* [PATCH] - Accept optional printed address at function breakpoints
@ 2003-12-08 16:25 Fred Fish
2003-12-08 16:48 ` Daniel Jacobowitz
2003-12-09 4:39 ` Fred Fish
0 siblings, 2 replies; 6+ messages in thread
From: Fred Fish @ 2003-12-08 16:25 UTC (permalink / raw)
To: gdb-patches; +Cc: fnf
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
$ gdb -nw -nx x
GNU gdb 2003-12-07-cvs
Copyright 2003 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 "i686-pc-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) br foo
Breakpoint 1 at 0x8048327: file x.c, line 2.
(gdb) br bar
Breakpoint 2 at 0x804832c: file x.c, line 8.
(gdb) run
Starting program: /links3/build/sourceware/gdb/T-i686-pc-linux-gnu/gdb/x
Breakpoint 1, 0x08048327 in foo () at x.c:2
2 {
(gdb) x/i $pc
0x8048327 <foo+3>: pop %ebp
(gdb) c
Continuing.
Breakpoint 2, bar () at x.c:8
8 }
(gdb) x/i $pc
0x804832c <bar+3>: pop %ebp
(gdb)
There are two things to note from the above run:
(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.
These messages are tested in lib/gdb.exp with:
proc gdb_continue { function } {
global decimal
return [gdb_test "continue" ".*Breakpoint $decimal, $function .*" "continue to $function"];
}
which does NOT allow any address in the breakpoint message.
If you disassemble the object file you can see the problem:
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
00000005 <bar>:
bar():
/build/sourceware/gdb/T-i686-pc-linux-gnu/gdb/x.c:6
5: 55 push %ebp
6: 89 e5 mov %esp,%ebp
/build/sourceware/gdb/T-i686-pc-linux-gnu/gdb/x.c:8
8: 5d pop %ebp
9: c3 ret
For the failing case (foo), the entire function body is covered by
just one source line, line number 2. For the succeeding case (bar)
there are two line numbers, one for the prologue code and one for the
epilogue code.
The documented behavior of gdb is to NOT print the address when it
hits a breakpoint at the first instruction associated with a new source
code line.
It's also interesting to note that the generated code is identical for
both functions, leading to a separate issue (bug?) of why gcc
generates different debug info for the two functions.
If we punt on the issue of whether or not the debug info is correct,
this patch fixes the problem.
-Fred
==================================================================
2003-12-08 Fred Fish <fnf@redhat.com>
* lib/gdb.exp (gdb_continue): Accept optional address printed
when stopping at a breakpointed function.
Index: lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.41
diff -c -r1.41 gdb.exp
*** lib/gdb.exp 23 Nov 2003 01:09:19 -0000 1.41
--- lib/gdb.exp 8 Dec 2003 16:21:36 -0000
***************
*** 1616,1623 ****
proc gdb_continue { function } {
global decimal
! return [gdb_test "continue" ".*Breakpoint $decimal, $function .*" "continue to $function"];
}
proc default_gdb_init { args } {
--- 1616,1624 ----
proc gdb_continue { function } {
global decimal
+ global hex
! return [gdb_test "continue" ".*Breakpoint $decimal, ($hex in )?$function .*" "continue to $function"];
}
proc default_gdb_init { args } {
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] - Accept optional printed address at function breakpoints
2003-12-08 16:25 [PATCH] - Accept optional printed address at function breakpoints Fred Fish
@ 2003-12-08 16:48 ` Daniel Jacobowitz
2003-12-08 17:51 ` Fred Fish
2003-12-09 4:39 ` Fred Fish
1 sibling, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2003-12-08 16:48 UTC (permalink / raw)
To: fnf; +Cc: gdb-patches
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
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] - Accept optional printed address at function breakpoints
2003-12-08 16:48 ` Daniel Jacobowitz
@ 2003-12-08 17:51 ` Fred Fish
0 siblings, 0 replies; 6+ messages in thread
From: Fred Fish @ 2003-12-08 17:51 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
On Monday 08 December 2003 09:47, Daniel Jacobowitz wrote:
> > $ gcc -g -o x x.c
>
> What GCC version?
gcc version 3.4 20031207 (experimental)
> 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.
OK, though we might want to review the few places in the testsuite
that allow an optional address to ensure that we are enforcing this
behavior.
It's also interesting to read the comments in condbreak.exp:
# GCC's Dwarf2 writer, on the other hand, squeezes out duplicate line
# entries, so GDB considers the source line to begin at the start of
# the function's prologue. Thus, if the program stops at the
# breakpoint, GDB will decide that the PC is not at the beginning of a
# source line, and will print an address.
#
# I think the Dwarf2 writer's behavior is arguably correct, but not
# helpful. If the user sets a breakpoint at that source line, they
# want that breakpoint to fall after the prologue. Identifying the
# prologue's code with the opening brace is nice, but it shouldn't
# take precedence over real code.
#
# Until the Dwarf2 writer gets fixed, I'm going to XFAIL its behavior.
On one hand, I can see the value of having just a single test that
focuses on confirming/enforcing this behavior and be more lenient
about the patterns we accept in general. On the other hand, I can see
that having dozens of new failures pop up due to a change in gcc debug
output could be helpful in getting enough attention to get the problem
fixed.
> This doesn't tell you anything. Objdump -S will coalesce identical
> line notes. You need to look at the debug info. For instance:
Sorry, I should have mentioned that I also checked the debug output
with "dwarfdump", which produces:
line number info
<source> [row,column] <pc> //<new statement or basic block
/build/sourceware/gdb/T-i686-pc-linux-gnu/gdb/x.c: [ 2,-1] 0
// new statement
/build/sourceware/gdb/T-i686-pc-linux-gnu/gdb/x.c: [ 6,-1] 0x5
// new statement
/build/sourceware/gdb/T-i686-pc-linux-gnu/gdb/x.c: [ 8,-1] 0x8
// new statement
/build/sourceware/gdb/T-i686-pc-linux-gnu/gdb/x.c: [ 11,-1] 0xa
// new statement
/build/sourceware/gdb/T-i686-pc-linux-gnu/gdb/x.c: [ 12,-1] 0x26
// new statement
/build/sourceware/gdb/T-i686-pc-linux-gnu/gdb/x.c: [ 13,-1] 0x2b
// new statement
/build/sourceware/gdb/T-i686-pc-linux-gnu/gdb/x.c: [ 14,-1] 0x30
// new statement
/build/sourceware/gdb/T-i686-pc-linux-gnu/gdb/x.c: [ 14,-1] 0x32
// new statement // end of text sequence
> 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.
Here is what I get from "readelf --debug-dump=line x" after compiling
my test case with "gcc -g -o x x.c":
Line Number Statements:
Extended opcode 2: set Address to 0x8048324
Special opcode 6: advance Address by 0 to 0x8048324 and Line by 1 to 2
Special opcode 79: advance Address by 5 to 0x8048329 and Line by 4 to 6
Special opcode 49: advance Address by 3 to 0x804832c and Line by 2 to 8
Special opcode 36: advance Address by 2 to 0x804832e and Line by 3 to 11
Advance PC by constant 17 to 0x804833f
Special opcode 160: advance Address by 11 to 0x804834a and Line by 1 to 12
Special opcode 76: advance Address by 5 to 0x804834f and Line by 1 to 13
Special opcode 76: advance Address by 5 to 0x8048354 and Line by 1 to 14
Advance PC by 2 to 8048356
Extended opcode 1: End of Sequence
The native RedHat 9 gcc (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
produces:
Line Number Statements:
Extended opcode 2: set Address to 0x80482f4
Special opcode 6: advance Address by 0 to 0x80482f4 and Line by 1 to 2
Special opcode 48: advance Address by 3 to 0x80482f7 and Line by 1 to 3
Special opcode 36: advance Address by 2 to 0x80482f9 and Line by 3 to 6
Special opcode 49: advance Address by 3 to 0x80482fc and Line by 2 to 8
Special opcode 36: advance Address by 2 to 0x80482fe and Line by 3 to 11
Special opcode 230: advance Address by 16 to 0x804830e and Line by 1 to 12
Special opcode 76: advance Address by 5 to 0x8048313 and Line by 1 to 13
Special opcode 76: advance Address by 5 to 0x8048318 and Line by 1 to 14
Advance PC by 2 to 804831a
Extended opcode 1: End of Sequence
and gdb on that executable does behave as the current testsuite expects:
(gdb) br foo
Breakpoint 1 at 0x80482f7: file x.c, line 3.
(gdb) br bar
Breakpoint 2 at 0x80482fc: file x.c, line 8.
(gdb) run
Starting program: /links3/build/sourceware/gdb/T-i686-pc-linux-gnu/gdb/x
Breakpoint 1, foo () at x.c:3
3 }
(gdb) c
Continuing.
Breakpoint 2, bar () at x.c:8
8 }
So this does look like a regression in gcc debug output. I hereby withdraw
my suggested patch. :-)
-Fred
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] - Accept optional printed address at function breakpoints
2003-12-08 16:25 [PATCH] - Accept optional printed address at function breakpoints Fred Fish
2003-12-08 16:48 ` Daniel Jacobowitz
@ 2003-12-09 4:39 ` Fred Fish
1 sibling, 0 replies; 6+ messages in thread
From: Fred Fish @ 2003-12-09 4:39 UTC (permalink / raw)
To: gdb-patches; +Cc: fnf
> If we punt on the issue of whether or not the debug info is correct,
Just for the record, I reported this as a gcc bug:
http://gcc.gnu.org/ml/gcc-bugs/2003-12/msg01018.html
-Fred
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] - Accept optional printed address at function breakpoints
@ 2003-12-08 16:53 Michael Elizabeth Chastain
0 siblings, 0 replies; 6+ messages in thread
From: Michael Elizabeth Chastain @ 2003-12-08 16:53 UTC (permalink / raw)
To: drow, fnf; +Cc: gdb-patches
drow> This is a debug info bug. Your patch is not correct; when you say
drow> "break LINE" or "break FUNCTION" and there is debug info, it's GDB's
drow> established behavior to stop at the beginning of a line. By not
drow> allowing the address we verify that GDB is stopping at the beginning of
drow> a line as expected.
That's right. It's a subtle way of testing that the line number
information is correct. If gdb prints a machine address in addition
to a line number, then either gcc has a bug in debug info output,
or gdb has a bug in debug info input.
Michael C
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] - Accept optional printed address at function breakpoints
@ 2003-12-08 18:02 Michael Elizabeth Chastain
0 siblings, 0 replies; 6+ messages in thread
From: Michael Elizabeth Chastain @ 2003-12-08 18:02 UTC (permalink / raw)
To: fnf; +Cc: drow, gdb-patches
Fred Fish writes:
> On one hand, I can see the value of having just a single test that
> focuses on confirming/enforcing this behavior and be more lenient
> about the patterns we accept in general. On the other hand, I can see
> that having dozens of new failures pop up due to a change in gcc debug
> output could be helpful in getting enough attention to get the problem
> fixed.
I favor the first hand. I would like to have one specific test script
which is devoted to this issue with a bunch of cases in it. Then let it
slide in every other test script.
To be sure, we might not get complete coverage of this bug without all
the windfall testing from other places. But it's just not a very
important bug to users, so I think it's not worth vitiating other parts
of the test suite just to get more coverage of this bug.
As far as the "dozens of new failures" go, it is easier for me if a bug
causes one FAIL rather than a dozen FAILs. I do track every individual
result change.
Michael C
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-12-09 4:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-08 16:25 [PATCH] - Accept optional printed address at function breakpoints Fred Fish
2003-12-08 16:48 ` Daniel Jacobowitz
2003-12-08 17:51 ` Fred Fish
2003-12-09 4:39 ` Fred Fish
2003-12-08 16:53 Michael Elizabeth Chastain
2003-12-08 18:02 Michael Elizabeth Chastain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox