From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2572 invoked by alias); 19 Jul 2011 18:44:39 -0000 Received: (qmail 2563 invoked by uid 22791); 19 Jul 2011 18:44:39 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,FROM_12LTRDOM,SPF_FAIL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 19 Jul 2011 18:43:56 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1QjFGt-0004Q7-QT from meadori@codesourcery.com for gdb-patches@sourceware.org; Tue, 19 Jul 2011 11:43:55 -0700 Received: from na2-mail.mgc.mentorg.com ([134.86.114.213]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 19 Jul 2011 11:41:46 -0700 Received: from localhost.localdomain ([134.86.101.110]) by na2-mail.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 19 Jul 2011 12:43:54 -0600 From: Meador Inge To: gdb-patches@sourceware.org Subject: [PATCH 1/1] ARM: Change prologue analyzer to always fallback on SP. Date: Tue, 19 Jul 2011 19:11:00 -0000 Message-Id: <1311101033-7648-2-git-send-email-meadori@codesourcery.com> In-Reply-To: <1311101033-7648-1-git-send-email-meadori@codesourcery.com> References: <1311101033-7648-1-git-send-email-meadori@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-07/txt/msg00491.txt.bz2 2011-07-19 Meador Inge * 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-07-19 Meador Inge * 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. Signed-off-by: Meador Inge --- gdb/arm-tdep.c | 16 +------------ gdb/testsuite/gdb.arch/thumb-prologue.c | 34 +++++++++++++++++++++++++++++ gdb/testsuite/gdb.arch/thumb-prologue.exp | 27 +++++++++++++++++++++++ 3 files changed, 63 insertions(+), 14 deletions(-) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 1a75af1..9aeec48 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -1150,18 +1150,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)) @@ -1881,18 +1875,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/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 . */ 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" -- 1.7.0.4