From a07daef34e77308381c29146b83f8926520755e0 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 25 Mar 2009 21:53:11 +0000 Subject: [PATCH] gdb/ * infrun.c (infrun_thread_thread_exit): New. (_initialize_infrun): Attach it to the thread_exit observer. * thread.c (delete_thread_1): Always call the observer, passing it the silent flag. * mi/mi-interp.c (mi_thread_exit): Add "silent" parameter. If SILENT, return immediately. gdb/doc/ * observer.texi (thread_exit): Add "silent" parameter. --- gdb/ChangeLog | 9 +++++++++ gdb/doc/ChangeLog | 4 ++++ gdb/doc/observer.texi | 6 ++++-- gdb/infrun.c | 10 ++++++++++ gdb/mi/mi-interp.c | 11 ++++++++--- gdb/thread.c | 7 +++---- 6 files changed, 38 insertions(+), 9 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 393f269..42623a9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2000-03-25 Pedro Alves + + * infrun.c (infrun_thread_thread_exit): New. + (_initialize_infrun): Attach it to the thread_exit observer. + * thread.c (delete_thread_1): Always call the observer, passing it + the silent flag. + * mi/mi-interp.c (mi_thread_exit): Add "silent" parameter. If + SILENT, return immediately. + 2009-03-25 Pedro Alves * infrun.c (normal_stop): Use has_stack_frames instead of diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index d86674a..2c4b291 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +2009-03-25 Pedro Alves + + * observer.texi (thread_exit): Add "silent" parameter. + 2009-03-22 Pedro Alves * observer.texi (about_to_proceed): New. diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi index f0fc6f4..4984f31 100644 --- a/gdb/doc/observer.texi +++ b/gdb/doc/observer.texi @@ -134,8 +134,10 @@ previously loaded symbol table data has now been invalidated. The thread specified by @var{t} has been created. @end deftypefun -@deftypefun void thread_exit (struct thread_info *@var{t}) -The thread specified by @var{t} has exited. +@deftypefun void thread_exit (struct thread_info *@var{t}, int @var{silent}) +The thread specified by @var{t} has exited. The @var{silent} argument +indicates that @value{GDBN} is removing the thread from its tables +without wanting to notify the user about it. @end deftypefun @deftypefun void thread_stop_requested (ptid_t @var{ptid}) diff --git a/gdb/infrun.c b/gdb/infrun.c index 4e270fc..7a9f4e9 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1691,6 +1691,15 @@ infrun_thread_stop_requested (ptid_t ptid) iterate_over_threads (infrun_thread_stop_requested_callback, &ptid); } +void nullify_last_target_wait_ptid (void); + +static void +infrun_thread_thread_exit (struct thread_info *tp, int silent) +{ + if (ptid_equal (target_last_wait_ptid, tp->ptid)) + nullify_last_target_wait_ptid (); +} + /* Callback for iterate_over_threads. */ static int @@ -5575,6 +5584,7 @@ Options are 'forward' or 'reverse'."), observer_attach_thread_ptid_changed (infrun_thread_ptid_changed); observer_attach_thread_stop_requested (infrun_thread_stop_requested); + observer_attach_thread_exit (infrun_thread_thread_exit); /* Explicitly create without lookup, since that tries to create a value with a void typed value, and when we get here, gdbarch diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index dee921f..4775eec 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -55,7 +55,7 @@ static void mi_remove_notify_hooks (void); static void mi_on_normal_stop (struct bpstats *bs, int print_frame); static void mi_new_thread (struct thread_info *t); -static void mi_thread_exit (struct thread_info *t); +static void mi_thread_exit (struct thread_info *t, int silent); static void mi_new_inferior (int pid); static void mi_inferior_exit (int pid); static void mi_on_resume (ptid_t ptid); @@ -293,9 +293,14 @@ mi_new_thread (struct thread_info *t) } static void -mi_thread_exit (struct thread_info *t) +mi_thread_exit (struct thread_info *t, int silent) { - struct mi_interp *mi = top_level_interpreter_data (); + struct mi_interp *mi; + + if (silent) + return; + + mi = top_level_interpreter_data (); target_terminal_ours (); fprintf_unfiltered (mi->event_channel, "thread-exited,id=\"%d\",group-id=\"%d\"", diff --git a/gdb/thread.c b/gdb/thread.c index fc3df61..eaef50e 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -247,8 +247,7 @@ delete_thread_1 (ptid_t ptid, int silent) { if (tp->state_ != THREAD_EXITED) { - if (!silent) - observer_notify_thread_exit (tp); + observer_notify_thread_exit (tp, silent); /* Tag it as exited. */ tp->state_ = THREAD_EXITED; @@ -267,8 +266,8 @@ delete_thread_1 (ptid_t ptid, int silent) thread_list = tp->next; /* Notify thread exit, but only if we haven't already. */ - if (!silent && tp->state_ != THREAD_EXITED) - observer_notify_thread_exit (tp); + if (tp->state_ != THREAD_EXITED) + observer_notify_thread_exit (tp, silent); free_thread (tp); } -- 2.7.4