Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: runtime.closure's returned exectuable data confuses gdb #3738

Closed
lvdlvd opened this issue Jun 14, 2012 · 8 comments
Closed

runtime: runtime.closure's returned exectuable data confuses gdb #3738

lvdlvd opened this issue Jun 14, 2012 · 8 comments
Milestone

Comments

@lvdlvd
Copy link

lvdlvd commented Jun 14, 2012

runtime.closure generates a little exectuable block of data to bind the closure
variables and jump into the actual _func_001 block.  There is no way for cmd/ld/dwarf.c
to generate dwarf for this so GDB gets terribly confused: it does not recognize a call
to a function type variable as step-into-able and it doesn't know how to finish from a
call like that
@gopherbot
Copy link
Contributor

Comment 1 by joelgwebber:

To add a bit more color -- there are two separate-but-related issues here: stepping
*into* a call-through-function-pointer, and stepping *out* of a function so invoked.
With normal compiler flags (none, or just -N) stepping in actually works fine. Stepping
out is what confuses gdb in this case, and the only solution is to use "bt" to figure
out how you got where you are, then you need to set a breakpoint in the caller and
"c"ontinue.
Compiling with -l (disable inlining) breaks stepping in as well. In this case, gdb takes
you directly into the thunk rather than into the callee. From here you can only "stepi"
your way into the callee. Stepping out is broken as before.

@minux
Copy link
Member

minux commented Jun 14, 2012

Comment 2:

one way to solve that is to use gdb's jit interface
http://sourceware.org/gdb/current/onlinedocs/gdb/Registering-Code.html#Registering-Code
but i'm afraid it's much too heavy weight for our use case, maybe we just change closure
repr.
into a pointer pair (code_ptr, env_ptr) and then this will no longer be a problem
(additional
benefit would be more secure Go binaries with no writable&executable sections).
just a side note, misc/cgo/test has code that assumes the current presentation of
closures.

@ianlancetaylor
Copy link
Member

Comment 3:

Gcc uses the same technique for nested functions (an extension to C), and gdb seems to
work OK in that case.  That would be a possible avenue of investigation.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 5:

Labels changed: added priority-later, removed priority-triage.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 6:

Labels changed: added go1.1.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 7:

Labels changed: added size-l.

@bradfitz
Copy link
Contributor

Comment 9:

Owner changed to @rsc.

@rsc
Copy link
Contributor

rsc commented Feb 22, 2013

Comment 10:

This issue was closed by revision b1b67a3.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants