Re: Improve end check on rs6000 prologue analyzer

Andreas Schwab
2007-04-16T16:03:07Z

Daniel Jacobowitz <drow@false.org> writes:

> 2007-03-09 Daniel Jacobowitz <dan@codesourcery.com>
>
> * rs6000-tdep.c (rs6000_skip_prologue): Use skip_prologue_using_sal.

This is causing a regression when the function is very small.

$ cat prologue.c
int foo ()
{
return 0;
}

int main (void)
{
return foo ();
}
$ gcc -O2 -g prologue.c
$ gdb a.out
GNU gdb 6.6.50.20070416-cvs
Copyright (C) 2007 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 "powerpc-suse-linux"...
Using host libthread_db library "/lib/power4/libthread_db.so.1".
(gdb) b foo
Breakpoint 1 at 0x10000490: file prologue.c, line 8.
(gdb) i b
Num Type Disp Enb Address What
1 breakpoint keep y 0x10000490 in main at prologue.c:8
(gdb)

Note that the breakpoint is actually in main, not in foo. The problem is
that skip_prologue_using_sal does not properly handle a function with only
one sal if the pc of the next line is bigger than the end pc of the
current function.

Andreas.

2007-04-16 Andreas Schwab <schwab@suse.de>

* symtab.c (skip_prologue_using_sal): Allow the end of the prologue
sal to be bigger than the end of the function.

--- gdb/symtab.c.~1.156.~ 2007-03-28 12:57:45.000000000 +0200
+++ gdb/symtab.c 2007-04-16 17:39:04.000000000 +0200
@@ -4111,7 +4111,7 @@ skip_prologue_using_sal (CORE_ADDR func_
/* If there is only one sal that covers the entire function,
then it is probably a single line function, like
"foo(){}". */
- if (prologue_sal.end == end_pc)
+ if (prologue_sal.end >= end_pc)
return 0;
while (prologue_sal.end < end_pc)
{

--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, MaxfeldstraÃŸe 5, 90409 NÃ¼rnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."