Golang gdb: Difference between revisions
From wikinotes
(→gc) |
(→gc) |
||
Line 26: | Line 26: | ||
Then it's regular gdb commands | Then it's regular gdb commands | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
# configure gdb for your execution | |||
break file.go:123 # set breakpoint in file.go, line:123 | |||
layout src # split-screen, displaying location in code | |||
# begin running code | |||
run | |||
# at breakpoints, inspect your code | |||
bt # show backtrace | bt # show backtrace | ||
p yourVar # print a variable | |||
l | |||
s # step into method | |||
n # next line | |||
exit # quit | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- gc --> | </blockquote><!-- gc --> |
Revision as of 16:23, 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 executableThen it's regular gdb commands
# configure gdb for your execution break file.go:123 # set breakpoint in file.go, line:123 layout src # split-screen, displaying location in code # begin running code run # at breakpoints, inspect your code bt # show backtrace p yourVar # print a variable l s # step into method n # next line exit # quit