[PATCH] - Accept optional printed address at function breakpoints

Daniel Jacobowitz drow@mvista.com
Mon Dec 8 16:48:00 GMT 2003


On Mon, Dec 08, 2003 at 09:25:06AM -0700, Fred Fish wrote:
> I decided to investigate the following failure in funcargs.exp:
> 
>   FAIL: gdb.base/funcargs.exp: continue to call6k
> 
> The problem can reproduced using:
> 
>   void foo ()
>   {
>   }
> 
>   void bar ()
>   {
>     static int dummy = 0;
>   }
> 
>   main ()
>   {
>     foo ();
>     bar ();
>   }
> 
> Using x86 native gdb:
> 
>   $ gcc -g -o x x.c

What GCC version?

>   (1) Both functions stop at the same relative position in each of
>   foo() and bar().  Gdb is smart enough to break at the first 
>   instruction after the prologue.
> 
>   (2) The breakpoint message for bar() does NOT include an address,
>   while the one for foo() does contain an address.

This is a debug info bug.  Your patch is not correct; when you say
"break LINE" or "break FUNCTION" and there is debug info, it's GDB's
established behavior to stop at the beginning of a line.  By not
allowing the address we verify that GDB is stopping at the beginning of
a line as expected.

>   00000000 <foo>:
>   foo():
>   /build/sourceware/gdb/T-i686-pc-linux-gnu/gdb/x.c:2
>      0:   55                      push   %ebp
>      1:   89 e5                   mov    %esp,%ebp
>      3:   5d                      pop    %ebp
>      4:   c3                      ret    

This doesn't tell you anything.  Objdump -S will coalesce identical
line notes.  You need to look at the debug info.  For instance:

08048334 <foo>:
void foo ()
{
 8048334:       55                      push   %ebp
 8048335:       89 e5                   mov    %esp,%ebp
 8048337:       5d                      pop    %ebp
 8048338:       c3                      ret

08048339 <bar>:
}
void bar ()
{
 8048339:       55                      push   %ebp
 804833a:       89 e5                   mov    %esp,%ebp
  static int dummy = 0;
}
 804833c:       5d                      pop    %ebp
 804833d:       c3                      ret


 Line Number Statements:
  Extended opcode 2: set Address to 0x8048334
  Special opcode 6: advance Address by 0 to 0x8048334 and Line by 1 to 2
  Special opcode 47: advance Address by 3 to 0x8048337 and Line by 0 to 2
  Special opcode 36: advance Address by 2 to 0x8048339 and Line by 3 to 5
  Special opcode 49: advance Address by 3 to 0x804833c and Line by 2 to 7
  Special opcode 35: advance Address by 2 to 0x804833e and Line by 2 to 9
  Special opcode 230: advance Address by 16 to 0x804834e and Line by 1 to 10
  Special opcode 76: advance Address by 5 to 0x8048353 and Line by 1 to 11
  Special opcode 76: advance Address by 5 to 0x8048358 and Line by 1 to 12
  Advance PC by 2 to 804835a
  Extended opcode 1: End of Sequence

Notice the special opcode 47 which advances address, but not line?  GDB
recognizes that and uses it to find the end of the prologue.  If you
haven't got one of those, something is wrong.


-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer



More information about the Gdb-patches mailing list