Skip to content

Commit

Permalink
Hoist code on marking thread as exited
Browse files Browse the repository at this point in the history
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  <[email protected]>

	* thread.c (delete_thread_1): Hoist code on marking thread as
	exited.
  • Loading branch information
Yao Qi committed Apr 10, 2017
1 parent 947fa91 commit 8c25b49
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
5 changes: 5 additions & 0 deletions gdb/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2017-04-10 Yao Qi <[email protected]>

* thread.c (delete_thread_1): Hoist code on marking thread as
exited.

2017-04-09 Simon Marchi <[email protected]>

* windows-nat.c (windows_detach): Initialize ptid with
Expand Down
33 changes: 12 additions & 21 deletions gdb/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8c25b49

Please sign in to comment.