From patchwork Thu Jun 30 14:09:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 13520 Received: (qmail 60282 invoked by alias); 30 Jun 2016 14:09:55 -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 60072 invoked by uid 89); 30 Jun 2016 14:09:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=lp, Stop X-HELO: mail-pf0-f194.google.com Received: from mail-pf0-f194.google.com (HELO mail-pf0-f194.google.com) (209.85.192.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 30 Jun 2016 14:09:44 +0000 Received: by mail-pf0-f194.google.com with SMTP id 66so7504927pfy.1 for ; Thu, 30 Jun 2016 07:09:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=vOsmIDMm/px/IhnSRe8BhJ7mKG6fzNaNATaBMXiaHL8=; b=RMMaODKKkTij4eyQKOKvRSKr6gs5wr0BR3qvWQotis9ARfUiMB/VKEwo4FpgXpSuQP kyFRQr9IBDxLTdHjUm6//zeD8pzIKuFE4xpC/zCsnLlom0pLmV2Tq6zxk19mxlyzXvdH rCmKIHHqkFbH5ML7GEzdIEctGGGc+2kqTyK49dq5xOGEnhYst2Dg5SVtfBQ7D9vgBNv4 shkqO69WcdaqeDlyGnTht52lOt/Nz3+3q/4S6pw5GIcy5ogvxbJYYE8CUO1tk2nWP/Hm Z0Hkq0zjpqUAjHcS/1MP+zwtwix9Y0Na+XGolA/W/oMKhGvUIrClW6mRmTL2yz1A3lfS kN+Q== X-Gm-Message-State: ALyK8tLzZLtO+XUNH/O7raA9FWUWFSNI6ITzkXKg5AaaY3dV52Bvk3qRnTY1hMM4LFDeVg== X-Received: by 10.98.28.143 with SMTP id c137mr21802166pfc.131.1467295782542; Thu, 30 Jun 2016 07:09:42 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id s3sm6263184pfb.87.2016.06.30.07.09.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Jun 2016 07:09:41 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 8/9] Use reinsert_breakpoint for vCont;s Date: Thu, 30 Jun 2016 15:09:24 +0100 Message-Id: <1467295765-3457-9-git-send-email-yao.qi@linaro.org> In-Reply-To: <1467295765-3457-1-git-send-email-yao.qi@linaro.org> References: <1467295765-3457-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes V3: - install breakpoints in proceed_one_lwp, if the thread doesn't have reinsert breakpoints installed yet, - no longer stop all threads when installing breakpoints, - delete reinsert breakpoints when GDBserver wants to report event, > - Also, if in all-stop mode, if gdb does: > > vCont;s:1;c > > thus setting thread 1 stepping, and all others continuing, > and then some other thread but thread 1 hits a breakpoint, > what is removing the reinsert breakpoint of thread 1? if thread 1 doesn't hit the reinsert breakpoint, we don't have to remove them, because GDB will send vCont;s:1 next time, and GDBserver can only install reinsert breakpoints if they are not installed yet. if thread hits the reinsert breakpoint, but the event is not reported. It becomes pending, and GDBserver will delete the reinsert breakpoints next time when this pending event is reported back to GDB. V2: fix spaces in changelog entry, use maybe_hw_step, cancel step-over if signal arrives (!maybe_internal_trap), This patch is to teach GDBserver using software single step to handle vCont;s. Simply speaking, if the thread's resume request is resume_step, install reinsert breakpoint at the next pcs when GDBserver is about to resume threads. These reinsert breakpoints of a thread are removed, when GDBserver gets an event from that thread and reports this event back to GDB. gdb/gdbserver: 2016-06-30 Yao Qi * linux-low.c (resume_stopped_resumed_lwps): If resume request is resume_step, call maybe_hw_step. (linux_wait_1): Stop all threads, remove reinsert breakpoints, and unstop them. (linux_resume_one_lwp_throw): Don't assert the thread has reinsert breakpoints or not. (proceed_one_lwp): If resume request is resume_step, install reinsert breakpoints and call maybe_hw_step. --- gdb/gdbserver/linux-low.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index abaf288..c9bb012 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -2563,7 +2563,10 @@ resume_stopped_resumed_lwps (struct inferior_list_entry *entry) && !lp->status_pending_p && thread->last_status.kind == TARGET_WAITKIND_IGNORE) { - int step = thread->last_resume_kind == resume_step; + int step = 0; + + if (thread->last_resume_kind == resume_step) + step = maybe_hw_step (thread); if (debug_threads) debug_printf ("RSRL: resuming stopped-resumed LWP %s at %s: step=%d\n", @@ -3622,6 +3625,20 @@ linux_wait_1 (ptid_t ptid, /* Alright, we're going to report a stop. */ + /* Remove reinsert breakpoints. */ + if (can_software_single_step () + && has_reinsert_breakpoints (current_thread)) + { + /* Stop all threads before removing breakpoints out of memory, + so that threads other than EVENT_CHILD won't hit the + breakpoint in the staled memory. */ + stop_all_lwps (0, event_child); + + delete_reinsert_breakpoints (current_thread); + + unstop_all_lwps (0, event_child); + } + if (!stabilizing_threads) { /* In all-stop, stop all threads. */ @@ -4275,12 +4292,6 @@ linux_resume_one_lwp_throw (struct lwp_info *lwp, step = maybe_hw_step (thread); } - else - { - /* If the thread isn't doing step-over, there shouldn't be any - reinsert breakpoints. */ - gdb_assert (!has_reinsert_breakpoints (thread)); - } if (fast_tp_collecting == 1) { @@ -5088,7 +5099,14 @@ proceed_one_lwp (struct inferior_list_entry *entry, void *except) if (debug_threads) debug_printf (" stepping LWP %ld, client wants it stepping\n", lwpid_of (thread)); - step = 1; + + /* If resume_step is requested by GDB, install reinsert + breakpoints when the thread is about to be actually resumed if + the reinsert breakpoints weren't removed. */ + if (can_software_single_step () && !has_reinsert_breakpoints (thread)) + install_software_single_step_breakpoints (lwp); + + step = maybe_hw_step (thread); } else if (lwp->bp_reinsert != 0) {