aboutsummaryrefslogtreecommitdiff
path: root/gdb/thread.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-10-10 16:45:51 +0100
committerPedro Alves <palves@redhat.com>2017-10-10 17:01:25 +0100
commit65630365f7d073430e62b4fe65f34dcdc0a4b05e (patch)
treea719688b221a7f234a045feb5a7fcee83ed93d95 /gdb/thread.c
parentbf4692711232eb96cd840f96d88897a2746d8190 (diff)
downloadgdb-65630365f7d073430e62b4fe65f34dcdc0a4b05e.zip
gdb-65630365f7d073430e62b4fe65f34dcdc0a4b05e.tar.gz
gdb-65630365f7d073430e62b4fe65f34dcdc0a4b05e.tar.bz2
Eliminate catch_exceptions/catch_exceptions_with_msg
This patch gets rid of catch_exceptions / catch_exceptions_with_msg. The latter is done mostly by getting rid of the three remaining vestigial libgdb wrapper functions, which are really pointless nowadays. This results in a good number of simplifications. (I checked that Insight doesn't use those functions.) The gdb.mi/mi-pthreads.exp change is necessary because this actually fixes a bug, IMO -- the patch stops MI's -thread-select causing output on the CLI stream. I.e., before: -thread-select 123456789 &"Thread ID 123456789 not known.\n" ^error,msg="Thread ID 123456789 not known." (gdb) After: -thread-select 123456789 ^error,msg="Thread ID 123456789 not known." (gdb) gdb/ChangeLog 2017-10-10 Pedro Alves <palves@redhat.com> Tom Tromey <tom@tromey.com> * breakpoint.c (struct captured_breakpoint_query_args) (do_captured_breakpoint_query, gdb_breakpoint_query): Delete. (print_breakpoint): New. * breakpoint.h (print_breakpoint): Declare. * common/common-exceptions.h (enum return_reason): Remove references to catch_exceptions. * exceptions.c (catch_exceptions, catch_exceptions_with_msg): Delete. * exceptions.h (catch_exceptions_ftype, catch_exceptions) (catch_exception_ftype, catch_exceptions_with_msg): Delete. * gdb.h: Delete. * gdbthread.h (thread_select): Declare. * mi/mi-cmd-break.c: Don't include gdb.h. (breakpoint_notify): Use print_breakpoint. * mi/mi-cmd-catch.c: Don't include gdb.h. * mi/mi-interp.c: Don't include gdb.h. (mi_print_breakpoint_for_event): New. (mi_breakpoint_created, mi_breakpoint_modified): Use mi_print_breakpoint_for_event. * mi/mi-main.c: Don't include gdb.h. (mi_cmd_thread_select): Parse the global thread ID here. Use thread_select instead of gdb_thread_select. (mi_cmd_thread_list_ids): Output "thread-ids" tuple here instead of using gdb_list_thread_ids. * remote-fileio.c (do_remote_fileio_request): Change type. Reply FILEIO_ENOSYS here. (remote_fileio_request): Use TRY/CATCH instead of catch_exceptions. * symfile-mem.c (struct symbol_file_add_from_memory_args) (symbol_file_add_from_memory_wrapper): Delete. (add_vsyscall_page): Use TRY/CATCH instead of catch_exceptions. * thread.c: Don't include gdb.h. (do_captured_list_thread_ids, gdb_list_thread_ids): Delete. (thread_alive): Use thread_select. (do_captured_thread_select): Delete, parts salvaged as ... (thread_select): ... this new function. (gdb_thread_select): Delete. gdb/testsuite/ChangeLog 2017-10-10 Pedro Alves <palves@redhat.com> * gdb.mi/mi-pthreads.exp (check_mi_thread_command_set): Don't expect CLI output.
Diffstat (limited to 'gdb/thread.c')
-rw-r--r--gdb/thread.c86
1 files changed, 5 insertions, 81 deletions
diff --git a/gdb/thread.c b/gdb/thread.c
index 91c077a..1668862 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, void *arg)
-{
- 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, NULL,
- 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,26 +1941,11 @@ show_print_thread_events (struct ui_file *file, int from_tty,
value);
}
-static int
-do_captured_thread_select (struct ui_out *uiout, void *tidstr_v)
-{
- const char *tidstr = (const char *) tidstr_v;
- 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);
- }
+/* See gdbthread.h. */
+void
+thread_select (const char *tidstr, thread_info *tp)
+{
if (!thread_alive (tp))
error (_("Thread ID %s has terminated."), tidstr);
@@ -2021,8 +1956,6 @@ do_captured_thread_select (struct ui_out *uiout, void *tidstr_v)
/* 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. */
@@ -2067,15 +2000,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, do_captured_thread_select, 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. */