Golang gdb: Difference between revisions

From wikinotes
Line 1: Line 1:
Instructions for debugging go with [[gdb]].<br>
Instructions for debugging go with [[gdb]].<br>
Instructions vary by compiler
Instructions vary by compiler
= Documentation =
<blockquote>
{| class="wikitable"
|-
| go blog || https://go.dev/doc/gdb
|-
|}
</blockquote><!-- Documentation -->


= gc =
= gc =
Line 10: Line 19:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
go build -gcflags "-N"
go build -gcflags "-N -l" # build, disabling optimizations
gdb executable
gdb executable
</syntaxhighlight>
</syntaxhighlight>
Line 16: Line 25:
Then it's regular gdb commands
Then it's regular gdb commands
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
run         # begin running code
run               # begin running code
layout src # show place in code
layout src         # show place in code
bt         # show backtrace
bt                 # show backtrace
break file.go:123  # set breakpoint in file.go, line:123
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- gc -->
</blockquote><!-- gc -->

Revision as of 16:17, 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

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