Re: [RFA] Patch to skip_prologue_using_sal() for oneline stub functions

Fred Fish
2006-05-13T19:44:20Z

On Saturday 13 May 2006 05:28, Mark Kettenis wrote:
> That said, how does this handle functions like:
> <examples>
> Did you check that?

I retested with the following sourcefile, printed here with line
numbers for reference:

1 void first ()
2 {
3 }
4
5 void oneline1(void) { }
6
7 void oneline2(void) { return; }
8
9 void twoline1(void) {
10 }
11
12 void twoline2(void) {
13 return; }
14
15 void threeline1 (void)
16 {
17 }
18
19 void fourline (void)
20 {
21 return;
22 }
23
24 void last (void)
25 {
26 }

Here is the .gdbinit file I used:

br first
br oneline1
br oneline2
br twoline1
br twoline2
br threeline1
br fourline
br last

First try the old gdb prior to the change: Notice that every
breakpoint gets set at the function AFTER the one it was supposed to
be set at:

$ ./gdb-old -nw -nx -x x.gdb x
GNU gdb 6.4
Copyright 2005 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 "--host=i686-pc-linux-gnu --target=sb1-elf"...
Breakpoint 1 at 0xa0020330: file x1.c, line 5.
Breakpoint 2 at 0xa0020338: file x1.c, line 7.
Breakpoint 3 at 0xa0020340: file x1.c, line 10.
Breakpoint 4 at 0xa0020348: file x1.c, line 13.
Breakpoint 5 at 0xa0020350: file x1.c, line 17.
Breakpoint 6 at 0xa0020358: file x1.c, line 22.
Breakpoint 7 at 0xa0020360: file x1.c, line 26.
Breakpoint 8 at 0xa0020368
(gdb) quit

BTW, for the above, breakpoint 8 actually gets set at the function followoing last():

(gdb) x/i 0xa0020368
0xa0020368 <__do_global_ctors_aux>: lui v0,0xa002

Now after the change. They are all correct, I believe, although the breakpoint
for fourline would probably look better from a source perspective if it said
line 21 instead of line 22.

$ ./gdb-new -nw -nx -x x.gdb x
GNU gdb 6.4
Copyright 2005 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 "--host=i686-pc-linux-gnu --target=sb1-elf"...
Breakpoint 1 at 0xa0020328: file x1.c, line 3.
Breakpoint 2 at 0xa0020330: file x1.c, line 5.
Breakpoint 3 at 0xa0020338: file x1.c, line 7.
Breakpoint 4 at 0xa0020340: file x1.c, line 10.
Breakpoint 5 at 0xa0020348: file x1.c, line 13.
Breakpoint 6 at 0xa0020350: file x1.c, line 17.
Breakpoint 7 at 0xa0020358: file x1.c, line 22.
Breakpoint 8 at 0xa0020360: file x1.c, line 26.
(gdb)

For reference, here is a disassembly:

(gdb) x/30i 0xa0020328
0xa0020328 <first>: jr ra
0xa002032c <first+4>: nop
0xa0020330 <oneline1>: jr ra
0xa0020334 <oneline1+4>: nop
0xa0020338 <oneline2>: jr ra
0xa002033c <oneline2+4>: nop
0xa0020340 <twoline1>: jr ra
0xa0020344 <twoline1+4>: nop
0xa0020348 <twoline2>: jr ra
0xa002034c <twoline2+4>: nop
0xa0020350 <threeline1>: jr ra
0xa0020354 <threeline1+4>: nop
0xa0020358 <fourline>: jr ra
0xa002035c <fourline+4>: nop
0xa0020360 <last>: jr ra
0xa0020364 <last+4>: nop
0xa0020368 <__do_global_ctors_aux>: lui v0,0xa002

-Fred