gdb debug info missing for local variable

865 views
Skip to first unread message

Jason E. Aten

unread,
Nov 9, 2013, 5:23:24 PM11/9/13
to golang-nuts
I'm seeing gdb debug info missing for some local variables in go1.2rc3/amd64/linux. Is this a known issue? (I'm not sure how/where to search for these things). I'm using gdb 7.4-2012.04-0ubuntu2.1.

code snippet:

     s3, err := capn.ReadFromStream(file2, nil)
      if err != nil {
          fmt.Printf("read error %v\n", err)
                  return
      }

and in gdb after stepping past the above lines:

(gdb) p s3
No symbol "s3" in current context.
(gdb) list
269     RET
270
271 // int64 clone(int32 flags, void *stack, M *mp, G *gp, void (*fn)(void));
272 TEXT runtime·clone(SB),NOSPLIT,$0
273     MOVL    flags+8(SP), DI
274     MOVQ    stack+16(SP), SI
275
276     // Copy mp, gp, fn off parent stack for use by child.
277     // Careful: Linux system call clobbers CX and R11.
278     MOVQ    mm+24(SP), R8
(gdb) i lo
file = 0xc210000058
s2 = 0xc21001d330
&buf2 = 0xc210048070
s = 0xc21001d2d0
b·3 = 0xc21001d2d0
file2 = 0xc210000068
&buf = 0xc210048000
fn = {str = 0x5320b0 "sample.zdate.cp", len = 15}
err = {tab = 0x0, data = 0x0}
data·2 = {array = 0x0, len = 0, cap = 0}
z2 = {Segment = 0xc21001d330, off = 8, length = 0, datasz = 16, ptrs = 1, typ = 1 '\001', flags = 0}
d = {Segment = 0xc21001d2d0, off = 32, length = 0, datasz = 8, ptrs = 0, typ = 1 '\001', flags = 0}
d2 = {Segment = 0xc21001d330, off = 32, length = 0, datasz = 8, ptrs = 0, typ = 1 '\001', flags = 0}
z = {Segment = 0xc21001d2d0, off = 8, length = 0, datasz = 16, ptrs = 1, typ = 1 '\001', flags = 0}
d3 = {Segment = 0x41d419, off = 833492210096, length = 4314137, datasz = 833492340864, ptrs = 1664, typ = 0 '\000', flags = 4233167}
z3 = {Segment = 0x10, off = 4314137, length = 4319617, datasz = 4314137, ptrs = 833492132336, typ = 16 '\020', flags = 4319744}
(gdb)

you fu

unread,
Nov 10, 2013, 7:49:46 PM11/10/13
to golan...@googlegroups.com
how to run gdb debug ?
gdb progromming?

mkob...@gmail.com

unread,
Nov 10, 2013, 8:15:14 PM11/10/13
to Jason E. Aten, golang-nuts
Maybe it's this: https://code.google.com/p/go/issues/detail?id=2430

"Jason E. Aten"<j.e....@gmail.com> wrote:
> Date: November 9, 2013 5:23:24 PM
> From: "Jason E. Aten" <j.e....@gmail.com>
> To: golang-nuts<golan...@googlegroups.com>
> Subject: [go-nuts] gdb debug info missing for local variable
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Jason E. Aten

unread,
Nov 11, 2013, 2:15:58 AM11/11/13
to mkob...@gmail.com, golang-nuts
Spot on @mkobetic, thank you! Looking at the disassembly, my invisible-to-gdb variable 's3' is indeed sitting in the %rax register.

If I add a print out for s3, and then re-inspect the disassembly, I see it is now stack allocated, not registerized, and gdb shows it as a local variable in "i lo" output.

Thanks again, @mkobetic, for the pointer to bug 2430, "cmd/gc: include registerization info for gdb".


minux

unread,
Nov 11, 2013, 2:40:53 AM11/11/13
to Jason E. Aten, mkob...@gmail.com, golang-nuts

On Mon, Nov 11, 2013 at 2:15 AM, Jason E. Aten <j.e....@gmail.com> wrote:
Spot on @mkobetic, thank you! Looking at the disassembly, my invisible-to-gdb variable 's3' is indeed sitting in the %rax register.

If I add a print out for s3, and then re-inspect the disassembly, I see it is now stack allocated, not registerized, and gdb shows it as a local variable in "i lo" output.

Thanks again, @mkobetic, for the pointer to bug 2430, "cmd/gc: include registerization info for gdb".
If registeratization is the problem, you probably didn't read golang.org/doc/gdb

-gcflags "-N -l" will do the trick.
Reply all
Reply to author
Forward
0 new messages