From eec4126c312ab709df64df48fa6db99339e9ea54 Mon Sep 17 00:00:00 2001 From: kevinb Date: Sat, 26 Feb 2000 09:30:30 +0000 Subject: [PATCH] Changes to skip_prologue for PPC architecture. --- gdb/ChangeLog | 13 +++++++++++++ gdb/rs6000-tdep.c | 38 +++++++++++++++++++++++++++----------- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b3b3c265d4..36dc637b17 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +2000-02-26 Kevin Buettner + + * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Add + comment explaining motivation behind this function and why + the generic facilities won't work for this platform. + * rs6000-tdep.c (skip_prologue): Always test to make sure + that an instruction is read successfully from the target's + memory. Introduce notion of instructions which may appear in + the prologue, but may not end the prologue. Added explicit + check for nop instruction. Use memset() to zero the frame + data instead of assignment from a statically allocated, + uninitialized structure. + Sat Feb 26 17:15:16 2000 Andrew Cagney * MAINTAINERS: Chris Faylor is responsible for all MS Windows diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index ca094c74cf..c3cd31b75e 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -305,11 +305,10 @@ rs6000_software_single_step (signal, insert_breakpoints_p) #define GET_SRC_REG(x) (((x) >> 21) & 0x1f) CORE_ADDR -skip_prologue (pc, fdata) - CORE_ADDR pc; - struct rs6000_framedata *fdata; +skip_prologue (CORE_ADDR pc, struct rs6000_framedata *fdata) { CORE_ADDR orig_pc = pc; + CORE_ADDR last_prologue_pc; char buf[4]; unsigned long op; long offset = 0; @@ -318,24 +317,31 @@ skip_prologue (pc, fdata) int reg; int framep = 0; int minimal_toc_loaded = 0; - static struct rs6000_framedata zero_frame; + int prev_insn_was_prologue_insn = 1; - *fdata = zero_frame; + memset (fdata, 0, sizeof (struct rs6000_framedata)); fdata->saved_gpr = -1; fdata->saved_fpr = -1; fdata->alloca_reg = -1; fdata->frameless = 1; fdata->nosavedpc = 1; - if (target_read_memory (pc, buf, 4)) - return pc; /* Can't access it -- assume no prologue. */ - - /* Assume that subsequent fetches can fail with low probability. */ pc -= 4; for (;;) { pc += 4; - op = read_memory_integer (pc, 4); + + /* Sometimes it isn't clear if an instruction is a prologue + instruction or not. When we encounter one of these ambiguous + cases, we'll set prev_insn_was_prologue_insn to 0 (false). + Otherwise, we'll assume that it really is a prologue instruction. */ + if (prev_insn_was_prologue_insn) + last_prologue_pc = pc; + prev_insn_was_prologue_insn = 1; + + if (target_read_memory (pc, buf, 4)) + break; + op = extract_signed_integer (buf, 4); if ((op & 0xfc1fffff) == 0x7c0802a6) { /* mflr Rx */ @@ -375,6 +381,16 @@ skip_prologue (pc, fdata) continue; } + else if ((op & 0xffff0000) == 0x60000000) + { + /* nop */ + /* Allow nops in the prologue, but do not consider them to + be part of the prologue unless followed by other prologue + instructions. */ + prev_insn_was_prologue_insn = 0; + continue; + + } else if ((op & 0xffff0000) == 0x3c000000) { /* addis 0,0,NUM, used for >= 32k frames */ @@ -564,7 +580,7 @@ skip_prologue (pc, fdata) #endif /* 0 */ fdata->offset = -fdata->offset; - return pc; + return last_prologue_pc; } -- 2.11.0