From patchwork Mon Jul 7 01:37:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 1926 Received: (qmail 20786 invoked by alias); 7 Jul 2014 01:38:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 20762 invoked by uid 89); 7 Jul 2014 01:38:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Jul 2014 01:38:43 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1X3xt9-0001bn-Fq from Yao_Qi@mentor.com ; Sun, 06 Jul 2014 18:38:39 -0700 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 6 Jul 2014 18:38:39 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.2.247.3; Sun, 6 Jul 2014 18:38:26 -0700 Message-ID: <53B9F9C2.70601@codesourcery.com> Date: Mon, 7 Jul 2014 09:37:06 +0800 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Will Newton CC: "gdb-patches@sourceware.org" Subject: Re: [PATCH 1/4] Restrict matching add/sub sp, #imm References: <1404367792-23234-1-git-send-email-yao@codesourcery.com> <1404367792-23234-2-git-send-email-yao@codesourcery.com> In-Reply-To: X-IsSubscribed: yes On 07/03/2014 04:31 PM, Will Newton wrote: > One too many ms? > Oh, sorry. >> > (thumb_in_function_epilogue_p): Don't match 'sub sp, #imm'. >> > --- >> > gdb/arm-tdep.c | 15 +++++---------- >> > 1 file changed, 5 insertions(+), 10 deletions(-) >> > >> > diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c >> > index 8cc60a4..0fc7fc1 100644 >> > --- a/gdb/arm-tdep.c >> > +++ b/gdb/arm-tdep.c >> > @@ -737,16 +737,11 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, >> > pv_area_store (stack, regs[ARM_SP_REGNUM], 4, regs[regno]); >> > } >> > } >> > - else if ((insn & 0xff00) == 0xb000) /* add sp, #simm OR >> > - sub sp, #simm */ >> > + else if ((insn & 0xff80) == 0xb080) /* sub sp, #simm */ > I wonder if we should adjust the comment to just #imm, as #simm > implies it is a signed quantity. > Fixed. diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 8cc60a4..6b1cf3c 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -737,16 +737,11 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, pv_area_store (stack, regs[ARM_SP_REGNUM], 4, regs[regno]); } } - else if ((insn & 0xff00) == 0xb000) /* add sp, #simm OR - sub sp, #simm */ + else if ((insn & 0xff80) == 0xb080) /* sub sp, #imm */ { offset = (insn & 0x7f) << 2; /* get scaled offset */ - if (insn & 0x80) /* Check for SUB. */ - regs[ARM_SP_REGNUM] = pv_add_constant (regs[ARM_SP_REGNUM], - -offset); - else - regs[ARM_SP_REGNUM] = pv_add_constant (regs[ARM_SP_REGNUM], - offset); + regs[ARM_SP_REGNUM] = pv_add_constant (regs[ARM_SP_REGNUM], + -offset); } else if ((insn & 0xf800) == 0xa800) /* add Rd, sp, #imm */ regs[bits (insn, 8, 10)] = pv_add_constant (regs[ARM_SP_REGNUM], @@ -3264,7 +3259,7 @@ thumb_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc) found_return = 1; else if (insn == 0x46bd) /* mov sp, r7 */ found_stack_adjust = 1; - else if ((insn & 0xff00) == 0xb000) /* add sp, imm or sub sp, imm */ + else if ((insn & 0xff80) == 0xb000) /* add sp, imm */ found_stack_adjust = 1; else if ((insn & 0xfe00) == 0xbc00) /* pop */ { @@ -3324,7 +3319,7 @@ thumb_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc) if (insn2 == 0x46bd) /* mov sp, r7 */ found_stack_adjust = 1; - else if ((insn2 & 0xff00) == 0xb000) /* add sp, imm or sub sp, imm */ + else if ((insn2 & 0xff80) == 0xb000) /* add sp, imm */ found_stack_adjust = 1; else if ((insn2 & 0xff00) == 0xbc00) /* pop without PC */ found_stack_adjust = 1;