From patchwork Thu Jun 30 14:09:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 13518 Received: (qmail 60189 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 60082 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=lift X-HELO: mail-pf0-f193.google.com Received: from mail-pf0-f193.google.com (HELO mail-pf0-f193.google.com) (209.85.192.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 30 Jun 2016 14:09:43 +0000 Received: by mail-pf0-f193.google.com with SMTP id i123so7499603pfg.3 for ; Thu, 30 Jun 2016 07:09:42 -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=86HU4A4Azzx6ONHqNXm4OmIxDhz4++aIj+hNG3pXcHY=; b=L14OFvQFQs4f0y9nTvGSycDrSN9joeQIfNhLTAvTcboG8pMFC0BiFz1Nbkq2Yt57vX QSrWk5knugGDbTcmdijtkurYNgtOAEqny9cVE8aP7lGLueJy/u0lBeur5eYhaH8F9A35 PcvT5tupYrTRoMx3X0qzSoBzPH0NqBOn6NiM4UmFJZ0IKhh6vyJ8EgCO+dEcWrWo8EBn cd9sGzsPoP/7RCWaHRjVEX1GoMEdelhzoAh4zFLVYTfUU82BFQGATsy749utnI1LOXuF 4goWJX/pM0u0UB2hBXyoStXBEkXKT6MDUp1O3m5pxpyCOhQSZ6Ee6DekdVrxVyWFG9pX J9zA== X-Gm-Message-State: ALyK8tLrO37aq//uzS+KITT/HhVSSCsO7VIt9FqvzD8lPlaz4xoO2Iml2srVm6d+03q0jw== X-Received: by 10.98.103.198 with SMTP id t67mr21696676pfj.158.1467295781143; Thu, 30 Jun 2016 07:09:41 -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.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Jun 2016 07:09:40 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 7/9] Enqueue signal even when resuming threads Date: Thu, 30 Jun 2016 15:09:23 +0100 Message-Id: <1467295765-3457-8-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 Nowadays, we only enqueue signal when we leave thread pending in linux_resume_one_thread. If lwp->resume->sig isn't zero (GDB wants to resume with signal), we pass lwp->resume->sig to linux_resume_one_lwp. In order to reduce the difference between resuming thread with signal and proceeding thread with signal, when we resume thread, we can enqueue signal too, and proceed thread. The signal will be consumed in linux_resume_one_lwp_throw from lwp->pending_signals. gdb/gdbserver: 2016-06-29 Yao Qi * linux-low.c (proceed_one_lwp): Declare. (linux_resume_one_thread): Remove local variable 'step'. Lift code enqueue signal. Call proceed_one_lwp instead of linux_resume_one_lwp. --- gdb/gdbserver/linux-low.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 8061758..abaf288 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -267,6 +267,7 @@ static int kill_lwp (unsigned long lwpid, int signo); static void enqueue_pending_signal (struct lwp_info *lwp, int signal, siginfo_t *info); static void complete_ongoing_step_over (void); static int linux_low_ptrace_options (int attached); +static int proceed_one_lwp (struct inferior_list_entry *entry, void *except); /* When the event-loop is doing a step-over, this points at the thread being stepped. */ @@ -4834,7 +4835,6 @@ linux_resume_one_thread (struct inferior_list_entry *entry, void *arg) { struct thread_info *thread = (struct thread_info *) entry; struct lwp_info *lwp = get_thread_lwp (thread); - int step; int leave_all_stopped = * (int *) arg; int leave_pending; @@ -4901,36 +4901,35 @@ linux_resume_one_thread (struct inferior_list_entry *entry, void *arg) || lwp->status_pending_p || leave_all_stopped); + /* If we have a new signal, enqueue the signal. */ + if (lwp->resume->sig != 0) + { + siginfo_t info, *info_p; + + /* If this is the same signal we were previously stopped by, + make sure to queue its siginfo. */ + if (WIFSTOPPED (lwp->last_status) + && WSTOPSIG (lwp->last_status) == lwp->resume->sig + && ptrace (PTRACE_GETSIGINFO, lwpid_of (thread), + (PTRACE_TYPE_ARG3) 0, &info) == 0) + info_p = &info; + else + info_p = NULL; + + enqueue_pending_signal (lwp, lwp->resume->sig, info_p); + } + if (!leave_pending) { if (debug_threads) debug_printf ("resuming LWP %ld\n", lwpid_of (thread)); - step = (lwp->resume->kind == resume_step); - linux_resume_one_lwp (lwp, step, lwp->resume->sig, NULL); + proceed_one_lwp (entry, NULL); } else { if (debug_threads) debug_printf ("leaving LWP %ld stopped\n", lwpid_of (thread)); - - /* If we have a new signal, enqueue the signal. */ - if (lwp->resume->sig != 0) - { - siginfo_t info, *info_p; - - /* If this is the same signal we were previously stopped by, - make sure to queue its siginfo. */ - if (WIFSTOPPED (lwp->last_status) - && WSTOPSIG (lwp->last_status) == lwp->resume->sig - && ptrace (PTRACE_GETSIGINFO, lwpid_of (thread), - (PTRACE_TYPE_ARG3) 0, &info) == 0) - info_p = &info; - else - info_p = NULL; - - enqueue_pending_signal (lwp, lwp->resume->sig, info_p); - } } thread->last_status.kind = TARGET_WAITKIND_IGNORE;