From patchwork Wed Aug 19 07:11:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Buettner X-Patchwork-Id: 8289 Received: (qmail 81820 invoked by alias); 19 Aug 2015 07:11:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 81811 invoked by uid 89); 19 Aug 2015 07:11:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 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; Wed, 19 Aug 2015 07:11:35 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id A36A13679F0 for ; Wed, 19 Aug 2015 07:11:34 +0000 (UTC) Received: from pinnacle.lan ([10.3.113.17]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7J7BXQ0003502 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO) for ; Wed, 19 Aug 2015 03:11:34 -0400 Date: Wed, 19 Aug 2015 00:11:32 -0700 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: [PATCH 6/8] Implement unconditional_branch_address method for powerpc / rs6000 Message-ID: <20150819001132.2ed35d1d@pinnacle.lan> In-Reply-To: <20150818235334.1afb0c85@pinnacle.lan> References: <20150818235334.1afb0c85@pinnacle.lan> MIME-Version: 1.0 X-IsSubscribed: yes Implement unconditional_branch_address method for powerpc / rs6000. gdb/ChangeLog: * rs6000-tdep.c (rs6000_unconditional_branch_address): New function. (rs6000_gdbarch_init): Register rs6000_unconditional_branch_address. --- gdb/rs6000-tdep.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 785f451..f1c33e0 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -3578,6 +3578,20 @@ ppc_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum, reg->how = DWARF2_FRAME_REG_CFA; } +/* Implement the unconditional_branch_address gdbarch method. */ + +static CORE_ADDR +rs6000_unconditional_branch_address (struct gdbarch *gdbarch, CORE_ADDR pc) +{ + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + unsigned long insn = read_memory_unsigned_integer (pc, 4, byte_order); + + if ((insn & 0xfc000003) == 0x48000000) /* b instruction. */ + return pc + (((insn & 0x02000000) ? ~((CORE_ADDR) 0x03fffffc) : 0) + | (insn & 0x03fffffc)); + else + return 0; +} /* Return true if a .gnu_attributes section exists in BFD and it indicates we are using SPE extensions OR if a .PPC.EMB.apuinfo @@ -6051,6 +6065,10 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) else register_ppc_ravenscar_ops (gdbarch); + /* Unconditional Branch. */ + set_gdbarch_unconditional_branch_address + (gdbarch, rs6000_unconditional_branch_address); + return gdbarch; }