Skip to content

Commit 8c25b49

Browse files
author
Yao Qi
committed
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.
1 parent 947fa91 commit 8c25b49

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

gdb/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2017-04-10 Yao Qi <yao.qi@linaro.org>
2+
3+
* thread.c (delete_thread_1): Hoist code on marking thread as
4+
exited.
5+
16
2017-04-09 Simon Marchi <simon.marchi@polymtl.ca>
27

38
* windows-nat.c (windows_detach): Initialize ptid with

gdb/thread.c

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -434,35 +434,26 @@ delete_thread_1 (ptid_t ptid, int silent)
434434
if (tp->step_over_next != NULL)
435435
thread_step_over_chain_remove (tp);
436436

437-
/* If this is the current thread, or there's code out there that
438-
relies on it existing (refcount > 0) we can't delete yet. Mark
439-
it as exited, and notify it. */
440-
if (tp->refcount > 0
441-
|| ptid_equal (tp->ptid, inferior_ptid))
437+
if (tp->state != THREAD_EXITED)
442438
{
443-
if (tp->state != THREAD_EXITED)
444-
{
445-
observer_notify_thread_exit (tp, silent);
439+
observer_notify_thread_exit (tp, silent);
446440

447-
/* Tag it as exited. */
448-
tp->state = THREAD_EXITED;
441+
/* Tag it as exited. */
442+
tp->state = THREAD_EXITED;
449443

450-
/* Clear breakpoints, etc. associated with this thread. */
451-
clear_thread_inferior_resources (tp);
452-
}
444+
/* Clear breakpoints, etc. associated with this thread. */
445+
clear_thread_inferior_resources (tp);
446+
}
453447

448+
/* If this is the current thread, or there's code out there that
449+
relies on it existing (refcount > 0) we can't delete yet. */
450+
if (tp->refcount > 0
451+
|| ptid_equal (tp->ptid, inferior_ptid))
452+
{
454453
/* Will be really deleted some other time. */
455454
return;
456455
}
457456

458-
/* Notify thread exit, but only if we haven't already. */
459-
if (tp->state != THREAD_EXITED)
460-
observer_notify_thread_exit (tp, silent);
461-
462-
/* Tag it as exited. */
463-
tp->state = THREAD_EXITED;
464-
clear_thread_inferior_resources (tp);
465-
466457
if (tpprev)
467458
tpprev->next = tp->next;
468459
else

0 commit comments

Comments
 (0)