summaryrefslogtreecommitdiff
path: root/gdb/rs6000-tdep.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2011-01-18 16:18:21 +0000
committerJoel Brobecker <brobecker@gnat.com>2011-01-18 16:18:21 +0000
commit42294ab40a733dbca9258929d0a6ec72e3059fbc (patch)
treecd83a8da47e5db35f97491170293d1307c6a4620 /gdb/rs6000-tdep.c
parent797407ac8fed56f60655bce2083f199296e1f5f4 (diff)
downloadgdb-42294ab40a733dbca9258929d0a6ec72e3059fbc.tar.gz
[powerpc] breakpoint inserted past function end
On powerpc, the prologue scanner reads instruction after instruction, and just skips instructions that do not affect a frame. This means that it does not stop if if finds and unexpected instruction (which could possibly happen with optimization, I presume). To avoid scanning too many instructions, it tries to establish an upper limit. The upper limit is first computed using the debugging (line) info, but if that fails, it falls back on an arbitrary 100 bytes (or 25 instructions). The problem is that, if the function is shorter than those 25 instructions, we run the risk of skipping the entire function and returning a PC that's outside our function. In the event where we can find a symbol for a given PC (and therefore can determine function start and end addresses), but cannot find an upper limit using skip_prologue_using_sal, then we can at least limit make sure that the 25 instructions do not put us beyour our function. If it does, then further reduce the upper-limit to the end of the function. gdb/ChangeLog: * rs6000-tdep.c (rs6000_skip_prologue): Make sure that the prologue upper limit address is not greater than the function end address when the upper limit could not be computed using the debugging info.
Diffstat (limited to 'gdb/rs6000-tdep.c')
-rw-r--r--gdb/rs6000-tdep.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index c16e9334187..9832b5bb3fd 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -2090,12 +2090,12 @@ static CORE_ADDR
rs6000_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
{
struct rs6000_framedata frame;
- CORE_ADDR limit_pc, func_addr;
+ CORE_ADDR limit_pc, func_addr, func_end_addr = 0;
/* See if we can determine the end of the prologue via the symbol table.
If so, then return either PC, or the PC after the prologue, whichever
is greater. */
- if (find_pc_partial_function (pc, NULL, &func_addr, NULL))
+ if (find_pc_partial_function (pc, NULL, &func_addr, &func_end_addr))
{
CORE_ADDR post_prologue_pc
= skip_prologue_using_sal (gdbarch, func_addr);
@@ -2113,6 +2113,11 @@ rs6000_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
if (limit_pc == 0)
limit_pc = pc + 100; /* Magic. */
+ /* Do not allow limit_pc to be past the function end, if we know
+ where that end is... */
+ if (func_end_addr && limit_pc > func_end_addr)
+ limit_pc = func_end_addr;
+
pc = skip_prologue (gdbarch, pc, limit_pc, &frame);
return pc;
}