gdb/infrun: add reason parameter to stop_all_threads
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Nov 2021 21:18:56 +0000 (16:18 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Mon, 17 Jan 2022 16:41:44 +0000 (11:41 -0500)
Add a "reason" parameter, only used to show in debug messages what is
the reason for stopping all threads.  This helped me understand the
debug logs while adding some new uses of stop_all_threads, so I am
proposing to merge it.

Change-Id: I66c8c335ebf41836a7bc3d5fe1db92c195f65e55

gdb/infcmd.c
gdb/infrun.c
gdb/infrun.h
gdb/remote.c

index c4b7ad0b7b942fff8e66d0c455d6d9b2fc1270f1..e2ac750ad12604431042ebaf74b574f1a0e8e087 100644 (file)
@@ -2525,7 +2525,7 @@ attach_post_wait (int from_tty, enum attach_post_wait_mode mode)
        {
          struct thread_info *lowest = inferior_thread ();
 
-         stop_all_threads ();
+         stop_all_threads ("attaching");
 
          /* It's not defined which thread will report the attach
             stop.  For consistency, always select the thread with
index 474c0c9277068875d9102b04a2af411bdacd8574..9bc8bcaaf303d38f0d99e73f9111ba47b278236f 100644 (file)
@@ -2385,7 +2385,7 @@ resume_1 (enum gdb_signal sig)
          /* Fallback to stepping over the breakpoint in-line.  */
 
          if (target_is_non_stop_p ())
-           stop_all_threads ();
+           stop_all_threads ("displaced stepping falling back on inline stepping");
 
          set_step_over_info (regcache->aspace (),
                              regcache_read_pc (regcache), 0, tp->global_num);
@@ -4956,7 +4956,7 @@ handle_one (const wait_one_event &event)
 /* See infrun.h.  */
 
 void
-stop_all_threads (void)
+stop_all_threads (const char *reason)
 {
   /* We may need multiple passes to discover all threads.  */
   int pass;
@@ -4964,7 +4964,7 @@ stop_all_threads (void)
 
   gdb_assert (exists_non_stop_target ());
 
-  infrun_debug_printf ("starting");
+  INFRUN_SCOPED_DEBUG_START_END ("reason=%s", reason);
 
   scoped_restore_current_thread restore_thread;
 
@@ -8016,7 +8016,7 @@ stop_waiting (struct execution_control_state *ecs)
   /* If all-stop, but there exists a non-stop target, stop all
      threads now that we're presenting the stop to the user.  */
   if (!non_stop && exists_non_stop_target ())
-    stop_all_threads ();
+    stop_all_threads ("presenting stop to user in all-stop");
 }
 
 /* Like keep_going, but passes the signal to the inferior, even if the
@@ -8118,7 +8118,7 @@ keep_going_pass_signal (struct execution_control_state *ecs)
         we're about to step over, otherwise other threads could miss
         it.  */
       if (step_over_info_valid_p () && target_is_non_stop_p ())
-       stop_all_threads ();
+       stop_all_threads ("starting in-line step-over");
 
       /* Stop stepping if inserting breakpoints fails.  */
       try
index 3343bce57360057d7d44812ed50de8c19455ee65..36591417ca6e6a72d3117af058e8731c9ffa5c18 100644 (file)
@@ -38,8 +38,8 @@ extern bool debug_infrun;
 
 /* Print "infrun" start/end debug statements.  */
 
-#define INFRUN_SCOPED_DEBUG_START_END(msg) \
-  scoped_debug_start_end (debug_infrun, "infrun", msg)
+#define INFRUN_SCOPED_DEBUG_START_END(fmt, ...) \
+  scoped_debug_start_end (debug_infrun, "infrun", fmt, ##__VA_ARGS__)
 
 /* Print "infrun" enter/exit debug statements.  */
 
@@ -137,8 +137,11 @@ extern void set_last_target_status (process_stratum_target *target, ptid_t ptid,
    target_wait().  */
 extern void nullify_last_target_wait_ptid ();
 
-/* Stop all threads.  Only returns after everything is halted.  */
-extern void stop_all_threads (void);
+/* Stop all threads.  Only returns after everything is halted.
+
+   REASON is a string indicating the reason why we stop all threads, used in
+   debug messages.  */
+extern void stop_all_threads (const char *reason);
 
 extern void prepare_for_detach (void);
 
index aff52167edea77fdc84d7d6e1e817901b8ceb7ef..61487456ce8b2f107467a750aa67cc4870834f72 100644 (file)
@@ -4595,7 +4595,7 @@ remote_target::process_initial_stop_replies (int from_tty)
      the inferiors.  */
   if (!non_stop)
     {
-      stop_all_threads ();
+      stop_all_threads ("remote connect in all-stop");
 
       /* If all threads of an inferior were already stopped, we
         haven't setup the inferior yet.  */
This page took 0.033446 seconds and 4 git commands to generate.