how to start debugging / set command line args?

509 views
Skip to first unread message

Jason Aten

unread,
Jul 24, 2015, 9:46:09 AM7/24/15
to delve-dev
I've built a test binary (that runs my go tests). Now I want to debug with delve. How do I get dlv to run the program?

Also, how do I set the command line arguments to be passed to the executable? (https://github.com/derekparker/delve/issues/178)

What I tried:

$ go test -c -gcflags "-N -l" -v  # outputs myprog.test
$ dlv ./myprog.test -test.v -test.run 046 # attempting to set the command line args
Type 'help' for list of commands.
(dlv) run
Command failed: command not available
(dlv) c
Command failed: debugger isn't running
(dlv) help
The following commands are available:
    help - Prints the help message.
    break|b - Set break point at the entry point of a function, or at a specific file/line. Example: break foo.go:13
    continue|c - Run until breakpoint or program termination.
    step|si - Single step through program.
    next|n - Step over to next source line.
    threads - Print out info for every traced thread.
    thread|t - Switch to the specified thread.
    clear - Deletes breakpoint.
    clearall - Deletes all breakpoints.
    goroutines - Print out info for every goroutine.
    breakpoints|bp - Print out info for active breakpoints.
    print|p - Evaluate a variable.
    info - Provides info about args, funcs, locals, sources, or vars.
    exit - Exit the debugger.
(dlv) step
Command failed: debugger isn't running
(dlv)  ??? mystified

Jason Aten

unread,
Jul 24, 2015, 10:24:17 AM7/24/15
to delve-dev, j.e....@gmail.com, j.e....@gmail.com
might be an OSX thing. On linux I can get 'c' to start running the program. This was on OSX 10.9.5.

DerekP

unread,
Jul 26, 2015, 8:10:36 PM7/26/15
to delve-dev, j.e....@gmail.com, j.e....@gmail.com
To answer your questions:

* In order to pass flags / arguments to the new process see: https://github.com/derekparker/delve/wiki/Usage#passing-arguments
* You can use `dlv test` instead of manually building the binary yourself, to the same effect.
* Have you codesigned the dlv binary on OSX? That could lead to the "Command failed: debugger isn't running" errors you are seeing.
Message has been deleted

Jason Aten

unread,
Jul 27, 2015, 8:03:55 PM7/27/15
to delve-dev, parker...@gmail.com, parker...@gmail.com
I suspect it is something wonky with the code signing framework. I made it work on OSX 10.10.2 but not on Mavericks 10.9.5

Details on the OSX 10.9.5 fail:

~/dev/src/github.com/derekparker/delve (master) $ CERT=dlv-cert make install
go install github.com/derekparker/delve/cmd/dlv
codesign -s dlv-cert /Users/jaten/vtix/bin/dlv
/Users/jaten/dev/bin/dlv: is already signed           # yep, was already done.
make: *** [install] Error 1
$ dlv run ./my.test                  # the first time here it gave me a security popup and I gave it the admin pw, but it still fails to launch, saying:
could not launch process: invalid magic number in record at byte 0x0

Jason Aten

unread,
Jul 27, 2015, 8:14:22 PM7/27/15
to delve-dev, j.e....@gmail.com, parker...@gmail.com, j.e....@gmail.com
Update: however "dlv test" does appear to work, even when "dlv run myprog.test" does not

 $ dlv test

Type 'help' for list of commands.
(dlv) c
............
12 assertions thus far
...

The above on OSX 10.9.5

Rafael Díaz de León

unread,
Aug 10, 2016, 6:42:05 PM8/10/16
to delve-dev
On Sunday, 26 July 2015 19:10:36 UTC-5, DerekP wrote:
To answer your questions:

* In order to pass flags / arguments to the new process see: https://github.com/derekparker/delve/wiki/Usage#passing-arguments
* You can use `dlv test` instead of manually building the binary yourself, to the same effect.
* Have you codesigned the dlv binary on OSX? That could lead to the "Command failed: debugger isn't running" errors you are seeing.

Can we get an update on how to pass the arguments? The github wiki seems to be empty and I can't find
any reference on how to do it in the included documentation. I have also tried just calling the program and
appending the arguments as is I was calling it normally. 

Alessandro Arzilli

unread,
Aug 11, 2016, 9:27:44 AM8/11/16
to delv...@googlegroups.com
Put them after a "--"

dlv debug -- your arguments here


Reply all
Reply to author
Forward
0 new messages