2014-10-15 14:21:46 +00:00
# Delve
2014-05-03 20:31:52 +00:00
2015-02-18 03:31:50 +00:00
[](https://travis-ci.org/github.com/derekparker/delve)
2015-02-14 23:29:33 +00:00
[](https://godoc.org/github.com/derekparker/delve)
2014-10-15 14:21:46 +00:00
### What is Delve?
2014-05-03 20:31:52 +00:00
2014-11-23 23:44:00 +00:00
Delve is a (Beta) Go debugger, written in Go.
This project is currently in beta. Most of the functionality is there, but there are various improvements to be made.
2014-05-03 20:31:52 +00:00
2014-08-23 13:50:18 +00:00
### Building
2014-11-25 00:09:55 +00:00
Delve requires Go 1.4 to build.
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-11-12 18:16:03 +00:00
You will need readline installed on your system. With apt simply: `sudo apt-get install libreadline-dev` .
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-14 07:41:12 +00:00
$ dlv 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-12-29 05:06:04 +00:00
* `info $type [regex]` - Outputs information about the symbol table. An optional regex filters the list. Example `info funcs unicode` . Valid types are:
2015-02-04 04:20:25 +00:00
* `args` - Prints the name and value of all arguments to the current function
2014-12-29 05:06:04 +00:00
* `funcs` - Prings the name of all defined functions
2014-12-30 17:57:31 +00:00
* `locals` - Prints the name and value of all local variables in the current context
2015-02-04 04:20:25 +00:00
* `sources` - Prings the path of all source files
* `vars` - Prints the name and value of all package variables in the app. Any variable that is not local or arg is considered a package variables
2014-12-28 08:28:50 +00:00
2014-11-12 03:41:29 +00:00
* `exit` - Exit the debugger.
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-11-15 16:55:22 +00:00
* Editor integration
2014-07-21 16:40:21 +00:00
### License
2014-05-03 20:31:52 +00:00
MIT