From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2665 invoked by alias); 28 Sep 2010 16:32:32 -0000 Received: (qmail 2655 invoked by uid 22791); 28 Sep 2010 16:32:30 -0000 X-SWARE-Spam-Status: No, hits=-2.1 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; Tue, 28 Sep 2010 16:32:21 +0000 Received: (qmail 18689 invoked from network); 28 Sep 2010 16:32:20 -0000 Received: from unknown (HELO caradoc.them.org) (dan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 28 Sep 2010 16:32:20 -0000 Date: Tue, 28 Sep 2010 21:49:00 -0000 From: Daniel Jacobowitz To: Ulrich Weigand Cc: gdb-patches@sourceware.org, rearnsha@arm.com Subject: Re: [rfa] Fix software-watchpoint failures by adding epilogue detection Message-ID: <20100928163216.GH6886@caradoc.them.org> 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.20 (2009-06-14) 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/msg00476.txt.bz2 On Tue, Sep 28, 2010 at 06:04:14PM +0200, Ulrich Weigand wrote: > 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? Bah, you are correct. Poor choice of example. bx ip is a better example; that can be an indirect call, a return, or a tail 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". Sorry, I don't know :-( Does GCC also only use lr for an indirect tail call? I can't tell - I couldn't get GCC to issue an indirect tail call. But I did get this out of RealView: void (*foo)(); void bar() { foo(); } bar PROC LDR r0,|L1.12| LDR r0,[r0,#0] ; foo BX r0 ENDP > 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 ...) Yes, that sounds like the case I was worried about. Of course, it's relatively harmless either way; nothing in GDB absolutely relies on this hook. So I won't object to the patch as-is. This would be a nice thing to clean up some day. -- Daniel Jacobowitz CodeSourcery