From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/2] Hoist code on marking thread as exited
Date: Wed, 05 Apr 2017 21:15:00 -0000 [thread overview]
Message-ID: <1491426942-6306-2-git-send-email-yao.qi@linaro.org> (raw)
In-Reply-To: <1491426942-6306-1-git-send-email-yao.qi@linaro.org>
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 <yao.qi@linaro.org>
* 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
--
1.9.1
next prev parent reply other threads:[~2017-04-05 21:15 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-28 8:24 [PATCH 0/2] Fix thread_info refcount Yao Qi
2017-03-28 8:24 ` [PATCH 2/2] Delete thread_info is refcount is zero Yao Qi
2017-03-28 12:10 ` Pedro Alves
2017-04-05 21:15 ` [PATCH 0/2] Don't delete thread_info if refcount isn't zero Yao Qi
2017-04-05 21:15 ` Yao Qi [this message]
2017-04-06 9:27 ` [PATCH 1/2] Hoist code on marking thread as exited Pedro Alves
2017-04-05 21:15 ` [PATCH 2/2] Don't delete thread_info if refcount isn't zero Yao Qi
2017-04-06 10:18 ` Pedro Alves
2017-04-07 9:22 ` Yao Qi
2017-04-07 10:29 ` Pedro Alves
2017-04-10 13:40 ` Yao Qi
2017-04-10 14:50 ` [pushed] GC gdb/thread.c:current_thread_cleanup_chain (Re: [PATCH 2/2] Don't delete thread_info if refcount isn't zero) Pedro Alves
2017-04-10 15:57 ` [PATCH 2/2] Don't delete thread_info if refcount isn't zero Pedro Alves
[not found] ` <1490689483-16084-2-git-send-email-yao.qi@linaro.org>
2017-03-28 12:12 ` [PATCH 1/2] Add constructor and destructor to thread_info Pedro Alves
2017-03-28 14:08 ` Yao Qi
2017-03-28 14:47 ` Pedro Alves
2017-03-28 15:40 ` Yao Qi
2017-03-28 22:35 ` Pedro Alves
2017-03-29 15:59 ` Yao Qi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1491426942-6306-2-git-send-email-yao.qi@linaro.org \
--to=qiyaoltc@gmail.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox