diff options
Diffstat (limited to 'gdb/thread.c')
-rw-r--r-- | gdb/thread.c | 88 |
1 files changed, 3 insertions, 85 deletions
diff --git a/gdb/thread.c b/gdb/thread.c index 7deebf2..33c98e4 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -30,7 +30,6 @@ #include "command.h" #include "gdbcmd.h" #include "regcache.h" -#include "gdb.h" #include "btrace.h" #include <ctype.h> @@ -720,50 +719,6 @@ any_live_thread_of_process (int pid) return tp_executing; } -/* Print a list of thread ids currently known, and the total number of - threads. To be used from within catch_errors. */ -static int -do_captured_list_thread_ids (struct ui_out *uiout) -{ - struct thread_info *tp; - int num = 0; - int current_thread = -1; - - update_thread_list (); - - { - ui_out_emit_tuple tuple_emitter (uiout, "thread-ids"); - - for (tp = thread_list; tp; tp = tp->next) - { - if (tp->state == THREAD_EXITED) - continue; - - if (tp->ptid == inferior_ptid) - current_thread = tp->global_num; - - num++; - uiout->field_int ("thread-id", tp->global_num); - } - } - - if (current_thread != -1) - uiout->field_int ("current-thread-id", current_thread); - uiout->field_int ("number-of-threads", num); - return GDB_RC_OK; -} - -/* Official gdblib interface function to get a list of thread ids and - the total number. */ -enum gdb_rc -gdb_list_thread_ids (struct ui_out *uiout, char **error_message) -{ - if (catch_exceptions_with_msg (uiout, do_captured_list_thread_ids, - error_message, RETURN_MASK_ALL) < 0) - return GDB_RC_FAIL; - return GDB_RC_OK; -} - /* Return true if TP is an active thread. */ static int thread_alive (struct thread_info *tp) @@ -1885,13 +1840,8 @@ thread_command (char *tidstr, int from_tty) else { ptid_t previous_ptid = inferior_ptid; - enum gdb_rc result; - - result = gdb_thread_select (current_uiout, tidstr, NULL); - /* If thread switch did not succeed don't notify or print. */ - if (result == GDB_RC_FAIL) - return; + thread_select (tidstr, parse_thread_id (tidstr, NULL)); /* Print if the thread has not changed, otherwise an event will be sent. */ @@ -1991,25 +1941,9 @@ show_print_thread_events (struct ui_file *file, int from_tty, value); } -static int -do_captured_thread_select (struct ui_out *uiout, const char *tidstr) +void +thread_select (const char *tidstr, thread_info *tp) { - struct thread_info *tp; - - if (uiout->is_mi_like_p ()) - { - int num = value_as_long (parse_and_eval (tidstr)); - - tp = find_thread_global_id (num); - if (tp == NULL) - error (_("Thread ID %d not known."), num); - } - else - { - tp = parse_thread_id (tidstr, NULL); - gdb_assert (tp != NULL); - } - if (!thread_alive (tp)) error (_("Thread ID %s has terminated."), tidstr); @@ -2020,8 +1954,6 @@ do_captured_thread_select (struct ui_out *uiout, const char *tidstr) /* Since the current thread may have changed, see if there is any exited thread we can now delete. */ prune_threads (); - - return GDB_RC_OK; } /* Print thread and frame switch command response. */ @@ -2066,20 +1998,6 @@ print_selected_thread_frame (struct ui_out *uiout, } } -enum gdb_rc -gdb_thread_select (struct ui_out *uiout, char *tidstr, char **error_message) -{ - if (catch_exceptions_with_msg - (uiout, - [&] (struct ui_out *inner_uiout) - { - return do_captured_thread_select (inner_uiout, tidstr); - }, - error_message, RETURN_MASK_ALL) < 0) - return GDB_RC_FAIL; - return GDB_RC_OK; -} - /* Update the 'threads_executing' global based on the threads we know about right now. */ |