While working on another patch I wanted to add some extra debug
information to the attach_command function. This required me to add a
new function to convert the thread_info::state variable to a string.
The new debug might be useful to others, and the state to string
function might be useful in other locations, so I thought I'd merge
it.
const char *cmd, int from_tty,
const qcs_flags &flags);
+/* Return a string representation of STATE. */
+
+extern const char *thread_state_string (enum thread_state state);
+
#endif /* GDBTHREAD_H */
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));
+ }
+
/* Set up the "saved terminal modes" of the inferior
based on what modes we are starting it with. */
target_terminal::init ();
return target_thread_name (thread);
}
+/* See gdbthread.h. */
+
+const char *
+thread_state_string (enum thread_state state)
+{
+ switch (state)
+ {
+ case THREAD_STOPPED:
+ return "STOPPED";
+
+ case THREAD_RUNNING:
+ return "RUNNING";
+
+ case THREAD_EXITED:
+ return "EXITED";
+ }
+
+ gdb_assert_not_reached ("unknown thread state");
+}
+
/* Return a new value for the selected thread's id. Return a value of
0 if no thread is selected. If GLOBAL is true, return the thread's
global number. Otherwise return the per-inferior number. */