aboutsummaryrefslogtreecommitdiff
path: root/gdb/infrun.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2020-01-10 20:06:14 +0000
committerPedro Alves <palves@redhat.com>2020-01-10 20:06:14 +0000
commit2f4fcf00399bc0ad5a4fed6b530128e8be4f40da (patch)
tree2808b2e8b1b5992b8ece704ca03bb0b874653c24 /gdb/infrun.c
parent121b3efd49f98e4049281b3ba7a258e650e40b38 (diff)
downloadgdb-2f4fcf00399bc0ad5a4fed6b530128e8be4f40da.zip
gdb-2f4fcf00399bc0ad5a4fed6b530128e8be4f40da.tar.gz
gdb-2f4fcf00399bc0ad5a4fed6b530128e8be4f40da.tar.bz2
Require always-non-stop for multi-target resumptions
Currently, we can only support resuming multiple targets at the same time if all targets are in non-stop mode (or user-visible all-stop mode with target backend in non-stop mode). This patch makes GDB error out if the user tries to resume more than one target at the same time and one of the resumed targets isn't in non-stop mode: (gdb) info inferiors Num Description Connection Executable 1 process 15303 1 (native) a.out * 2 process 15286 2 (extended-remote :9999) a.out (gdb) set schedule-multiple on (gdb) c Continuing. Connection 2 (extended-remote :9999) does not support multi-target resumption. This is here later in the series instead of in the main multi-target patch because it depends the previous patch, which added process_stratum_target::connection_string(). gdb/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * infrun.c: Include "target-connection.h". (check_multi_target_resumption): New. (proceed): Call it. * target-connection.c (make_target_connection_string): Make extern. * target-connection.h (make_target_connection_string): Declare.
Diffstat (limited to 'gdb/infrun.c')
-rw-r--r--gdb/infrun.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 707c053..a0583a8 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -28,6 +28,7 @@
#include "gdbcore.h"
#include "gdbcmd.h"
#include "target.h"
+#include "target-connection.h"
#include "gdbthread.h"
#include "annotate.h"
#include "symfile.h"
@@ -2881,6 +2882,61 @@ commit_resume_all_targets ()
}
}
+/* Check that all the targets we're about to resume are in non-stop
+ mode. Ideally, we'd only care whether all targets support
+ target-async, but we're not there yet. E.g., stop_all_threads
+ doesn't know how to handle all-stop targets. Also, the remote
+ protocol in all-stop mode is synchronous, irrespective of
+ target-async, which means that things like a breakpoint re-set
+ triggered by one target would try to read memory from all targets
+ and fail. */
+
+static void
+check_multi_target_resumption (process_stratum_target *resume_target)
+{
+ if (!non_stop && resume_target == nullptr)
+ {
+ scoped_restore_current_thread restore_thread;
+
+ /* This is used to track whether we're resuming more than one
+ target. */
+ process_stratum_target *first_connection = nullptr;
+
+ /* The first inferior we see with a target that does not work in
+ always-non-stop mode. */
+ inferior *first_not_non_stop = nullptr;
+
+ for (inferior *inf : all_non_exited_inferiors (resume_target))
+ {
+ switch_to_inferior_no_thread (inf);
+
+ if (!target_has_execution)
+ continue;
+
+ process_stratum_target *proc_target
+ = current_inferior ()->process_target();
+
+ if (!target_is_non_stop_p ())
+ first_not_non_stop = inf;
+
+ if (first_connection == nullptr)
+ first_connection = proc_target;
+ else if (first_connection != proc_target
+ && first_not_non_stop != nullptr)
+ {
+ switch_to_inferior_no_thread (first_not_non_stop);
+
+ proc_target = current_inferior ()->process_target();
+
+ error (_("Connection %d (%s) does not support "
+ "multi-target resumption."),
+ proc_target->connection_number,
+ make_target_connection_string (proc_target).c_str ());
+ }
+ }
+ }
+}
+
/* Basic routine for continuing the program in various fashions.
ADDR is the address to resume at, or -1 for resume where stopped.
@@ -2931,6 +2987,8 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal)
process_stratum_target *resume_target
= user_visible_resume_target (resume_ptid);
+ check_multi_target_resumption (resume_target);
+
if (addr == (CORE_ADDR) -1)
{
if (pc == cur_thr->suspend.stop_pc