diff options
author | Sandra Loosemore <sandra@codesourcery.com> | 2014-11-25 18:40:28 -0800 |
---|---|---|
committer | Sandra Loosemore <sandra@codesourcery.com> | 2014-11-25 18:40:28 -0800 |
commit | aa4893954a75660d2aa66245cb9d020049cb9546 (patch) | |
tree | d396726f249452f1a3ad1d738c4bcc68e5ec04c2 | |
parent | 7f1659b5875387986901ee9bccd5247bf6899afc (diff) | |
download | gdb-aa4893954a75660d2aa66245cb9d020049cb9546.zip gdb-aa4893954a75660d2aa66245cb9d020049cb9546.tar.gz gdb-aa4893954a75660d2aa66245cb9d020049cb9546.tar.bz2 |
Fix Nios II prologue analyzer to handle multiple stack adjustments.
2014-11-25 Sandra Loosemore <sandra@codesourcery.com>
gdb/
* nios2-tdep.c (nios2_analyze_prologue): Replace restriction
that there can be only one stack adjustment in the prologue
with tests to detect specific disallowed stack adjustments.
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/nios2-tdep.c | 33 |
2 files changed, 31 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d7f7563..de98b3c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2014-11-25 Sandra Loosemore <sandra@codesourcery.com> + * nios2-tdep.c (nios2_analyze_prologue): Replace restriction + that there can be only one stack adjustment in the prologue + with tests to detect specific disallowed stack adjustments. + +2014-11-25 Sandra Loosemore <sandra@codesourcery.com> + * nios2-tdep.c (nios2_in_epilogue_p): Handle multiple stack adjustments. diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c index 2758012..13aa407 100644 --- a/gdb/nios2-tdep.c +++ b/gdb/nios2-tdep.c @@ -842,6 +842,11 @@ nios2_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR start_pc, cache->reg_saved[NIOS2_SP_REGNUM].addr = -4; } + else if (rc == NIOS2_SP_REGNUM && ra == NIOS2_FP_REGNUM) + /* This is setting SP from FP. This only happens in the + function epilogue. */ + break; + else if (rc != 0) { if (value[rb].reg == 0) @@ -853,13 +858,21 @@ nios2_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR start_pc, value[rc].offset = value[ra].offset + value[rb].offset; } - prologue_end = pc; + /* The add/move is only considered a prologue instruction + if the destination is SP or FP. */ + if (rc == NIOS2_SP_REGNUM || rc == NIOS2_FP_REGNUM) + prologue_end = pc; } else if (nios2_match_sub (insn, op, mach, &ra, &rb, &rc)) { /* SUB rc, ra, rb */ - if (rc != 0) + if (rc == NIOS2_SP_REGNUM && rb == NIOS2_SP_REGNUM + && value[rc].reg != 0) + /* If we are decrementing the SP by a non-constant amount, + this is alloca, not part of the prologue. */ + break; + else if (rc != 0) { if (value[rb].reg == 0) value[rc].reg = value[ra].reg; @@ -873,12 +886,13 @@ nios2_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR start_pc, { /* ADDI rb, ra, imm */ - /* The first stack adjustment is part of the prologue. - Any subsequent stack adjustments are either down to - alloca or the epilogue so stop analysing when we hit - them. */ + /* A positive stack adjustment has to be part of the epilogue. */ if (rb == NIOS2_SP_REGNUM - && (value[rb].offset != 0 || value[ra].reg != NIOS2_SP_REGNUM)) + && (imm > 0 || value[ra].reg != NIOS2_SP_REGNUM)) + break; + + /* Likewise restoring SP from FP. */ + else if (rb == NIOS2_SP_REGNUM && ra == NIOS2_FP_REGNUM) break; if (rb != 0) @@ -887,7 +901,10 @@ nios2_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR start_pc, value[rb].offset = value[ra].offset + imm; } - prologue_end = pc; + /* The add is only considered a prologue instruction + if the destination is SP or FP. */ + if (rb == NIOS2_SP_REGNUM || rb == NIOS2_FP_REGNUM) + prologue_end = pc; } else if (nios2_match_orhi (insn, op, mach, &ra, &rb, &uimm)) |