Breakpoints in runtime

210 views
Skip to first unread message

Mark Diener

unread,
Aug 31, 2022, 3:59:31 PM8/31/22
to golang-dev
Anybody have some advice on how to setup a build environment on macOSX (visual studio code) so I can build the golang using make.bash but also set breakpoints so I can step through code in the runtime instead of using println() statements.

Best, 

Mark

David Chase

unread,
Aug 31, 2022, 5:02:57 PM8/31/22
to Mark Diener, golang-dev
The way I usually do this (outside visual studio) is recompile my application "go build -gcflags=all='-N -l' ...".
I'm not sure how to set that option within VSCode, or if it is possible.  Debugging outside VSCode, I use either Delve or Gdlv.

Gdlv will wake up on a retina screen with a UI for ants, I believe you can fix that with CTRL-+.
Gdlv definitely passes the used-it-in-anger test.  

--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-dev/9ae10c2b-4c22-4947-abab-26b1cab17ac5n%40googlegroups.com.

Mark Diener

unread,
Sep 1, 2022, 8:39:09 AM9/1/22
to golang-dev
Hello DrC (& google-dev)

There is a script called make.bash that builds the compiler and runtime binary from the google source.

Is there a way to have make.bash build a debug version of the go binary and then I can trigger delve debugging from command line.

Maybe a suggested value for GO_GCFLAGS and maybe GO_LDFLAGS environment variables:

GO_GCFLAGS="all='-N -l' ...".

Any responses appreciated.

Mark

Alessandro Arzilli

unread,
Sep 1, 2022, 9:00:40 AM9/1/22
to Mark Diener, golang-dev
AFAIK the runtime can not be built with optimizations disabled. But you can
still place breakpoints inside the runtime of any go program.

Make.bash bootstraps the toolchain (compiler, linker, etc), the options you
specify through GO_GCFLAGS apply only to the executables it produces in bin/
and pkg/.
After that cmd/go can recompile the runtime, if it needs to, and the flags
that affect the runtime that ends up in your executables are the ones passed
to 'go build' with -gcflags (with some exceptions that are not supported
specifically for runtime), not the ones used for make.bash.

You don't need to run make.bash to make changes to the runtime.
> >> <https://groups.google.com/d/msgid/golang-dev/9ae10c2b-4c22-4947-abab-26b1cab17ac5n%40googlegroups.com?utm_medium=email&utm_source=footer>
> >> .
> >>
> >
>
> --
> You received this message because you are subscribed to the Google Groups "golang-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-dev/bd8c0109-ffb6-41f9-b744-a942589cb26dn%40googlegroups.com.

David Chase

unread,
Sep 1, 2022, 10:06:48 AM9/1/22
to Alessandro Arzilli, Mark Diener, golang-dev
On Thu, Sep 1, 2022, 9:00 AM Alessandro Arzilli <alessandr...@gmail.com> wrote:

You don't need to run make.bash to make changes to the runtime.

Until you make a breaking change to the runtime, not that anyone here would ever do that....


Reply all
Reply to author
Forward
0 new messages