Build the code
go build -gcflags "-N -l" -o gdb_sandbox debug.go
The code generated by the gc compiler includes inlining of function invocations and registerization of variables.
These optimizations can sometimes make debugging with gdb harder.
To disable them when debugging, pass the flags -gcflags "-N -l" to the go command used to build the code being debugged.
Start gdb gdb gdb_sandbox
define breakpoint b day47/debug.go:6
let's start debugging run
navigate through lines using s
until line 11
tip: use n
inside greet function
print variable p greetingArg
learn more comands typing help
type q
to exit