From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22019 invoked by alias); 27 Aug 2014 00:48:08 -0000 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 Received: (qmail 21996 invoked by uid 89); 27 Aug 2014 00:48:06 -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; Wed, 27 Aug 2014 00:48:05 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1XMRP7-0000SZ-W5 from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Tue, 26 Aug 2014 17:48:02 -0700 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 26 Aug 2014 17:48:01 -0700 Received: from GreenOnly (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.2.247.3; Tue, 26 Aug 2014 17:48:01 -0700 From: Yao Qi To: Subject: Re: [PATCH] arm software watchpoint: return to epilogue References: <1407295090-17296-1-git-send-email-yao@codesourcery.com> Date: Wed, 27 Aug 2014 00:48:00 -0000 In-Reply-To: <1407295090-17296-1-git-send-email-yao@codesourcery.com> (Yao Qi's message of "Wed, 6 Aug 2014 11:18:10 +0800") Message-ID: <87ioleiwxb.fsf@codesourcery.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2014-08/txt/msg00538.txt.bz2 Yao Qi writes: > This patch is to handle a software watchpoint case that program returns > to caller's epilogue, and it causes the fail in thumb mode, > > finish^M > Run till exit from #0 func () at gdb/testsuite/gdb.base/watchpoint-cond-= gone.c:26^M > 0x000001f6 in jumper ()^M > (gdb) FAIL: gdb.base/watchpoint-cond-gone.exp: Catch the no longer valid = watchpoint > > In the test, jumper calls func, and programs returns from func to > jumper's epilogue, IOW, the branch instruction is the last instruction > of jumper's function body. > > jumper: > ..... > 0x000001f2 <+10>: bl 0x200 [1] <---- indirect call to func > 0x000001f6 <+14>: mov sp, r7 [2] <---- start of the epilogue > 0x000001f8 <+16>: add sp, #8 > 0x000001fa <+18>: pop {r7} > 0x000001fc <+20>: pop {r0} > 0x000001fe <+22>: bx r0 > > When the inferior returns from func back to jumper, it is expected > that an expression of a software watchpoint becomes out-of-scope. > GDB validates the expression by checking the corresponding frame, > but this check is guarded by gdbarch_in_function_epilogue_p. See > breakpoint.c:watchpoint_check. > > It doesn't work in this case, because program returns from func's > epilogue back to jumper's epilogue [2], GDB thinks the program is > still within the epilogue, but in fact it goes to a different one. > When PC points at [2], the sp-restore instruction is to be > executed, so the stack frame isn't destroyed yet and we can still > use the frame mechanism reliably. > > Note that when PC points to the first instruction of restoring SP, > it is part of epilogue, but we still return zero. When goes to > the next instruction, the backward scan will still match the > epilogue sequence correctly. The reason for doing this is to > handle the "return-to-epilogue" case. > > What this patch does is to restrict the epilogue matching that let > GDB think the first SP restore instruction isn't part of the epilogue, > and fall back to use frame mechanism. We set 'found_stack_adjust' > zero before backward scan (although found_stack_adjust is initialized > to zero, it is safe to set it again before using it), and we've done > this for arm mode counterpart (arm_in_function_epilogue_p) too. > > The patch is tested in arm-none-eabi and arm-none-linux-gnueabi with > various multilibs. OK to apply? > > gdb: > > 2014-08-06 Yao Qi > > * arm-tdep.c (thumb_in_function_epilogue_p): Don't set > found_stack_adjust in forward scan. Set it zero before > backward scan. Remove condition check on > found_stack_adjust which is always true. Indent the code. Ping^2 https://sourceware.org/ml/gdb-patches/2014-08/msg00060.html --=20 Yao (=E9=BD=90=E5=B0=A7)