From patchwork Fri May 20 15:12:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 12414 Received: (qmail 68021 invoked by alias); 20 May 2016 15:13:07 -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 67864 invoked by uid 89); 20 May 2016 15:13:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=parent's X-HELO: mail-pa0-f67.google.com Received: from mail-pa0-f67.google.com (HELO mail-pa0-f67.google.com) (209.85.220.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 20 May 2016 15:12:55 +0000 Received: by mail-pa0-f67.google.com with SMTP id xm6so11172740pab.3 for ; Fri, 20 May 2016 08:12:55 -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=bE1J5OVmPifYNAYpWNUr9DxtiH5IqGbC8CHLqc2/wzo=; b=V7EPfjNlXRcjjyT5m5FHU/idVYyNJJk15K6dHjM97dJyBQyQ5/xZ8Ndw0dGknEAVkd A9nENvMheixf0RYd6gXgeQY5ow6oi4J/nmv1sJbjE9Z7pvekHcXkikuvnZB5GgIrowAc U3LnFwpnH5ee3rBBVfxTqezlHdFqB3NV21/hX/w4pf0T2wez71vfJ5GsO65sQaWg6ELr qy1QdXhx/tga8SKYc+PurKz28ejHODAfb/ceDyq/mcKD++j0436mlu6jJfiyifdBVZN3 HWoXYlI7JDIi5GFkiRs/uadRjVYp7n+BkUjnzd4lnACJXfkFR1WJStc1sLfLOGDWwyPU gojA== X-Gm-Message-State: AOPr4FX8kPxPznNDkRnmIa3EJZGJy0B/KuZqk1qpGXvRKxd3DRD1fLrrK9c3AhWA33UHlw== X-Received: by 10.66.183.69 with SMTP id ek5mr5574772pac.153.1463757173776; Fri, 20 May 2016 08:12:53 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc113.osuosl.org. [140.211.9.71]) by smtp.gmail.com with ESMTPSA id p80sm27985272pfj.58.2016.05.20.08.12.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 May 2016 08:12:53 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 2/8] Delete reinsert breakpoints from forked child Date: Fri, 20 May 2016 16:12:35 +0100 Message-Id: <1463757161-25850-3-git-send-email-yao.qi@linaro.org> In-Reply-To: <1463757161-25850-1-git-send-email-yao.qi@linaro.org> References: <1463757161-25850-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes When a thread is stepping over a syscall instruction with software single step, GDBserver inserts reinsert breakpoints at the next pcs. If the syscall call is fork, the forked child has reinsert breakpoint in its space, and GDBserver clones parent's breakpoint list to child's. When GDBserver resumes the child, it hits the reinsert breakpoint. Since it is a GDBserver internal breakpoint, GDBserver will do step-over again, and remove this reinsert breakpoint on step-over is finished, so the reinsert breakpoint left in the child process doesn't make any trouble. However, GDBserver still need to remove the reinsert breakpoints from the child, in order to avoid the unnecessary breakpoint hit and step-over. gdb/gdbserver: 2016-05-20 Yao Qi * linux-low.c (handle_extended_wait): If the parent is doing step-over, remove the reinsert breakpoints from the child. --- gdb/gdbserver/linux-low.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 8e8f710..a63cc7a 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -568,6 +568,25 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat) event_lwp->status_pending_p = 1; event_lwp->status_pending = wstat; + /* If the parent thread is doing step-over with reinsert + breakpoints, the reinsert breakpoints are still in child's + process space and cloned to its breakpoint list from the + parent's. Remove them. */ + if (event_lwp->bp_reinsert != 0 && can_software_single_step ()) + { + struct thread_info *saved_thread = current_thread; + + /* The child process is forked and stopped, so it is safe + to access its memory without stopping all other threads + from other processes. */ + current_thread = child_thr; + delete_reinsert_breakpoints (); + current_thread = saved_thread; + + gdb_assert (has_reinsert_breakpoints (parent_proc)); + gdb_assert (!has_reinsert_breakpoints (child_proc)); + } + /* Report the event. */ return 0; }