diff options
author | Meador Inge <meadori@sourceware.org> | 2011-11-09 00:53:40 +0000 |
---|---|---|
committer | Meador Inge <meadori@sourceware.org> | 2011-11-09 00:53:40 +0000 |
commit | 72a2e3dcf5c4dceb8e548d738b5373468d05655b (patch) | |
tree | d448b68f853b7b18de2815749705879fee3e3b88 | |
parent | 6a12077df4f990359fe9dd97c419b05a169d7503 (diff) | |
download | gdb-72a2e3dcf5c4dceb8e548d738b5373468d05655b.zip gdb-72a2e3dcf5c4dceb8e548d738b5373468d05655b.tar.gz gdb-72a2e3dcf5c4dceb8e548d738b5373468d05655b.tar.bz2 |
gdb/
* arm-tdep.c (thumb_analyze_prologue): Always fallback on the SP
register when the frame can't be determined.
* arm-tdep.c (arm_analyze_prologue): Ditto.
gdb/testsuite/
* gdb.arch/thumb-prologue.c (switch_stack_to_same): New test function.
(switch_stack_to_other): New test function.
* gdb.arch/thumb-prologue.exp: New test cases.
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/arm-tdep.c | 16 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/thumb-prologue.c | 34 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/thumb-prologue.exp | 27 |
5 files changed, 75 insertions, 14 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index be41aa0..e003f39 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2011-11-08 Meador Inge <meadori@codesourcery.com> + + * arm-tdep.c (thumb_analyze_prologue): Always fallback on the SP + register when the frame can't be determined. + * arm-tdep.c (arm_analyze_prologue): Ditto. + 2011-11-07 Stan Shebs <stan@codesourcery.com> * MAINTAINERS: Move Michael Snyder to Past Maintainers. diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 3337248..4cd11d4 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -1152,18 +1152,12 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, cache->framereg = THUMB_FP_REGNUM; cache->framesize = -regs[THUMB_FP_REGNUM].k; } - else if (pv_is_register (regs[ARM_SP_REGNUM], ARM_SP_REGNUM)) + else { /* Try the stack pointer... this is a bit desperate. */ cache->framereg = ARM_SP_REGNUM; cache->framesize = -regs[ARM_SP_REGNUM].k; } - else - { - /* We're just out of luck. We don't know where the frame is. */ - cache->framereg = -1; - cache->framesize = 0; - } for (i = 0; i < 16; i++) if (pv_area_find_reg (stack, gdbarch, i, &offset)) @@ -1883,18 +1877,12 @@ arm_analyze_prologue (struct gdbarch *gdbarch, framereg = ARM_FP_REGNUM; framesize = -regs[ARM_FP_REGNUM].k; } - else if (pv_is_register (regs[ARM_SP_REGNUM], ARM_SP_REGNUM)) + else { /* Try the stack pointer... this is a bit desperate. */ framereg = ARM_SP_REGNUM; framesize = -regs[ARM_SP_REGNUM].k; } - else - { - /* We're just out of luck. We don't know where the frame is. */ - framereg = -1; - framesize = 0; - } if (cache) { diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 4625ffb..d4380fb 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-11-08 Meador Inge <meadori@codesourcery.com> + + * gdb.arch/thumb-prologue.c (switch_stack_to_same): New test function. + (switch_stack_to_other): New test function. + * gdb.arch/thumb-prologue.exp: New test cases. + 2010-11-08 Maciej W. Rozycki <macro@codesourcery.com> * lib/mi-support.exp (mi_send_resuming_command_raw): Fix a typo. diff --git a/gdb/testsuite/gdb.arch/thumb-prologue.c b/gdb/testsuite/gdb.arch/thumb-prologue.c index bb24df0..a726149 100644 --- a/gdb/testsuite/gdb.arch/thumb-prologue.c +++ b/gdb/testsuite/gdb.arch/thumb-prologue.c @@ -18,11 +18,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ void tpcs_frame (void); +void switch_stack_to_same (void); +void switch_stack_to_other (void); int main (void) { tpcs_frame (); + switch_stack_to_same (); + switch_stack_to_other (); return 0; } @@ -104,3 +108,33 @@ asm(".text\n" " mov lr, r3\n" " bx lr\n" ); + +asm(".text\n" + " .align 2\n" + " .thumb_func\n" + " .code 16\n" + "write_sp:\n" + " mov sp, r0\n" + " bx lr\n" + + " .align 2\n" + " .thumb_func\n" + " .code 16\n" + "switch_stack_to_same:\n" + " push {lr}\n" + " mov r0, sp\n" + " bl write_sp\n" + " pop {r1}\n" + " bx r1\n" + + " .align 2\n" + " .thumb_func\n" + " .code 16\n" + "switch_stack_to_other:\n" + " push {lr}\n" + " mov r7, sp\n" + " mov r0, #128\n" + " bl write_sp\n" + " mov sp, r7\n" + " pop {r1}\n" + " bx r1\n"); diff --git a/gdb/testsuite/gdb.arch/thumb-prologue.exp b/gdb/testsuite/gdb.arch/thumb-prologue.exp index e685bc5..39b61c4 100644 --- a/gdb/testsuite/gdb.arch/thumb-prologue.exp +++ b/gdb/testsuite/gdb.arch/thumb-prologue.exp @@ -59,3 +59,30 @@ gdb_test "backtrace 10" \ gdb_test "info frame" \ ".*Saved registers:.*r7 at.*r10 at.*r11 at.*lr at.*" \ "saved registers in TPCS" + + +# Testcase for "switching" the stack to the same stack in the prologue. + +gdb_breakpoint "switch_stack_to_same" + +gdb_test "continue" "Breakpoint .*, $hex in switch_stack_to_same \\(\\)" \ + "continue to switch_stack_to_same" + +gdb_test "stepi 2" "in write_sp \\(\\)" "stepi over mov sp, sp" + +gdb_test "backtrace 10" \ + "#0\[ \t\]*$hex in write_sp .*\r\n#1\[ \t\]*$hex in switch_stack_to_same .*\r\n#2\[ \t\]*$hex in main.*" \ + "backtrace in write_sp" + +# Testcase for switching to another stack in the prologue. + +gdb_breakpoint "switch_stack_to_other" + +gdb_test "continue" "Breakpoint .*, $hex in switch_stack_to_other \\(\\)" \ + "continue to switch_stack_to_other" + +gdb_test "stepi 2" "in write_sp \\(\\)" "stepi over mov sp, 128" + +gdb_test "backtrace 10" \ + "#0\[ \t\]*$hex in write_sp .*\r\n#1\[ \t\]*$hex in switch_stack_to_other .*\r\n#2\[ \t\]*$hex in main.*" \ + "backtrace in write_sp" |