* gdbthread.h (struct thread_info): Add in_infcall member.
authorPedro Alves <palves@redhat.com>
Sun, 22 Mar 2009 17:59:59 +0000 (17:59 +0000)
committerPedro Alves <palves@redhat.com>
Sun, 22 Mar 2009 17:59:59 +0000 (17:59 +0000)
* infcall.c (run_inferior_call): Save, set and restore in_infcall.
Remove reverences to suppress_resume_observer.  Refresh
`call_thread' after returning from `proceed'.
* infcmd.c (suppress_resume_observer): Delete.
* inferior.h (suppress_resume_observer): Delete declaration.
* mi/mi-interp.c (mi_on_resume): Suppress output while calling an
inferior function.
* thread.c (set_running): Remove references to
suppress_resume_observer.
* infrun.c (struct inferior_status): Add in_infcall member.
(save_inferior_status): Save it.
(restore_inferior_status): Restore it.

gdb/ChangeLog
gdb/gdbthread.h
gdb/infcall.c
gdb/infcmd.c
gdb/inferior.h
gdb/infrun.c
gdb/mi/mi-interp.c
gdb/thread.c

index 504ed02..12aff52 100644 (file)
@@ -1,5 +1,21 @@
 2009-03-22  Pedro Alves  <pedro@codesourcery.com>
 
+       * gdbthread.h (struct thread_info): Add in_infcall member.
+       * infcall.c (run_inferior_call): Save, set and restore in_infcall.
+       Remove reverences to suppress_resume_observer.  Refresh
+       `call_thread' after returning from `proceed'.
+       * infcmd.c (suppress_resume_observer): Delete.
+       * inferior.h (suppress_resume_observer): Delete declaration.
+       * mi/mi-interp.c (mi_on_resume): Suppress output while calling an
+       inferior function.
+       * thread.c (set_running): Remove references to
+       suppress_resume_observer.
+       * infrun.c (struct inferior_status): Add in_infcall member.
+       (save_inferior_status): Save it.
+       (restore_inferior_status): Restore it.
+
+2009-03-22  Pedro Alves  <pedro@codesourcery.com>
+
        * infcall.c (run_inferior_call): Remove references to
        suppress_stop_observer.
        * infcmd.c (suppress_stop_observer): Delete.
index 3a405a8..5b4bce5 100644 (file)
@@ -152,6 +152,10 @@ struct thread_info
      or a similar situation when stop_registers should be saved.  */
   int proceed_to_finish;
 
+  /* Nonzero if the thread is being proceeded for an inferior function
+     call.  */
+  int in_infcall;
+
   enum step_over_calls_kind step_over_calls;
 
   /* Nonzero if stopped due to a step command.  */
index 3a11149..16b4320 100644 (file)
@@ -330,10 +330,12 @@ run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc)
 {
   volatile struct gdb_exception e;
   int saved_async = 0;
-  int saved_suppress_resume_observer = suppress_resume_observer;
+  int saved_in_infcall = call_thread->in_infcall;
   ptid_t call_thread_ptid = call_thread->ptid;
   char *saved_target_shortname = xstrdup (target_shortname);
 
+  call_thread->in_infcall = 1;
+
   clear_proceed_status ();
 
   disable_watchpoints_before_interactive_call_start ();
@@ -342,17 +344,12 @@ run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc)
   if (target_can_async_p ())
     saved_async = target_async_mask (0);
 
-  suppress_resume_observer = 1;
-
   TRY_CATCH (e, RETURN_MASK_ALL)
     proceed (real_pc, TARGET_SIGNAL_0, 0);
 
-  /* At this point the current thread may have changed.
-     CALL_THREAD is no longer usable as its thread may have exited.
-     Set it to NULL to prevent its further use.  */
-  call_thread = NULL;
-
-  suppress_resume_observer = saved_suppress_resume_observer;
+  /* At this point the current thread may have changed.  Refresh
+     CALL_THREAD as it could be invalid if its thread has exited.  */
+  call_thread = find_thread_pid (call_thread_ptid);
 
   /* Don't restore the async mask if the target has changed,
      saved_async is for the original target.  */
@@ -369,11 +366,13 @@ run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc)
      of error out of resume()), then we wouldn't need this.  */
   if (e.reason < 0)
     {
-      struct thread_info *tp = find_thread_pid (call_thread_ptid);
-      if (tp != NULL)
-       breakpoint_auto_delete (tp->stop_bpstat);
+      if (call_thread != NULL)
+       breakpoint_auto_delete (call_thread->stop_bpstat);
     }
 
