From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121255 invoked by alias); 22 Sep 2015 18:03:36 -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 121238 invoked by uid 89); 22 Sep 2015 18:03:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 22 Sep 2015 18:03:35 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 7DA55461D5 for ; Tue, 22 Sep 2015 18:03:34 +0000 (UTC) Received: from pinnacle.lan (ovpn-113-63.phx2.redhat.com [10.3.113.63]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8MI3X7g018468 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO) for ; Tue, 22 Sep 2015 14:03:34 -0400 Date: Tue, 22 Sep 2015 18:03:00 -0000 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: Re: [PATCH 2/8] Add new gdbarch method, unconditional_branch_address Message-ID: <20150922110328.5c7ba08e@pinnacle.lan> In-Reply-To: <861tdqbfma.fsf@gmail.com> References: <20150818235334.1afb0c85@pinnacle.lan> <20150819000002.06f6a2cf@pinnacle.lan> <861tdqbfma.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg00536.txt.bz2 On Tue, 22 Sep 2015 17:09:17 +0100 Yao Qi wrote: > Kevin Buettner writes: > > > Add new gdbarch method, unconditional_branch_address. > > > > gdb/ChangeLog: > > > > * gdbarch.sh (unconditional_branch_address): New gdbarch method. > > * gdbarch.h, gdbarch.c: Regenerate. > > * arch-utils.h (default_unconditional_branch_address): Declare. > > * arch-utils.c (default_unconditional_branch_address): New function. > > Did you consider using existing gdbarch method > adjust_breakpoint_address when you wrote the patch? Can we use > adjust_breakpoint_address here rather than adding a new gdbarch method? Hi Yao, The adjust_breakpoint_address method is not suitable for this patch set. It was originally added for the FR-V architecture. FR-V is a VLIW architecture which places limits on where a breakpoint may be placed within a bundle. For FR-V, this method ensures that a breakpoint is placed at the beginning of the VLIW bundle. I see now that it has also been used for MIPS to avoid placing breakpoints on branch delay slots and also for ARM to avoid placing breakpoints within IT (if-then) blocks. In each of these cases, the breakpoint is moved because, if is not, the breakpoint might not be hit. The gdbarch method that I'm introducing in this patch set needs to limit itself to checking to see if the instruction at a given address is an unconditional branch; if it is, it will return true and also provide the branch destination address via an output parameter. An existing gdbarch method that might be suitable (with some modification) for this purpose is insn_is_jump, which is presently used by the btrace code. The insn_is_jump method is a predicate only; at the moment, it does not provide the branch destination. It could be changed to do so, but I think it makes sense to limit use of the insn_is_{jump,ret,call} methods to btrace. This is the justification that I provided in another reply to this thread: I decided that the work I'm doing here should have it's own method. If GCC should someday emit DWARF which sets is_stmt to 0 for the branch instruction at the beginning of a while loop, this work might not be needed any longer. It'll be easier to rip it out and clean things up again if I don't modify gdbarch methods that were added for other purposes. Kevin