Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 16/30] Decouple target_interrupt from all-stop/non-stop modes
Date: Fri, 18 Mar 2016 19:37:00 -0000	[thread overview]
Message-ID: <1458328714-4938-17-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1458328714-4938-1-git-send-email-palves@redhat.com>

In non-stop mode, "interrupt" results in a "stop with no 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:
yyyy-mm-dd  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/infcmd.c    |  6 +++++-
 gdb/linux-nat.c | 10 ----------
 gdb/remote.c    | 35 +++++++++--------------------------
 3 files changed, 14 insertions(+), 37 deletions(-)

diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index d687116..3a0265f 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -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,
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 0829bcb..b75153c 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -4463,15 +4463,6 @@ linux_nat_stop (struct target_ops *self, ptid_t ptid)
 }
 
 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)
 {
   /* Unregister from the event loop.  */
@@ -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;
 
diff --git a/gdb/remote.c b/gdb/remote.c
index d43293b..f932455 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -5811,10 +5811,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 ();
@@ -5833,12 +5833,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.  */
@@ -5864,30 +5862,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.  */
-- 
2.5.0


  parent reply	other threads:[~2016-03-18 19:37 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-18 19:19 [PATCH 00/30] Stop throwing exceptions from signal handlers Pedro Alves
2016-03-18 19:18 ` [PATCH 18/30] Fix inconsistent handling of EINTR in ser-*.c backends Pedro Alves
2016-03-18 19:18 ` [PATCH 01/30] Don't rely on immediate_quit in command_line_input Pedro Alves
2016-03-18 19:19 ` [PATCH 02/30] Inline command_loop in read_command_line Pedro Alves
2016-03-18 19:19 ` [PATCH 22/30] Use target_terminal_ours_for_output in infcmd.c Pedro Alves
2016-03-18 19:19 ` [PATCH 29/30] Eliminate immediate_quit Pedro Alves
2016-03-18 19:19 ` [PATCH 14/30] Don't call clear_quit_flag in captured_main Pedro Alves
2016-03-18 19:19 ` [PATCH 19/30] ada-lang.c: Introduce type_as_string and use it Pedro Alves
2016-03-18 19:19 ` [PATCH 30/30] Eliminate target_check_pending_interrupt Pedro Alves
2016-03-18 19:19 ` [PATCH 26/30] Use target_terminal_ours_for_output in MI Pedro Alves
2016-03-18 19:19 ` [PATCH 27/30] TUI: GC tui_target_has_run Pedro Alves
2016-03-18 19:19 ` [PATCH 03/30] TUI: check whether in secondary prompt instead of immediate_quit Pedro Alves
2016-03-18 19:19 ` [PATCH 20/30] Use target_terminal_ours_for_output in cp-support.c Pedro Alves
2016-03-18 19:19 ` [PATCH 28/30] target remote: Don't rely on immediate_quit (introduce quit handlers) Pedro Alves
2016-03-18 19:24 ` [PATCH 17/30] Pass Ctrl-C to the target in target_terminal_inferior Pedro Alves
2016-03-18 19:24 ` [PATCH 25/30] Do target_terminal_ours in query & friends instead of in all callers Pedro Alves
2016-03-18 19:24 ` [PATCH 23/30] Use target_terminal_ours_for_output in warning/internal_error Pedro Alves
2016-03-18 19:25 ` [PATCH 08/30] Fix signal handler/event-loop races Pedro Alves
2016-03-18 19:25 ` [PATCH 04/30] Don't set immediate_quit in prompt_for_continue Pedro Alves
2016-03-18 19:25 ` [PATCH 12/30] Don't call clear_quit_flag in command_handler Pedro Alves
2016-03-18 19:25 ` [PATCH 13/30] Don't call clear_quit_flag in prepare_to_throw_exception Pedro Alves
2016-03-18 19:26 ` [PATCH 10/30] Make Python use a struct serial event Pedro Alves
2016-03-18 19:26 ` [PATCH 24/30] Add missing cleanups to defaulted_query and prompt_for_continue Pedro Alves
2016-03-18 19:26 ` [PATCH 07/30] Introduce a serial interface for select'able events Pedro Alves
2016-03-18 19:27 ` [PATCH 06/30] Remove unused struct serial::name field Pedro Alves
2016-03-18 19:27 ` [PATCH 21/30] Use target_terminal_ours_for_output in exceptions.c Pedro Alves
2016-03-18 19:27 ` [PATCH 15/30] Eliminate clear_quit_flag Pedro Alves
2016-03-18 19:28 ` [PATCH 11/30] Don't call clear_quit_flag after check_quit_flag Pedro Alves
2016-03-18 19:28 ` [PATCH 05/30] Stop remote-fileio.c from throwing from SIGINT handler Pedro Alves
2016-03-18 19:37 ` [PATCH 09/30] Introduce interruptible_select Pedro Alves
2016-03-21 17:59   ` Simon Marchi
2016-03-21 18:33     ` Pedro Alves
2016-03-21 19:48   ` Simon Marchi
2016-03-21 19:49     ` Pedro Alves
2016-03-18 19:37 ` Pedro Alves [this message]
2016-03-21 18:21   ` [PATCH 16/30] Decouple target_interrupt from all-stop/non-stop modes Simon Marchi
2016-03-21 18:24     ` Pedro Alves
2016-03-21 19:52 ` [PATCH 00/30] Stop throwing exceptions from signal handlers Simon Marchi
2016-03-31 14:43   ` Pedro Alves
2016-03-31 18:44     ` Pedro Alves
2016-04-12 16:15     ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1458328714-4938-17-git-send-email-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox