From patchwork Thu Oct 29 17:09:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Tremblay X-Patchwork-Id: 9467 Received: (qmail 88226 invoked by alias); 29 Oct 2015 17:10:13 -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 88181 invoked by uid 89); 29 Oct 2015 17:10:12 -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: usevmg20.ericsson.net Received: from usevmg20.ericsson.net (HELO usevmg20.ericsson.net) (198.24.6.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 29 Oct 2015 17:10:08 +0000 Received: from EUSAAHC004.ericsson.se (Unknown_Domain [147.117.188.84]) by usevmg20.ericsson.net (Symantec Mail Security) with SMTP id B4.0C.32596.ED1F1365; Thu, 29 Oct 2015 11:15:58 +0100 (CET) Received: from elxa4wqvvz1.dyn.mo.ca.am.ericsson.se (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.84) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 29 Oct 2015 13:09:53 -0400 From: Antoine Tremblay To: CC: Antoine Tremblay Subject: [PATCH 09/10] Enable software single stepping for while-stepping actions in GDBServer. Date: Thu, 29 Oct 2015 13:09:42 -0400 Message-ID: <1446138583-13268-10-git-send-email-antoine.tremblay@ericsson.com> In-Reply-To: <1446138583-13268-1-git-send-email-antoine.tremblay@ericsson.com> References: <1446138583-13268-1-git-send-email-antoine.tremblay@ericsson.com> MIME-Version: 1.0 X-IsSubscribed: yes This patch enables software single stepping if the targets supports it, to do while-stepping actions. No regressions, tested on ubuntu 14.04 ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/gdbserver/ChangeLog: * linux-low.c (single_step): New function. (linux_resume_one_lwp_throw): Call single_step. (start_step_over): Likewise. --- gdb/gdbserver/linux-low.c | 59 +++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 1f423ba..d0a9c2a 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -3900,7 +3900,34 @@ install_software_single_step_breakpoints (struct lwp_info *lwp) VEC_free (CORE_ADDR, next_pcs.result); } -/* Resume execution of LWP. If STEP is nonzero, single-step it. If +/* Single step via hardware or software single step. + Return 1 if hardware single stepping, 0 if software single stepping + or can't single step. */ + +static int +single_step (struct lwp_info* lwp) +{ + int step = 0; + + if (can_hardware_single_step ()) + { + step = 1; + } + else if (can_software_single_step ()) + { + install_software_single_step_breakpoints (lwp); + step = 0; + } + else + { + if (debug_threads) + debug_printf ("stepping is not implemented on this target"); + } + + return step; +} + +/* RESUME execution of LWP. If STEP is nonzero, single-step it. If SIGNAL is nonzero, give it that signal. */ static void @@ -4045,14 +4072,13 @@ linux_resume_one_lwp_throw (struct lwp_info *lwp, address, continue, and carry on catching this while-stepping action only when that breakpoint is hit. A future enhancement. */ - if (thread->while_stepping != NULL - && can_hardware_single_step ()) - { - if (debug_threads) - debug_printf ("lwp %ld has a while-stepping action -> forcing step.\n", - lwpid_of (thread)); - step = 1; - } + if (thread->while_stepping != NULL) { + if (debug_threads) + debug_printf ("lwp %ld has a while-stepping action -> forcing step.\n", + lwpid_of (thread)); + + step = single_step (lwp); + } if (proc->tdesc != NULL && the_low_target.get_pc != NULL) { @@ -4457,20 +4483,7 @@ start_step_over (struct lwp_info *lwp) uninsert_breakpoints_at (pc); uninsert_fast_tracepoint_jumps_at (pc); - if (can_hardware_single_step ()) - { - step = 1; - } - else if (can_software_single_step ()) - { - install_software_single_step_breakpoints (lwp); - step = 0; - } - else - { - internal_error (__FILE__, __LINE__, - "stepping is not implemented on this target"); - } + step = single_step (lwp); current_thread = saved_thread;