README.md 4.1 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
```
D
Derek Parker 已提交
16
go get -u github.com/derekparker/delve/cmd/dlv
17 18
```

D
Derek Parker 已提交
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#### Linux

You're done!

#### OS X

If you are on OS X a few extra steps must be taken. You must create a self signed certificate:

* Open application “Keychain Access” (/Applications/Utilities/Keychain Access.app)
* Open menu /Keychain Access/Certificate Assistant/Create a Certificate...
* Choose a name (dlv-cert in the example), set “Identity Type” to “Self Signed Root”, set “Certificate Type” to “Code Signing” and select the “Let me override defaults”. Click “Continue”. You might want to extend the predefined 365 days period to 3650 days.
* Click several times on “Continue” until you get to the “Specify a Location For The Certificate” screen, then set “Keychain to System”.
* If you can't store the certificate in the “System” keychain, create it in the “login” keychain, then export it. You can then import it into the “System” keychain.
* In keychains select “System”, and you should find your new certificate. Use the context menu for the certificate, select “Get Info”, open the “Trust” item, and set “Code Signing” to “Always Trust”.
* You must quit “Keychain Access” application in order to use the certificate and restart “taskgated” service by killing the current running “taskgated” process. Alternatively you can restart your computer.

All `make` commands assume a CERT environment variables that contains the name of the cert you created above.
Following that you can `CERT=mycert make install` which should install the binary and codesign it. For running tests, simply run `CERT=mycert make test`.

The makefile is only necessary to help facilitate the process of building and codesigning.
39

D
Derek Parker 已提交
40 41
### Features

D
Derek Parker 已提交
42 43
* Attach to an already running process
* Launch a process and begin debug session
D
Derek Parker 已提交
44
* Set breakpoints, single step, step over functions, print variable contents, print thread and goroutine information
D
Derek Parker 已提交
45 46 47

### Usage

48 49
The debugger can be launched in three ways:

D
Derek Parker 已提交
50
* Compile, run, and attach in one step:
51 52

	```
53
	$ dlv -run
54
	```
D
Derek Parker 已提交
55 56

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

D
Derek Parker 已提交
58
	```
59
	$ dlv path/to/program
D
Derek Parker 已提交
60
	```
D
Derek Parker 已提交
61 62 63

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

D
Derek Parker 已提交
64
	```
65
	$ sudo dlv -pid 44839
D
Derek Parker 已提交
66
	```
D
Derek Parker 已提交
67

D
Derek Parker 已提交
68 69 70 71 72 73
### 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 已提交
74 75
Once inside a debugging session, the following commands may be used:

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

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

D
Derek Parker 已提交
80
* `step` - Single step through program.
D
Derek Parker 已提交
81

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

D
Derek Parker 已提交
84
* `threads` - Print status of all traced threads.
D
Derek Parker 已提交
85 86 87

* `goroutines` - Print status of all goroutines.

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

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

M
Matt Self 已提交
97 98 99
* `exit` - Exit the debugger.


D
Derek Parker 已提交
100 101 102
### Upcoming features

* In-scope variable setting
D
Derek Parker 已提交
103
* Editor integration
D
Derek Parker 已提交
104 105

### License
D
Derek Parker 已提交
106 107

MIT