From patchwork Wed Aug 19 07:15:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Buettner X-Patchwork-Id: 8291 Received: (qmail 86157 invoked by alias); 19 Aug 2015 07:15:57 -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 86144 invoked by uid 89); 19 Aug 2015 07:15:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 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:15:56 +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 451368E508 for ; Wed, 19 Aug 2015 07:15:55 +0000 (UTC) Received: from pinnacle.lan ([10.3.113.17]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7J7FsXX004206 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO) for ; Wed, 19 Aug 2015 03:15:55 -0400 Date: Wed, 19 Aug 2015 00:15:52 -0700 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: [PATCH 8/8] Implement unconditional_branch_address method for rx Message-ID: <20150819001552.72ad9ff6@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 rx. gdb/ChangeLog: * rx-tdep.c (rx_unconditional_branch_address): New function. (rx_gdbarch_init): Register rx_unconditional_branch_address. --- gdb/rx-tdep.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c index 0bd91ff..f7ba2fb 100644 --- a/gdb/rx-tdep.c +++ b/gdb/rx-tdep.c @@ -1015,6 +1015,38 @@ rx_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg) reg); } +/* Implement the unconditional_branch_address gdbarch method. */ + +static CORE_ADDR +rx_unconditional_branch_address (struct gdbarch *gdbarch, CORE_ADDR pc) +{ + int bytes_read; + RX_Opcode_Decoded opc; + struct rx_get_opcode_byte_handle opcode_handle; + + opcode_handle.pc = pc; + + bytes_read = rx_decode_opcode (pc, &opc, rx_get_opcode_byte, + &opcode_handle); + + if (bytes_read > 0 + && (opc.id == RXO_branch || opc.id == RXO_branchrel) + && (opc.op[1].type == RX_Operand_None + || (opc.op[1].type == RX_Operand_Condition + && opc.op[1].reg == RXC_always)) + && opc.op[0].type == RX_Operand_Immediate) + { + LONGEST l = opc.op[0].addend; + + if (opc.id == RXO_branch) + return (CORE_ADDR) l; + else + return pc + l; + } + + return 0; +} + /* Allocate and initialize a gdbarch object. */ static struct gdbarch * rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) @@ -1146,6 +1178,10 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Virtual tables. */ set_gdbarch_vbit_in_delta (gdbarch, 1); + /* Unconditional Branch. */ + set_gdbarch_unconditional_branch_address (gdbarch, + rx_unconditional_branch_address); + return gdbarch; }