Stack frame problem in gdb

Yar Tikhiy yar at comp.chem.msu.su
Tue May 16 00:12:50 PDT 2006


Hi folks,

Has our stock GDB lost the ability to set the current stack frame
by its address?  In 4.11-STABLE, the old recipe from the Developer's
Handbook still works:

	frame <frame_addr> <instruction_ptr>

Alas, it no longer works in RELENG_6 or CURRENT (tested on i386 and
amd64.)  A sample typescript is attached.  It boils down to the
following: The "frame" command accepts one argument at most in the
new GDB, which is taken for the address of a frame if it's sufficiently
large.  Refusing now to read the instruction pointer value from the
command line, GDB sets it to 0 -- a smart guess, damn it.  Finally,
GDB crashes on the bogus frame it made up.

What do you think this is, a GDB bug or my misunderstanding?  Thanks!

-- 
Yar

########################################################################

%cat test.c
main()
{
        foo(1);
}

foo(a)
        int a;
{
        return (a + bar(a));
}

bar(x)
        int x;
{
        return (x * x);
}
%gcc -g test.c
%gdb a.out
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
(gdb) b bar
Breakpoint 1 at 0x80484d7: file test.c, line 15.
(gdb) r
Starting program: /usr/home/yar/a.out

Breakpoint 1, bar (x=1) at test.c:15
15              return (x * x);
(gdb) bt
#0  bar (x=1) at test.c:15
#1  0x080484c9 in foo (a=1) at test.c:9
#2  0x080484b2 in main () at test.c:3
(gdb) info f 1
Stack frame at 0xbfbfec30:
 eip = 0x80484c9 in foo (test.c:9); saved eip 0x80484b2
 called by frame at 0xbfbfec60, caller of frame at 0xbfbfec10
 source language c.
 Arglist at 0xbfbfec28, args: a=1
 Locals at 0xbfbfec28, Previous frame's sp is 0xbfbfec30
 Saved registers:
  ebp at 0xbfbfec28, eip at 0xbfbfec2c
(gdb) frame 0xbfbfec30 0x80484c9
Too many args in frame specification
(gdb) frame 0xbfbfec30
#0  0x00000000 in ?? ()
(gdb) info f
Stack level 0, frame at 0xbfbfec30:
 eip = 0x0; saved eip
/usr/src/gnu/usr.bin/gdb/libgdb/../../../../contrib/gdb/gdb/dwarf2-frame.c:613: internal-error: dwarf2_frame_cache: Assertion `fde != NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

########################################################################


More information about the freebsd-hackers mailing list