This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 1/2] Hoist code on marking thread as exited
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 5 Apr 2017 22:15:41 +0100
- Subject: [PATCH 1/2] Hoist code on marking thread as exited
- Authentication-results: sourceware.org; auth=none
- References: <1f525e52-f547-63ac-0a31-e92686c9caf8@redhat.com> <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