Subject: Re: gdb versus threads?
To: Nathan J. Williams <nathanw@wasabisystems.com>
From: Ben Collver <collver@peak.org>
List: netbsd-users
Date: 06/03/2006 05:51:41
On Mon, May 29, 2006 at 11:21:58AM -0400, Nathan J. Williams wrote:
> What do "info registers", "info frame", and "backtrace" show you?
> Something thinks that the frame has an address of 0.  Figuring out
> why the debugger thinks that about the frame is important.

Thank you for the help.  Here is output from info registers, info frame,
and backtrace:

(gdb) p pos
Cannot access memory at address 0x24
(gdb) info address pos
Symbol "pos" is a local variable at frame offset 36.
(gdb) info registers
eax            0x14     20
ecx            0xbd6edac5       -1116808507
edx            0x0      0
ebx            0xbfbfd2f0       -1077947664
esp            0xbfbfcfb0       0xbfbfcfb0
ebp            0x0      0x0
esi            0x81922e0        135865056
edi            0xbfbfd2f0       -1077947664
eip            0x80f3891        0x80f3891 <aifcReadHeader+329>
eflags         0x396    918
cs             0x17     23
ss             0x1f     31
ds             0x1f     31
es             0x1f     31
fs             0x0      0
gs             0x0      0
(gdb) info frame
Stack level 0, frame at 0x0:
 eip = 0x80f3891 in aifcReadHeader (aifc.c:281); saved eip 0x80f3891
 source language c.
 Arglist at unknown address.
 Locals at unknown address, Previous frame's sp in esp
(gdb) backtrace
#0  aifcReadHeader (fd=???, fname=???, hdr=???, firstlong=???, p=???)
    at aifc.c:281


> On a lark, do you get different results if you compile with "-gdwarf-2 -O0"?

Yes, the problem goes away when I use dwarf2.

(gdb) p pos
$3 = 135918415
(gdb) info address pos
Symbol "pos" is a variable with complex or multiple locations (DWARF2).
(gdb) info registers
eax            0x14     20
ecx            0xbd6edac5       -1116808507
edx            0x0      0
ebx            0xbfbfd2e0       -1077947680
esp            0xbfbfcfa0       0xbfbfcfa0
ebp            0x0      0x0
esi            0x81922e0        135865056
edi            0xbfbfd2e0       -1077947680
eip            0x80f3891        0x80f3891 <aifcReadHeader+329>
eflags         0x396    918
cs             0x17     23
ss             0x1f     31
ds             0x1f     31
es             0x1f     31
fs             0x0      0
gs             0x0      0
(gdb) info frame
Stack level 0, frame at 0xbfbfd1a0:
 eip = 0x80f3891 in aifcReadHeader (aifc.c:281); saved eip 0x80a83c7
 called by frame at 0xbfbfd1c4
 source language c.
 Arglist at unknown address.
 Locals at unknown address, Previous frame's sp is 0xbfbfd1a0
 Saved registers:
  ebx at 0xbfbfd18c, ebp at 0xbfbfd198, esi at 0xbfbfd190, edi at 0xbfbfd194,
  eip at 0xbfbfd19c
(gdb) backtrace
#0  aifcReadHeader (fd=135865056, fname=0x8192b14 "", hdr=0xa, 
    firstlong=134906823, p=0xbfbfd2e0) at aifc.c:281
#1  0x080a83c7 in readheader (ifd=10, sfname=0x0, p=0xbfbfd2e0)
    at sfheader.c:154
#2  0xbfbfd210 in ?? ()
#3  0x00000000 in ?? ()