From patchwork Wed Oct 14 11:14:33 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: 9111 Received: (qmail 88957 invoked by alias); 14 Oct 2015 15:08:04 -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 88874 invoked by uid 89); 14 Oct 2015 15:08:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-0.3 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:08:00 +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 t9EBEZIV010717 for ; Wed, 14 Oct 2015 04:14:36 -0700 (PDT) Received: by arn-build2.wrs.com (Postfix, from userid 18580) id 087CB220DEC; Wed, 14 Oct 2015 13:14:34 +0200 (CEST) From: henrik.wallin@windriver.com To: gdb-patches@sourceware.org Subject: [RFC][PATCH 15/15] gdb/gdbserver: Enable tracepoint for ARM Date: Wed, 14 Oct 2015 13:14:33 +0200 Message-Id: <38e54395d60fc93b63f57e6098ba96ef1c90bb54.1444820235.git.henrik.wallin@windriver.com> In-Reply-To: References: In-Reply-To: References: From: Henrik Wallin This enables tracepoint for ARM. - Fast tracepoint. A fast tracepoint can be set in thumb and arm mode code. Validation is done for the instruction to relocate. Currently all PC-relative instructions are not possible to relocate. The inserted branch instruction needs to be 4 bytes, which also limit the possible instructions to relocate in thumb mode. It should be possible to rewrite some instructions, so more instructions are relocatable. - Breakpoint based tracepoint does not work This needs new infrastructure in gdbserver for setting breakpoints and to step over an instruction. The infrastructure to be able to do this is currently only available in gdb. There is no added error check for this. - jit compilation of tracepoint expressions is not implemented. gdb/ChangeLog: * arm-tdep.c (arm_gdbarch_init) : Install fast tracepoint callbacks. gdb/gdbserver/ChangeLog: * linux-arm-low.c (arm_get_thread_area) : New function. (arm_get_min_fast_tracepoint_insn_len) : New function. (arm_supports_tracepoints) : New function. (struct linux_target_ops) : Add fast tracepoint callbacks. Signed-off-by: Henrik Wallin --- gdb/arm-tdep.c | 5 +++++ gdb/gdbserver/linux-arm-low.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 74c58eb91c4d..1c34d1a4715b 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -11156,6 +11156,11 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) user_reg_add (gdbarch, arm_register_aliases[i].name, value_of_arm_user_reg, &arm_register_aliases[i].regnum); + set_gdbarch_fast_tracepoint_valid_at (gdbarch, + arm_fast_tracepoint_valid_at); + + set_gdbarch_relocate_instruction (gdbarch, arm_relocate_instruction); + return gdbarch; } diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c index 6bb069fe71bb..c3f85960bb28 100644 --- a/gdb/gdbserver/linux-arm-low.c +++ b/gdb/gdbserver/linux-arm-low.c @@ -918,6 +918,30 @@ arm_regs_info (void) } static int +arm_get_thread_area (int lwpid, CORE_ADDR *addr) +{ + uint32_t val; + + if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, &val) != 0) + return -1; + + *addr = val; + return 0; +} + +static int +arm_get_min_fast_tracepoint_insn_len(void) +{ + return 4; +} + +static int +arm_supports_tracepoints(void) +{ + return 1; +} + +static int is_target_arm (CORE_ADDR to, CORE_ADDR from) { CORE_ADDR ptr = to; @@ -1324,6 +1348,12 @@ struct linux_target_ops the_low_target = { arm_new_thread, arm_new_fork, arm_prepare_to_resume, + NULL, /* process_qsupported */ + arm_supports_tracepoints, /* supports_tracepoints */ + arm_get_thread_area, /* get_thread_area */ + arm_install_fast_tracepoint_jump_pad, /* install_fast_tracepoint_jump_pad */ + NULL, /* emit_ops */ + arm_get_min_fast_tracepoint_insn_len, /* get_min_fast_tracepoint_insn_len */ }; void