This is the basics. I can't find how to tell delve what command line arguments to pass to the executable being debugged.
In gdb, I would do "set args my.input.file.name", to have argv[1] set to my.input.file.name.
The same here, need help :(
dlv run [file] args. If file is omitted the package in the current directory
is used. Use -- to separate (flag) args to dlv itself from args to the
debugged binary.
$ cat echo.go
package main
import (
"fmt"
"os"
)
func main() {
fmt.Println(os.Args)
}
$ dlv run foo bar
Type 'help' for list of commands.
(dlv) continue
[./debug foo bar]
Process 10649 has exited with status 0
(dlv) exit
$ dlv run -- -a -b -c
Type 'help' for list of commands.
(dlv) continue
[./debug -a -b -c]
Process 11604 has exited with status 0
(dlv) exit
Thanks! That was a bit unexpected to omit the program path at all while using the -- separator, I've been trying this:
$ dlv run . -- -a -b -c
The run subcommand as it is currently implemented actually does not take an argument, but otherwise the above information is correct. Delve will pass any non-flag arguments after run to the new process. For flags, use -- and then any flags you would like to pass.
Docs updated at: https://github.com/derekparker/delve/wiki/Usage#passing-arguments
@glycerine additionally, there is no command to pass any flags / arguments to the process once your at the dlv prompt. By that time the process has already been created.
Hi @derekparker -- the way gdb does it: one uses "set args 1 2 3" and then "run". The run then uses the set args you just set when it re-launches the process. Does that make sense? Because you'll often times need to re-run the process a bunch of times when debugging, but not always with the exact same command line args.
Hi All.
The App we want to debug accepts a -key=value pairing as the command line argument. Delve does not seem to pass this string to the app correctly, as no Flags are received by the app when run from the debugger. Could this be because of unrecognised characters (e.g. =)? Is there a work-around?
@navonod: dlv debug -- -key=value seems to work for me.
I need 3 parameters
autotest -all -w ./
but, this dlv debug autotest/main.go -- -all=true -w=true -template_dir="./"
dosn't work, why ?
Most helpful comment
dlv run [file] args. If file is omitted the package in the current directoryis used. Use
--to separate (flag) args to dlv itself from args to thedebugged binary.