aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2017-04-10 14:39:41 +0100
committerYao Qi <yao.qi@linaro.org>2017-04-10 14:39:41 +0100
commit8c25b49760b854d0b8451e8ecffeb9860fc41158 (patch)
tree1b96a3a397f087b81076fc5449c54637c016a066
parent947fa9141488c1d39303fcdaa056332d2d0b2599 (diff)
downloadgdb-8c25b49760b854d0b8451e8ecffeb9860fc41158.zip
gdb-8c25b49760b854d0b8451e8ecffeb9860fc41158.tar.gz
gdb-8c25b49760b854d0b8451e8ecffeb9860fc41158.tar.bz2
Hoist code on marking thread as exited
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-10 Yao Qi <yao.qi@linaro.org> * thread.c (delete_thread_1): Hoist code on marking thread as exited.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/thread.c33
2 files changed, 17 insertions, 21 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f08f520..a1f8b49 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-10 Yao Qi <yao.qi@linaro.org>
+
+ * thread.c (delete_thread_1): Hoist code on marking thread as
+ exited.
+
2017-04-09 Simon Marchi <simon.marchi@polymtl.ca>
* windows-nat.c (windows_detach): Initialize ptid with
diff --git a/gdb/thread.c b/gdb/thread.c
index 24347dd..2e9da53 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