golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123k stars 17.54k forks source link

cmd/compile: include registerization info for gdb #2430

Open ianlancetaylor opened 12 years ago

ianlancetaylor commented 12 years ago
What steps will reproduce the problem?

foo.go:

package main

import "os"

type I interface{}

func main() {
    var i I = 1
    os.Exit(i.(int))
}

6g foo.go
6l foo.6
gdb 6.out
GNU gdb (GDB) 7.2-gg20
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>;
Type "show copying" and "show warranty" for licensing/warranty
details.
This GDB was configured as "x86_64-linux".

<http://wiki/Main/GnuDebugger  FAQ: http://go/gdb  Email: gdb-team  IRC: #gdb>
Hey, I'm GDB 7.x.  Check me out!  http://wiki/Main/Gdb7x

Reading symbols from /home/iant/gcc/gccgo2-objdir/6.out...done.
Loading Go Runtime support.
(gdb) break foo.go:9
Breakpoint 1 at 0x400c36: file /home/iant/foo1.go, line 9.
(gdb) run
Starting program: /home/iant/gcc/gccgo2-objdir/6.out 

Breakpoint 1, main.main () at /home/iant/foo1.go:9
9       os.Exit(i.(int))
(gdb) print i
No symbol "i" in current context.
(gdb) info locals
No locals.
(gdb) step
runtime.assertE2T (t=void, e=void) at /home/iant/go/src/pkg/runtime/iface.c:286
286 runtime·assertE2T(Type *t, Eface e, ...)
(gdb) finish
Run till exit from #0  runtime.assertE2T (t=void, e=void)
    at /home/iant/go/src/pkg/runtime/iface.c:286
0x0000000000400c4f in main.main () at /home/iant/foo1.go:9
9       os.Exit(i.(int))
(gdb) print i
No symbol "i" in current context.
(gdb) step
os.Exit (code=1) at /home/iant/go/src/pkg/os/proc.go:34
34  func Exit(code int) { syscall.Exit(code) }

What is the expected output?

I expect to see information about the local variable.
rsc commented 12 years ago

Comment 1:

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

rsc commented 12 years ago

Comment 2:

Labels changed: added priority-go1.

lvdlvd commented 12 years ago

Comment 3:

This seems to happen for local variables that have been registerized completely, so that
their stack frame entry has been eliminated.   6nm shows no entry for 'i' in foo.6, nor
does it occur in 6g -S output.
then if it were present, the ld/dwarf code currently does not describe information about
registerized variables.
i'll think about the best way to pass both hurdles.
rsc commented 12 years ago

Comment 4:

If this is only about registerized variables then it can wait until after Go 1.
Nothing in the tool chain preserves that information.

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

rsc commented 12 years ago

Comment 5:

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

rsc commented 11 years ago

Comment 6:

Owner changed to @rsc.

gopherbot commented 10 years ago

Comment 7 by martin.kobetic@jadedpixel.com:

not seeing locals at all makes debugging quite difficult. Is there any workaround for
this? Anything better than disassembling the function and then trying to infer the
values directly from the registers?
rsc commented 10 years ago

Comment 8:

The usual workaround is print statements.
rsc commented 10 years ago

Comment 9:

Labels changed: added repo-main.

rsc commented 10 years ago

Comment 10:

Adding Release=None to all Priority=Someday bugs.

Labels changed: added release-none.

rsc commented 10 years ago

Comment 11:

Issue #7659 has been merged into this issue.