Decouple target_interrupt from all-stop/non-stop modes
authorPedro Alves <palves@redhat.com>
Tue, 12 Apr 2016 15:49:31 +0000 (16:49 +0100)
committerPedro Alves <palves@redhat.com>
Tue, 12 Apr 2016 15:56:39 +0000 (16:56 +0100)
In non-stop mode, "interrupt" results in a "stop with no signal",
while in all-stop mode, it results in a remote interrupt request /
stop with SIGINT.  This is currently implemented in both the Linux and
remote target backends.  Move it to the core code instead, making
target_interrupt specifically always about "Interrupting as if with
Ctrl-C", just like it is documented.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* infcmd.c (interrupt_target_1): Call target_stop is in non-stop
mode.
* linux-nat.c (linux_nat_interrupt): Delete.
(linux_nat_add_target): Don't install linux_nat_interrupt.
* remote.c (remote_interrupt_ns): Change return type to void.
Throw error if interrupting the target is not supported.
(remote_interrupt): Don't call the remote_stop_ns/remote_stop_as.

gdb/ChangeLog
gdb/infcmd.c
gdb/linux-nat.c
gdb/remote.c

index 7f0df5f89a4392fa0897193587f85f9a2eb21a75..2a05df21525cc9979c847c38a9b565f1a29f2d63 100644 (file)
@@ -1,3 +1,13 @@
+2016-04-12  Pedro Alves  <palves@redhat.com>
+
+       * infcmd.c (interrupt_target_1): Call target_stop is in non-stop
+       mode.
+       * linux-nat.c (linux_nat_interrupt): Delete.
+       (linux_nat_add_target): Don't install linux_nat_interrupt.
+       * remote.c (remote_interrupt_ns): Change return type to void.
+       Throw error if interrupting the target is not supported.
+       (remote_interrupt): Don't call the remote_stop_ns/remote_stop_as.
+
 2016-04-12  Pedro Alves  <palves@redhat.com>
 
        * defs.h (clear_quit_flag): Remove declaration.
index d68711663fcf7069319fdd744e1b90a7691b0fcb..3a0265f1957846b313ae08fd81b092a5ad4ff935 100644 (file)
@@ -3013,7 +3013,11 @@ interrupt_target_1 (int all_threads)
     ptid = minus_one_ptid;
   else
     ptid = inferior_ptid;
-  target_interrupt (ptid);
+
+  if (non_stop)
+    target_stop (ptid);
+  else
+    target_interrupt (ptid);
 
   /* Tag the thread as having been explicitly requested to stop, so
      other parts of gdb know not to resume this thread automatically,
index 0829bcb5072c7ff6177cb10dee47b8741ede4d34..b75153ce983f2bc16f5e592bde8f408313a97018 100644 (file)
@@ -4462,15 +4462,6 @@ linux_nat_stop (struct target_ops *self, ptid_t ptid)
   iterate_over_lwps (ptid, linux_nat_stop_lwp, NULL);
 }
 
-static void
-linux_nat_interrupt (struct target_ops *self, ptid_t ptid)
-{
-  if (non_stop)
-    iterate_over_lwps (ptid, linux_nat_stop_lwp, NULL);
-  else
-    linux_ops->to_interrupt (linux_ops, ptid);
-}
-
 static void
 linux_nat_close (struct target_ops *self)
 {
@@ -4672,7 +4663,6 @@ linux_nat_add_target (struct target_ops *t)
   t->to_close = linux_nat_close;
 
   t->to_stop = linux_nat_stop;
-  t->to_interrupt = linux_nat_interrupt;
 
   t->to_supports_multi_process = linux_nat_supports_multi_process;
 
index 443beacab92f401d989247142b51ce62eca80c09..1bd2bcfe29660bd36617f289f2facc3a4a4c573a 100644 (file)
@@ -5813,10 +5813,10 @@ remote_interrupt_as (void)
 
 /* Non-stop version of target_interrupt.  Uses `vCtrlC' to interrupt
    the remote target.  It is undefined which thread of which process
-   reports the interrupt.  Returns true if the packet is supported by
-   the server, false otherwise.  */
+   reports the interrupt.  Throws an error if the packet is not
+   supported by the server.  */
 
-static int
+static void
 remote_interrupt_ns (void)
 {
   struct remote_state *rs = get_remote_state ();
@@ -5835,12 +5835,10 @@ remote_interrupt_ns (void)
     case PACKET_OK:
       break;
     case PACKET_UNKNOWN:
-      return 0;
+      error (_("No support for interrupting the remote target."));
     case PACKET_ERROR:
       error (_("Interrupting target failed: %s"), rs->buf);
     }
-
-  return 1;
 }
 
 /* Implement the to_stop function for the remote targets.  */
@@ -5866,30 +5864,15 @@ remote_stop (struct target_ops *self, ptid_t ptid)
 static void
 remote_interrupt (struct target_ops *self, ptid_t ptid)
 {
+  struct remote_state *rs = get_remote_state ();
+
   if (remote_debug)
     fprintf_unfiltered (gdb_stdlog, "remote_interrupt called\n");
 
-  if (non_stop)
-    {
-      /* In non-stop mode, we always stop with no signal instead.  */
-      remote_stop_ns (ptid);
-    }
+  if (target_is_non_stop_p ())
+    remote_interrupt_ns ();
   else
-    {
-      /* In all-stop, we emulate ^C-ing the remote target's
-        terminal.  */
-      if (target_is_non_stop_p ())
-       {
-         if (!remote_interrupt_ns ())
-           {
-             /* No support for ^C-ing the remote target.  Stop it
-                (with no signal) instead.  */
-             remote_stop_ns (ptid);
-           }
-       }
-      else
-       remote_interrupt_as ();
-    }
+    remote_interrupt_as ();
 }
 
 /* Ask the user what to do when an interrupt is received.  */
This page took 0.056219 seconds and 4 git commands to generate.