Golang gdb: Difference between revisions

From wikinotes
Line 21: Line 21:
go build -gcflags "-N -l"  # build, disabling optimizations
go build -gcflags "-N -l"  # build, disabling optimizations
gdb executable
gdb executable
#> run                    # begin running executable
</syntaxhighlight>
</syntaxhighlight>



Revision as of 16:18, 26 June 2022

Instructions for debugging go with gdb.
Instructions vary by compiler

Documentation

go blog https://go.dev/doc/gdb

gc

NOTE:

haven't quite gotten this working yet

If compiled with gc (default).

go build -gcflags "-N -l"  # build, disabling optimizations
gdb executable
#> run                    # begin running executable

Then it's regular gdb commands

run                # begin running code
layout src         # show place in code
bt                 # show backtrace
break file.go:123  # set breakpoint in file.go, line:123