README.md 2.5 KB
Newer Older
D
Derek Parker 已提交
1
# Delve
D
Derek Parker 已提交
2

F
Florin Patan 已提交
3 4
[![GoDoc](https://godoc.org/github.com/derekparker/delve?status.svg)](https://godoc.org/github.com/derekparker/delve)

D
Derek Parker 已提交
5
### What is Delve?
D
Derek Parker 已提交
6

D
Derek Parker 已提交
7 8 9
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.
D
Derek Parker 已提交
10

D
Derek Parker 已提交
11 12
### Building

D
Derek Parker 已提交
13
Delve requires Go 1.4 to build.
D
Derek Parker 已提交
14

15 16 17 18
```
go get github.com/derekparker/delve/cmd/dlv
```

19 20
You will need readline installed on your system. With apt simply: `sudo apt-get install libreadline-dev` .

D
Derek Parker 已提交
21 22
### Features

D
Derek Parker 已提交
23 24
* Attach to an already running process
* Launch a process and begin debug session
D
Derek Parker 已提交
25
* Set breakpoints, single step, step over functions, print variable contents, print thread and goroutine information
D
Derek Parker 已提交
26 27 28

### Usage

29 30
The debugger can be launched in three ways:

D
Derek Parker 已提交
31
* Compile, run, and attach in one step:
32 33

	```
34
	$ dlv -run
35
	```
D
Derek Parker 已提交
36 37

* Provide the name of the program you want to debug, and the debugger will launch it for you.
D
Derek Parker 已提交
38

D
Derek Parker 已提交
39
	```
40
	$ dlv path/to/program
D
Derek Parker 已提交
41
	```
D
Derek Parker 已提交
42 43 44

* Provide the pid of a currently running process, and the debugger will attach and begin the session.

D
Derek Parker 已提交
45
	```
46
	$ sudo dlv -pid 44839
D
Derek Parker 已提交
47
	```
D
Derek Parker 已提交
48

D
Derek Parker 已提交
49 50 51 52 53 54
### 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

D
Derek Parker 已提交
55 56
Once inside a debugging session, the following commands may be used:

D
Derek Parker 已提交
57
* `break` - Set break point at the entry point of a function, or at a specific file/line. Example: `break foo.go:13`.
D
Derek Parker 已提交
58

J
Jack Christensen 已提交
59 60
* `continue` - Run until breakpoint or program termination.

D
Derek Parker 已提交
61
* `step` - Single step through program.
D
Derek Parker 已提交
62

D
Derek Parker 已提交
63
* `next` - Step over to next source line.
D
Derek Parker 已提交
64

D
Derek Parker 已提交
65
* `threads` - Print status of all traced threads.
D
Derek Parker 已提交
66 67 68

* `goroutines` - Print status of all goroutines.

D
Derek Parker 已提交
69 70
* `print $var` - Evaluate a variable.

D
Derek Parker 已提交
71
* `info $type [regex]` - Outputs information about the symbol table. An optional regex filters the list. Example `info funcs unicode`. Valid types are:
72
  * `args` - Prints the name and value of all arguments to the current function
D
Derek Parker 已提交
73
  * `funcs` - Prings the name of all defined functions
E
epipho 已提交
74
  * `locals` - Prints the name and value of all local variables in the current context
75 76
  * `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
E
epipho 已提交
77

M
Matt Self 已提交
78 79 80
* `exit` - Exit the debugger.


D
Derek Parker 已提交
81 82 83
### Upcoming features

* In-scope variable setting
D
Derek Parker 已提交
84
* Support for OS X
D
Derek Parker 已提交
85
* Editor integration
D
Derek Parker 已提交
86 87

### License
D
Derek Parker 已提交
88 89

MIT