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

D
Derek Parker 已提交
3
### What is Delve?
D
Derek Parker 已提交
4

D
Derek Parker 已提交
5 6 7
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 已提交
8

D
Derek Parker 已提交
9 10
### Building

D
Derek Parker 已提交
11
Delve requires Go 1.4 to build.
D
Derek Parker 已提交
12

13 14 15 16
```
go get github.com/derekparker/delve/cmd/dlv
```

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

D
Derek Parker 已提交
19 20
### Features

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

### Usage

27 28
The debugger can be launched in three ways:

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

	```
32
	$ dlv -run
33
	```
D
Derek Parker 已提交
34 35

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

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

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

D
Derek Parker 已提交
43
	```
44
	$ sudo dlv -pid 44839
D
Derek Parker 已提交
45
	```
D
Derek Parker 已提交
46

D
Derek Parker 已提交
47 48 49 50 51 52
### 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 已提交
53 54
Once inside a debugging session, the following commands may be used:

D
Derek Parker 已提交
55
* `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 已提交
56

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

D
Derek Parker 已提交
59
* `step` - Single step through program.
D
Derek Parker 已提交
60

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

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

* `goroutines` - Print status of all goroutines.

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

D
Derek Parker 已提交
69
* `info $type [regex]` - Outputs information about the symbol table. An optional regex filters the list. Example `info funcs unicode`. Valid types are:
E
epipho 已提交
70
  * `sources` - Prings the path of all source files
D
Derek Parker 已提交
71
  * `funcs` - Prings the name of all defined functions
E
epipho 已提交
72 73
  * `locals` - Prints the name and value of all local variables in the current context
  * `args` - Prints the name and value of all arguments to the current function
E
epipho 已提交
74

M
Matt Self 已提交
75 76 77
* `exit` - Exit the debugger.


D
Derek Parker 已提交
78 79 80
### Upcoming features

* In-scope variable setting
D
Derek Parker 已提交
81
* Support for OS X
D
Derek Parker 已提交
82
* Editor integration
D
Derek Parker 已提交
83 84

### License
D
Derek Parker 已提交
85 86

MIT