2014-10-15 14:21:46 +00:00
# Delve
2014-05-03 20:31:52 +00:00
2014-10-15 14:21:46 +00:00
### What is Delve?
2014-05-03 20:31:52 +00:00
2014-10-25 17:35:05 +00:00
Delve is a Go debugger, written in Go.
2014-05-03 20:31:52 +00:00
2014-08-23 13:50:18 +00:00
### Building
2014-10-15 14:21:46 +00:00
Currently, Delve requires the following [patch ](https://codereview.appspot.com/117280043/ ), however this change is vendored until Go 1.4 lands, so the project is go get-able.
2014-08-23 13:50:18 +00:00
2014-11-10 23:12:46 +00:00
```
go get github.com/derekparker/delve/cmd/dlv
```
2014-07-21 16:40:21 +00:00
### Features
2014-10-25 17:35:05 +00:00
* Attach to an already running process
* Launch a process and begin debug session
2014-11-11 22:31:43 +00:00
* Set breakpoints, single step, step over functions, print variable contents, print thread and goroutine information
2014-07-21 16:40:21 +00:00
### Usage
2014-10-13 23:30:37 +00:00
The debugger can be launched in three ways:
2014-10-25 17:35:05 +00:00
* Compile, run, and attach in one step:
2014-10-13 23:30:37 +00:00
```
2014-11-10 23:12:46 +00:00
$ dlv -run
2014-10-13 23:30:37 +00:00
```
2014-08-27 22:51:56 +00:00
* Provide the name of the program you want to debug, and the debugger will launch it for you.
2014-10-25 17:35:05 +00:00
2014-08-28 01:33:46 +00:00
```
2014-11-10 23:12:46 +00:00
$ dlv -proc path/to/program
2014-08-28 01:33:46 +00:00
```
2014-08-27 22:51:56 +00:00
* Provide the pid of a currently running process, and the debugger will attach and begin the session.
2014-08-28 01:33:46 +00:00
```
2014-11-10 23:12:46 +00:00
$ sudo dlv -pid 44839
2014-08-28 01:33:46 +00:00
```
2014-08-27 22:51:56 +00:00
2014-11-10 14:28:53 +00:00
### Breakpoints
Delve can insert breakpoints via the `breakpoint` command once inside a debug session, however for ease of debugging, you can also call `runtime.Breakpoint()` and Delve will handle the breakpoint and stop the program at the next source line.
### Commands
2014-08-27 22:51:56 +00:00
Once inside a debugging session, the following commands may be used:
2014-07-21 16:41:50 +00:00
* `break` - Set break point at the entry point of a function, or at a specific file/line. Example: `break foo.go:13` .
2014-07-21 16:40:21 +00:00
2014-10-18 15:41:55 +00:00
* `continue` - Run until breakpoint or program termination.
2014-07-21 16:41:50 +00:00
* `step` - Single step through program.
2014-07-21 16:40:21 +00:00
2014-07-21 16:41:50 +00:00
* `next` - Step over to next source line.
2014-07-21 16:40:21 +00:00
2014-11-11 22:31:43 +00:00
* `threads` - Print status of all traced threads.
2014-11-09 20:19:32 +00:00
* `goroutines` - Print status of all goroutines.
2014-10-14 14:56:22 +00:00
* `print $var` - Evaluate a variable.
2014-07-21 16:40:21 +00:00
### Upcoming features
* In-scope variable setting
2014-07-30 00:00:03 +00:00
* Support for OS X
2014-07-21 16:40:21 +00:00
### License
2014-05-03 20:31:52 +00:00
MIT