This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[2/3] broken -thread-info output in non-stop mode, suppress_resume_observer


This gives the suppress_resume_observer a similar treatment.

Instead of suppressing the observer call, we make the observers
themselves know when to ignore the event.

Vladimir, could you please take a look?  I'd appreciate
comments from others too, of course.

-- 
Pedro Alves

2009-03-17  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.

---
 gdb/gdbthread.h    |    4 ++++
 gdb/infcall.c      |   23 +++++++++++------------
 gdb/infcmd.c       |    3 ---
 gdb/inferior.h     |    3 ---
 gdb/infrun.c       |    6 +++++-
 gdb/mi/mi-interp.c |   11 +++++++++++
 gdb/thread.c       |    6 +++---
 7 files changed, 34 insertions(+), 22 deletions(-)

Index: src/gdb/gdbthread.h
===================================================================
--- src.orig/gdb/gdbthread.h	2009-03-17 05:27:45.000000000 +0000
+++ src/gdb/gdbthread.h	2009-03-17 05:51:35.000000000 +0000
@@ -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: src/gdb/infcall.c
===================================================================
--- src.orig/gdb/infcall.c	2009-03-17 05:27:45.000000000 +0000
+++ src/gdb/infcall.c	2009-03-17 05:51:35.000000000 +0000
@@ -330,10 +330,12 @@ run_inferior_call (struct thread_info *c
 {
   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 *c
   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.  CALL_THREAD
+     is no longer usable as its thread may have 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 *c
      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: src/gdb/infcmd.c
===================================================================
--- src.orig/gdb/infcmd.c	2009-03-17 05:49:08.000000000 +0000
+++ src/gdb/infcmd.c	2009-03-17 05:51:35.000000000 +0000
@@ -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;
 
 /* Accessor routines. */
 
Index: src/gdb/inferior.h
===================================================================
--- src.orig/gdb/inferior.h	2009-03-17 05:27:45.000000000 +0000
+++ src/gdb/inferior.h	2009-03-17 05:51:35.000000000 +0000
@@ -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;
-
 
 /* Possible values for gdbarch_call_dummy_location.  */
 #define ON_STACK 1
Index: src/gdb/mi/mi-interp.c
===================================================================
--- src.orig/gdb/mi/mi-interp.c	2009-03-17 05:27:45.000000000 +0000
+++ src/gdb/mi/mi-interp.c	2009-03-17 05:51:35.000000000 +0000
@@ -370,6 +370,17 @@ mi_on_normal_stop (struct bpstats *bs, i
 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: src/gdb/thread.c
===================================================================
--- src.orig/gdb/thread.c	2009-03-17 05:27:45.000000000 +0000
+++ src/gdb/thread.c	2009-03-17 05:51:35.000000000 +0000
@@ -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);
     }
 }
Index: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c	2009-03-17 05:47:32.000000000 +0000
+++ src/gdb/infrun.c	2009-03-17 05:52:06.000000000 +0000
@@ -4442,7 +4442,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,
@@ -4999,6 +5000,7 @@ struct inferior_status
 
   int breakpoint_proceeded;
   int proceed_to_finish;
+  int in_infcall;
 };
 
 /* Save all of the information associated with the inferior<==>gdb
@@ -5029,6 +5031,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));
 
@@ -5079,6 +5082,7 @@ restore_inferior_status (struct inferior
   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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]