aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2021-01-27 18:20:35 +0000
committerAndrew Burgess <andrew.burgess@embecosm.com>2021-01-28 20:04:48 +0000
commit0f93c3a25bbfbdfeea92f27f591c88e7daeb9a70 (patch)
tree00e62ee66218a7247d296c5ea6c8a0126cded1a9
parentf237f998d1168139d599c550d54169cd8f94052d (diff)
downloadgdb-0f93c3a25bbfbdfeea92f27f591c88e7daeb9a70.zip
gdb-0f93c3a25bbfbdfeea92f27f591c88e7daeb9a70.tar.gz
gdb-0f93c3a25bbfbdfeea92f27f591c88e7daeb9a70.tar.bz2
gdb: remove unneeded switch_to_thread from thr_try_catch_cmd
I spotted that every time thr_try_catch_cmd is called GDB has already switched to the required thread. The call to switch_to_thread at the head of thr_try_catch_cmd is therefore redundant. This commit replaces the call to switch_to_thread with an assertion that we already have the required thread selected. I also extended the header comment on thr_try_catch_cmd to make it clearer when this function could throw an exception. There should be no user visible changes after this commit. gdb/ChangeLog: * thread.c (thr_try_catch_cmd): Replace swith_to_thread with an assert. Extend the header comment.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/thread.c7
2 files changed, 9 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e108274..1de9d30 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-01-28 Andrew Burgess <andrew.burgess@embecosm.com>
+ * thread.c (thr_try_catch_cmd): Replace swith_to_thread with an
+ assert. Extend the header comment.
+
+2021-01-28 Andrew Burgess <andrew.burgess@embecosm.com>
+
* Makefile.in (SUBDIR_TUI_SRCS): Add tui/tui-location.c.
(HFILES_NO_SRCDIR): Add tui/tui-location.h.
* tui/tui-data.h (TUI_STATUS_WIN): Define.
diff --git a/gdb/thread.c b/gdb/thread.c
index 899c211..8210706 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1466,15 +1466,16 @@ tp_array_compar_descending (const thread_info_ref &a, const thread_info_ref &b)
return (a->per_inf_num > b->per_inf_num);
}
-/* Switch to thread THR and execute CMD.
+/* Assuming that THR is the current thread, execute CMD.
FLAGS.QUIET controls the printing of the thread information.
- FLAGS.CONT and FLAGS.SILENT control how to handle errors. */
+ FLAGS.CONT and FLAGS.SILENT control how to handle errors. Can throw an
+ exception if !FLAGS.SILENT and !FLAGS.CONT and CMD fails. */
static void
thr_try_catch_cmd (thread_info *thr, const char *cmd, int from_tty,
const qcs_flags &flags)
{
- switch_to_thread (thr);
+ gdb_assert (is_current_thread (thr));
/* The thread header is computed before running the command since
the command can change the inferior, which is not permitted