From patchwork Wed Apr 5 21:15:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 19875 Received: (qmail 33676 invoked by alias); 5 Apr 2017 21:15:49 -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 33561 invoked by uid 89); 5 Apr 2017 21:15:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f175.google.com Received: from mail-wr0-f175.google.com (HELO mail-wr0-f175.google.com) (209.85.128.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Apr 2017 21:15:47 +0000 Received: by mail-wr0-f175.google.com with SMTP id t20so33455692wra.1 for ; Wed, 05 Apr 2017 14:15:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=DsU+MEJDVBlJ1UfhnI3kh8zI97/4E/XWTGKDCfTd75Q=; b=Hmk2PxCbyd6Xck7L8CfYph1B1yIK9+COEXfpV453rDTF3nwfIDdQyloJ8H6+cB2UYW 7wPsbdN1ysgOM6IFVeMWAzWLKTUtM2MxOEr7nhmb7us9hQS0o0Fw/lpOsYw5BFGHk9zi JXVPK5gU3p6yS1ceq40SjOvpRxYF54YrWTjZP+86XFdW9wvYHSHzCptTv5tKItzqxjNs prl5dbdYbwbDXJ+fXiqsK78hOn4h/Ev5V46/j2w0s9oU9Ik2WAwsGR4K9eqiJML0j6T7 sAGe57HyTM+s9LfeSVJXdgsoqziYY2hMnlHF/yoZ7OGFlgevYPJfcA9LANtp8/DjAWAR xT7A== X-Gm-Message-State: AFeK/H3OM+kBDtNqVJpCKPgqDSsrx/tSY2+0MEiwB3OdCKehN5w7xj0R 5lBTa0PXqLr/8xBl X-Received: by 10.28.95.87 with SMTP id t84mr20797601wmb.35.1491426946437; Wed, 05 Apr 2017 14:15:46 -0700 (PDT) Received: from E107787-LIN.Home ([194.214.185.158]) by smtp.gmail.com with ESMTPSA id o22sm12800012wro.45.2017.04.05.14.15.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Apr 2017 14:15:45 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 1/2] Hoist code on marking thread as exited Date: Wed, 5 Apr 2017 22:15:41 +0100 Message-Id: <1491426942-6306-2-git-send-email-yao.qi@linaro.org> In-Reply-To: <1491426942-6306-1-git-send-email-yao.qi@linaro.org> References: <1f525e52-f547-63ac-0a31-e92686c9caf8@redhat.com> <1491426942-6306-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes This patch hoists code on marking thread as exited, so more code is shared for two different paths (thread_info is deleted or is not deleted). gdb: 2017-04-05 Yao Qi * thread.c (delete_thread_1): Hoist code on marking thread as exited. --- gdb/thread.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/gdb/thread.c b/gdb/thread.c index fd9022f..cc3af7a 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -434,35 +434,26 @@ delete_thread_1 (ptid_t ptid, int silent) if (tp->step_over_next != NULL) thread_step_over_chain_remove (tp); - /* If this is the current thread, or there's code out there that - relies on it existing (refcount > 0) we can't delete yet. Mark - it as exited, and notify it. */ - if (tp->refcount > 0 - || ptid_equal (tp->ptid, inferior_ptid)) + if (tp->state != THREAD_EXITED) { - if (tp->state != THREAD_EXITED) - { - observer_notify_thread_exit (tp, silent); + observer_notify_thread_exit (tp, silent); - /* Tag it as exited. */ - tp->state = THREAD_EXITED; + /* Tag it as exited. */ + tp->state = THREAD_EXITED; - /* Clear breakpoints, etc. associated with this thread. */ - clear_thread_inferior_resources (tp); - } + /* Clear breakpoints, etc. associated with this thread. */ + clear_thread_inferior_resources (tp); + } + /* If this is the current thread, or there's code out there that + relies on it existing (refcount > 0) we can't delete yet. */ + if (tp->refcount > 0 + || ptid_equal (tp->ptid, inferior_ptid)) + { /* Will be really deleted some other time. */ return; } - /* Notify thread exit, but only if we haven't already. */ - if (tp->state != THREAD_EXITED) - observer_notify_thread_exit (tp, silent); - - /* Tag it as exited. */ - tp->state = THREAD_EXITED; - clear_thread_inferior_resources (tp); - if (tpprev) tpprev->next = tp->next; else