aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/infcmd.c19
-rw-r--r--gdb/infrun.c3
-rw-r--r--gdb/infrun.h26
3 files changed, 37 insertions, 11 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 53c9e3d..e909d4d 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -238,6 +238,9 @@ post_create_inferior (int from_tty)
/* Be sure we own the terminal in case write operations are performed. */
target_terminal::ours_for_output ();
+ infrun_debug_show_threads ("threads in the newly created inferior",
+ current_inferior ()->non_exited_threads ());
+
/* If the target hasn't taken care of this already, do it now.
Targets which need to access registers during to_open,
to_create_inferior, or to_attach should do it earlier; but many
@@ -454,6 +457,9 @@ run_command_1 (const char *args, int from_tty, enum run_how run_how)
shouldn't refer to run_target again. */
run_target = NULL;
+ infrun_debug_show_threads ("immediately after create_process",
+ current_inferior ()->non_exited_threads ());
+
/* We're starting off a new process. When we get out of here, in
non-stop mode, finish the state of all threads of that process,
but leave other threads alone, as they may be stopped in internal
@@ -2589,17 +2595,8 @@ attach_command (const char *args, int from_tty)
shouldn't refer to attach_target again. */
attach_target = NULL;
- if (debug_infrun)
- {
- infrun_debug_printf ("immediately after attach:");
- for (thread_info *thread : inferior->non_exited_threads ())
- infrun_debug_printf (" thread %s, executing = %d, resumed = %d, "
- "state = %s",
- thread->ptid.to_string ().c_str (),
- thread->executing (),
- thread->resumed (),
- thread_state_string (thread->state));
- }
+ infrun_debug_show_threads ("immediately after attach",
+ current_inferior ()->non_exited_threads ());
/* Enable async mode if it is supported by the target. */
if (target_can_async_p ())
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 531d398..02c98b5 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -5063,6 +5063,9 @@ stop_all_threads (const char *reason, inferior *inf)
INFRUN_SCOPED_DEBUG_START_END ("reason=%s, inf=%d", reason,
inf != nullptr ? inf->num : -1);
+ infrun_debug_show_threads ("non-exited threads",
+ all_non_exited_threads ());
+
scoped_restore_current_thread restore_thread;
/* Enable thread events on relevant targets. */
diff --git a/gdb/infrun.h b/gdb/infrun.h
index 9685f3a..0c7c55e 100644
--- a/gdb/infrun.h
+++ b/gdb/infrun.h
@@ -48,6 +48,32 @@ extern bool debug_infrun;
#define INFRUN_SCOPED_DEBUG_ENTER_EXIT \
scoped_debug_enter_exit (debug_infrun, "infrun")
+/* A infrun debug helper routine to print out all the threads in the set
+ THREADS (which should be a range type that returns thread_info*
+ objects).
+
+ The TITLE is a string that is printed before the list of threads.
+
+ Output is only produced when 'set debug infrun on'. */
+
+template<typename ThreadRange>
+static inline void
+infrun_debug_show_threads (const char *title, ThreadRange threads)
+{
+ if (debug_infrun)
+ {
+ infrun_debug_printf ("%s:", title);
+ for (thread_info *thread : threads)
+ infrun_debug_printf (" thread %s, executing = %d, resumed = %d, "
+ "state = %s",
+ thread->ptid.to_string ().c_str (),
+ thread->executing (),
+ thread->resumed (),
+ thread_state_string (thread->state));
+ }
+}
+
+
/* Nonzero if we want to give control to the user when we're notified
of shared library events by the dynamic linker. */
extern int stop_on_solib_events;