+  if (call_thread != NULL)
+    call_thread->in_infcall = saved_in_infcall;
+
   xfree (saved_target_shortname);
 
   return e;
index 0d5dce9..fcabd3a 100644 (file)
@@ -166,9 +166,6 @@ int stopped_by_random_signal;
    in format described in environ.h.  */
 
 struct gdb_environ *inferior_environ;
-
-/* When set, no calls to target_resumed observer will be made.  */
-int suppress_resume_observer = 0;
 \f
 /* Accessor routines. */
 
index 4d41402..969974c 100644 (file)
@@ -368,9 +368,6 @@ extern int debug_displaced;
 void displaced_step_dump_bytes (struct ui_file *file,
                                 const gdb_byte *buf, size_t len);
 
-/* When set, no calls to target_resumed observer will be made.  */
-extern int suppress_resume_observer;
-
 \f
 /* Possible values for gdbarch_call_dummy_location.  */
 #define ON_STACK 1
index 8466ed6..dfd6e71 100644 (file)
@@ -4451,7 +4451,8 @@ done:
       || last.kind == TARGET_WAITKIND_EXITED
       || (!inferior_thread ()->step_multi
          && !(inferior_thread ()->stop_bpstat
-              && inferior_thread ()->proceed_to_finish)))
+              && inferior_thread ()->proceed_to_finish)
+         && !inferior_thread ()->in_infcall))
     {
       if (!ptid_equal (inferior_ptid, null_ptid))
        observer_notify_normal_stop (inferior_thread ()->stop_bpstat,
@@ -5008,6 +5009,7 @@ struct inferior_status
 
   int breakpoint_proceeded;
   int proceed_to_finish;
+  int in_infcall;
 };
 
 /* Save all of the information associated with the inferior<==>gdb
@@ -5038,6 +5040,7 @@ save_inferior_status (void)
   tp->stop_bpstat = bpstat_copy (tp->stop_bpstat);
   inf_status->breakpoint_proceeded = breakpoint_proceeded;
   inf_status->proceed_to_finish = tp->proceed_to_finish;
+  inf_status->in_infcall = tp->in_infcall;
 
   inf_status->selected_frame_id = get_frame_id (get_selected_frame (NULL));
 
@@ -5088,6 +5091,7 @@ restore_inferior_status (struct inferior_status *inf_status)
   inf_status->stop_bpstat = NULL;
   breakpoint_proceeded = inf_status->breakpoint_proceeded;
   tp->proceed_to_finish = inf_status->proceed_to_finish;
+  tp->in_infcall = inf_status->in_infcall;
 
   if (target_has_stack)
     {
index 131698b..fb4b4d5 100644 (file)
@@ -370,6 +370,17 @@ mi_on_normal_stop (struct bpstats *bs, int print_frame)
 static void
 mi_on_resume (ptid_t ptid)
 {
+  struct thread_info *tp = NULL;
+
+  if (ptid_equal (ptid, minus_one_ptid))
+    tp = inferior_thread ();
+  else
+    tp = find_thread_pid (ptid);
+
+  /* Suppress output while calling an inferior function.  */
+  if (tp->in_infcall)
+    return;
+
   /* To cater for older frontends, emit ^running, but do it only once
      per each command.  We do it here, since at this point we know
      that the target was successfully resumed, and in non-async mode,
index 9dea7c2..52e4428 100644 (file)
@@ -509,8 +509,8 @@ set_running (ptid_t ptid, int running)
            any_started = 1;
          tp->state_ = running ? THREAD_RUNNING : THREAD_STOPPED;
        }
-      if (any_started && !suppress_resume_observer)
-       observer_notify_target_resumed (ptid);      
+      if (any_started)
+       observer_notify_target_resumed (ptid);
     }
   else
     {
@@ -521,7 +521,7 @@ set_running (ptid_t ptid, int running)
       if (running && tp->state_ == THREAD_STOPPED)
        started = 1;
       tp->state_ = running ? THREAD_RUNNING : THREAD_STOPPED;
-      if (started && !suppress_resume_observer)
+      if (started)
        observer_notify_target_resumed (ptid);
     }
 }