From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31628 invoked by alias); 29 Sep 2010 02:44:11 -0000 Received: (qmail 31554 invoked by uid 22791); 29 Sep 2010 02:44:09 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 29 Sep 2010 02:44:04 +0000 Received: (qmail 9998 invoked from network); 29 Sep 2010 02:44:03 -0000 Received: from unknown (HELO codesourcery.com) (yao@127.0.0.2) by mail.codesourcery.com with ESMTPA; 29 Sep 2010 02:44:03 -0000 Date: Wed, 29 Sep 2010 14:43:00 -0000 From: Yao Qi To: gdb-patches@sourceware.org Subject: Re: [rfa] Fix software-watchpoint failures by adding epilogue detection Message-ID: <20100929024358.GA598@codesourcery.com> References: <20100928151529.GG6886@caradoc.them.org> <201009281604.o8SG4Eng031035@d12av02.megacenter.de.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201009281604.o8SG4Eng031035@d12av02.megacenter.de.ibm.com> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) 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: 2010-09/txt/msg00483.txt.bz2 On Tue, Sep 28, 2010 at 06:04:14PM +0200, Ulrich Weigand wrote: > 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". > I haven't seen any examples GCC uses bx with other registers so far, but I noticed that some one is thinking of use 'bx r3' for optimization purpose. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40887 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19599 The patch for PR19599 hasn't been committed yet, so I still can't find a real example that using 'bx r3' to return. In short, there *might* be some cases now or in the future, that registers other than lr are used with bx for return. -- Yao Qi CodeSourcery yao@codesourcery.com (650) 331-3385 x739