From patchwork Mon Oct 5 16:44:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Tremblay X-Patchwork-Id: 8932 Received: (qmail 958 invoked by alias); 5 Oct 2015 16:44:58 -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 868 invoked by uid 89); 5 Oct 2015 16:44:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: usevmg21.ericsson.net Received: from usevmg21.ericsson.net (HELO usevmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 05 Oct 2015 16:44:56 +0000 Received: from EUSAAHC003.ericsson.se (Unknown_Domain [147.117.188.81]) by usevmg21.ericsson.net (Symantec Mail Security) with SMTP id 4F.E3.26730.A0D32165; Mon, 5 Oct 2015 11:04:11 +0200 (CEST) Received: from elxa4wqvvz1.dyn.mo.ca.am.ericsson.se (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.81) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 5 Oct 2015 12:44:33 -0400 From: Antoine Tremblay To: CC: Antoine Tremblay Subject: [PATCH v2 7/7] Support software breakpoints for ARM linux in GDBServer. Date: Mon, 5 Oct 2015 12:44:15 -0400 Message-ID: <1444063455-31558-8-git-send-email-antoine.tremblay@ericsson.com> In-Reply-To: <1444063455-31558-1-git-send-email-antoine.tremblay@ericsson.com> References: <1444063455-31558-1-git-send-email-antoine.tremblay@ericsson.com> MIME-Version: 1.0 X-IsSubscribed: yes This patch implements the breakpoint_from_kind operation introduced in a previous patch. The proper breakpoint can then be returned to be inserted in memory. It enables software breakpoints via GDB's Z0 packets on ARM. No regressions, tested on ubuntu 14.04 ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/ChangeLog: * NEWS: Add news for software breakpoints. gdb/gdbserver/ChangeLog: * linux-arm-low.c (arm_breakpoint_from_kind): New function. (arm_supports_z_point_type): Add software breakpoint support. (struct linux_target_ops) : Initialize field. --- gdb/NEWS | 2 ++ gdb/gdbserver/linux-arm-low.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/gdb/NEWS b/gdb/NEWS index 2e38d9a..17f1c05 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -3,6 +3,8 @@ *** Changes since GDB 7.10 +* Support for software breakpoints on ARM linux was added in GDBServer. + * Record btrace now supports non-stop mode. * Support for tracepoints on aarch64-linux was added in GDBserver. diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c index d16ea60..bd499f8 100644 --- a/gdb/gdbserver/linux-arm-low.c +++ b/gdb/gdbserver/linux-arm-low.c @@ -336,6 +336,28 @@ arm_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr) } } +/* Get the breakpoint from the remote kind + 2 is thumb-16 + 3 is thumb2-32 + 4 is arm +*/ +static const unsigned char * +arm_breakpoint_from_kind (int *kind) +{ + switch (*kind) { + case 2: + return (unsigned char *) &thumb_breakpoint; + case 3: + *kind = 4; + return (unsigned char *) &thumb2_breakpoint; + case 4: + return (unsigned char *) &arm_breakpoint; + default: + return NULL; + } + return NULL; +} + /* We only place breakpoints in empty marker functions, and thread locking is outside of the function. So rather than importing software single-step, we can just run until exit. */ @@ -577,6 +599,7 @@ arm_supports_z_point_type (char z_type) { switch (z_type) { + case Z_PACKET_SW_BP: case Z_PACKET_HW_BP: case Z_PACKET_WRITE_WP: case Z_PACKET_READ_WP: @@ -988,6 +1011,14 @@ struct linux_target_ops the_low_target = { arm_new_thread, arm_new_fork, arm_prepare_to_resume, + NULL, /* process_qsupported */ + NULL, /* supports_tracepoints */ + NULL, /* get_thread_area */ + NULL, /* install_fast_tracepoint_jump_pad */ + NULL, /* emit_ops */ + NULL, /* get_min_fast_tracepoint_insn_len */ + NULL, /* supports_range_stepping */ + arm_breakpoint_from_kind, }; void