From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16180 invoked by alias); 28 Sep 2010 16:04:30 -0000 Received: (qmail 16172 invoked by uid 22791); 28 Sep 2010 16:04:29 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_SOFTFAIL,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mtagate4.de.ibm.com (HELO mtagate4.de.ibm.com) (195.212.17.164) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 28 Sep 2010 16:04:23 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate4.de.ibm.com (8.13.1/8.13.1) with ESMTP id o8SG4KS7017693 for ; Tue, 28 Sep 2010 16:04:20 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o8SG4Gm73977262 for ; Tue, 28 Sep 2010 18:04:20 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o8SG4FMF031053 for ; Tue, 28 Sep 2010 18:04:16 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id o8SG4Eng031035; Tue, 28 Sep 2010 18:04:14 +0200 Message-Id: <201009281604.o8SG4Eng031035@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Tue, 28 Sep 2010 18:04:14 +0200 Subject: Re: [rfa] Fix software-watchpoint failures by adding epilogue detection To: dan@codesourcery.com (Daniel Jacobowitz) Date: Tue, 28 Sep 2010 21:47:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org, rearnsha@arm.com In-Reply-To: <20100928151529.GG6886@caradoc.them.org> from "Daniel Jacobowitz" at Sep 28, 2010 11:15:30 AM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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: 2010-09/txt/msg00474.txt.bz2 Daniel Jacobowitz wrote: > On Fri, Sep 24, 2010 at 02:39:05PM +0200, Ulrich Weigand wrote: > > - I'm accepting more diverse sequences due to forward-scanning for multiple > > instructions, and not requiring backward-scanning. > > This I'm worried about. From my patch: > > + /* We are in the epilogue if the previous instruction was a stack > + adjustment and the next instruction is a possible return (bx, mov > + pc, or pop). > > This is definitely an epilogue: > > pop { r4, r5, r6, lr } > bx lr > > This could be an epilogue, but it could also be an indirect call: > > bx lr > > If it's an indirect call there would be a mov lr, pc before it. > If it's an indirect tail call, then it's an epilogue, and the return > address won't be saved. I'm wondering how "bx lr" could be an indirect call; for a call, lr would have to point to the return address, so it couldn't also contain the target address ... Am I missing something here? My original patch accepted only specifically "bx lr"; yours also accepts different registers for bx. If we have a bx with a different register, this may of course well be an indirect call. As far as I can see, GCC never uses bx with any other register but lr to implement a return instruction. Do you know whether this is also true for other compilers? If so, maybe the easiest fix would be to change this back to only accepting "bx lr". > If there's no stack adjustment, then gdbarch_in_function_epilogue_p > does not need to return 1; the predicate really means "we can not > check for watchpoints because the frame might be in an inconsistent > state". > > Is it safe for this predicate to return 1 around something that is not > an epilogue? > > Given that definition of the predicate, the backwards scan is > appropriate; without a backwards scan, we can only answer "is there an > epilogue after this point", not "are we already inside an epilogue". > > Of course, if it turns out harmless to return false positives... I'm > not sure. It seems to me that it is relatively harmless to return a false positive; the only thing that happens is that the check for watchpoint hits is delayed until the next instruction. In particular, returning true in the epilogue of a frameless functions should definitely be harmless. (Returning true on a bx that implements a function call might in rare cases lead to a watchpoint hit being detected on the first instruction of the called function instead ...) Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com