From patchwork Wed Oct 14 11:14:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: henrik.wallin@windriver.com X-Patchwork-Id: 9109 Received: (qmail 87352 invoked by alias); 14 Oct 2015 15:07:50 -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 87276 invoked by uid 89); 14 Oct 2015 15:07:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mail.windriver.com Received: from mail.windriver.com (HELO mail.windriver.com) (147.11.1.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 14 Oct 2015 15:07:45 +0000 Received: from arn-build2.wrs.com (arn-build2.wrs.com [128.224.95.15]) by mail.windriver.com (8.15.2/8.15.1) with ESMTP id t9EBEZYb010724 for ; Wed, 14 Oct 2015 04:14:35 -0700 (PDT) Received: by arn-build2.wrs.com (Postfix, from userid 18580) id F24A2220D58; Wed, 14 Oct 2015 13:14:33 +0200 (CEST) From: henrik.wallin@windriver.com To: gdb-patches@sourceware.org Subject: [RFC][PATCH 12/15] gdbserver: Add help functions to get arm/thumb mode Date: Wed, 14 Oct 2015 13:14:30 +0200 Message-Id: <32fca8843f5c9a19d4f829f089daf4dac6d2e620.1444820235.git.henrik.wallin@windriver.com> In-Reply-To: References: In-Reply-To: References: From: Henrik Wallin This adds new function. No users yet. This is a quick dirty way to ask gdb what the mode is. The relocate_instruction function is used with a bogus address. gdb side advances the to address if arm mode, otherwise not. gdb/ChangeLog: * arm-tdep.c (arm_relocate_instruction_func) : Add code to handle special case address value. gdb/gdbserver/ChangeLog: * linux-arm-low.c (is_target_arm) : New function. Signed-off-by: Henrik Wallin --- gdb/arm-tdep.c | 9 ++++++++- gdb/gdbserver/linux-arm-low.c | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 601d589b8a89..74c58eb91c4d 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -10447,7 +10447,14 @@ arm_relocate_instruction_func (struct relocate_insn *rel) rel->byte_order_for_code = gdbarch_byte_order_for_code (rel->gdbarch); rel->result = 0; - if (arm_pc_is_thumb (rel->gdbarch, rel->oldloc)) + if (rel->oldloc == 0xFFFFFFFF) + { + uint32_t tmp = read_memory_unsigned_integer (*(rel->to), 4, + rel->byte_order_for_code); + if (! arm_pc_is_thumb (rel->gdbarch, tmp)) + *rel->to += 1; + } + else if (arm_pc_is_thumb (rel->gdbarch, rel->oldloc)) { uint16_t insn1; uint16_t insn2; diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c index 044e7527a3b0..1853e79bc140 100644 --- a/gdb/gdbserver/linux-arm-low.c +++ b/gdb/gdbserver/linux-arm-low.c @@ -917,6 +917,15 @@ arm_regs_info (void) return ®s_info_arm; } +static int +is_target_arm (CORE_ADDR to, CORE_ADDR from) +{ + CORE_ADDR ptr = to; + write_inferior_memory (to, (unsigned char *) &from, 4); + relocate_instruction (&ptr, 0xFFFFFFFF); + return (to == ptr) ? 0 : 1; +} + static uint32_t mk_t_b_rel (CORE_ADDR from, CORE_ADDR to) {