delve/README.md

110 lines
4.1 KiB
Markdown
Raw Normal View History

2014-10-15 14:21:46 +00:00
# Delve
2014-05-03 20:31:52 +00:00
2015-02-14 23:29:33 +00:00
[![GoDoc](https://godoc.org/github.com/derekparker/delve?status.svg)](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
Delve requires Go 1.4 to build.
2014-08-23 13:50:18 +00:00
```
2015-02-24 04:36:03 +00:00
go get -u github.com/derekparker/delve/cmd/dlv
```
#### 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.
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
The debugger can be launched in three ways:
2014-10-25 17:35:05 +00:00
* Compile, run, and attach in one step:
```
2015-03-09 02:26:45 +00:00
$ dlv run
```
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
```
$ 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
```
2015-03-09 02:26:45 +00:00
$ sudo dlv attach 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.
* `breakpoints` - Print information on all active breakpoints.
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:
* `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
* `locals` - Prints the name and value of all local variables in the current context
* `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-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