+2015-11-30 Pedro Alves <palves@redhat.com>
+
+ * NEWS (New remote packets): Mention vCtrlC.
+ * remote.c (PACKET_vCtrlC): New enum value.
+ (async_remote_interrupt): Call target_interrupt instead of
+ target_stop.
+ (remote_interrupt_as): Remove 'ptid' parameter.
+ (remote_interrupt_ns): New function.
+ (remote_stop): Adjust.
+ (remote_interrupt): If the target is in non-stop mode, try
+ interrupting with vCtrlC.
+ (initialize_remote): Install set remote ctrl-c packet.
+
2015-11-30 Pedro Alves <palves@redhat.com>
* remote.c (struct remote_state) <remote_watch_data_address,
response can contain the corresponding 'stubfeature'. Set and
show commands can be used to display whether these features are enabled.
+vCtrlC
+ Equivalent to interrupting with the ^C character, but works in
+ non-stop mode.
+
* Extended-remote exec events
** GDB now has support for exec events on extended-remote Linux targets.
+2015-11-30 Pedro Alves <palves@redhat.com>
+
+ * gdb.texinfo (Bootstrapping): Add "interrupting remote targets"
+ anchor.
+ (Packets): Document vCtrlC.
+
2015-11-26 Simon Marchi <simon.marchi@ericsson.com>
* gdb.texinfo (Thread List Format): Mention thread names.
The @samp{vCont} packet is not supported.
@end table
+@anchor{vCtrlC packet}
+@item vCtrlC
+@cindex @samp{vCtrlC} packet
+Interrupt remote target as if a control-C was pressed on the remote
+terminal. This is the equivalent to reacting to the @code{^C}
+(@samp{\003}, the control-C character) character in all-stop mode
+while the target is running, except this works in non-stop mode.
+@xref{interrupting remote targets}, for more info on the all-stop
+variant.
+
+Reply:
+@table @samp
+@item E @var{nn}
+for an error
+@item OK
+for success
+@end table
+
@item vFile:@var{operation}:@var{parameter}@dots{}
@cindex @samp{vFile} packet
Perform a file operation on the target system. For details,
@node Interrupts
@section Interrupts
@cindex interrupts (remote protocol)
+@anchor{interrupting remote targets}
-When a program on the remote target is running, @value{GDBN} may
-attempt to interrupt it by sending a @samp{Ctrl-C}, @code{BREAK} or
-a @code{BREAK} followed by @code{g},
-control of which is specified via @value{GDBN}'s @samp{interrupt-sequence}.
+In all-stop mode, when a program on the remote target is running,
+@value{GDBN} may attempt to interrupt it by sending a @samp{Ctrl-C},
+@code{BREAK} or a @code{BREAK} followed by @code{g}, control of which
+is specified via @value{GDBN}'s @samp{interrupt-sequence}.
The precise meaning of @code{BREAK} is defined by the transport
mechanism and may, in fact, be undefined. @value{GDBN} does not
When Linux kernel receives this sequence from serial port,
it stops execution and connects to gdb.
+In non-stop mode, because packet resumptions are asynchronous
+(@pxref{vCont packet}), @value{GDBN} is always free to send a remote
+command to the remote stub, even when the target is running. For that
+reason, @value{GDBN} instead sends a regular packet (@pxref{vCtrlC
+packet}) with the usual packet framing instead of the single byte
+@code{0x03}.
+
Stubs are not required to recognize these interrupt mechanisms and the
precise meaning associated with receipt of the interrupt is
implementation defined. If the target supports debugging of multiple
+2015-11-30 Pedro Alves <palves@redhat.com>
+
+ * server.c (handle_v_requests): Handle vCtrlC.
+
2015-11-30 Pedro Alves <palves@redhat.com>
* gdbthread.h (find_any_thread_of_pid): Declare.
{
if (!disable_packet_vCont)
{
+ if (strcmp (own_buf, "vCtrlC") == 0)
+ {
+ (*the_target->request_interrupt) ();
+ write_ok (own_buf);
+ return;
+ }
+
if (startswith (own_buf, "vCont;"))
{
require_running (own_buf);
/* Support for query supported vCont actions. */
PACKET_vContSupported,
+ /* Support remote CTRL-C. */
+ PACKET_vCtrlC,
+
PACKET_MAX
};
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "async_remote_interrupt called\n");
- target_stop (inferior_ptid);
+ target_interrupt (inferior_ptid);
}
/* Perform interrupt, if the first attempt did not succeed. Just give
process reports the interrupt. */
static void
-remote_interrupt_as (ptid_t ptid)
+remote_interrupt_as (void)
{
struct remote_state *rs = get_remote_state ();
send_interrupt_sequence ();
}
+/* 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. */
+
+static int
+remote_interrupt_ns (void)
+{
+ struct remote_state *rs = get_remote_state ();
+ char *p = rs->buf;
+ char *endp = rs->buf + get_remote_packet_size ();
+
+ xsnprintf (p, endp - p, "vCtrlC");
+
+ /* In non-stop, we get an immediate OK reply. The stop reply will
+ come in asynchronously by notification. */
+ putpkt (rs->buf);
+ getpkt (&rs->buf, &rs->buf_size, 0);
+
+ switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_vCtrlC]))
+ {
+ case PACKET_OK:
+ break;
+ case PACKET_UNKNOWN:
+ return 0;
+ case PACKET_ERROR:
+ error (_("Interrupting target failed: %s"), rs->buf);
+ }
+
+ return 1;
+}
+
/* Implement the to_stop function for the remote targets. */
static void
{
/* We don't currently have a way to transparently pause the
remote target in all-stop mode. Interrupt it instead. */
- remote_interrupt_as (ptid);
+ remote_interrupt_as ();
}
}
if (remote_debug)
fprintf_unfiltered (gdb_stdlog, "remote_interrupt called\n");
- if (target_is_non_stop_p ())
+ if (non_stop)
{
- /* We don't currently have a way to ^C the remote target in
- non-stop mode. Stop it (with no signal) instead. */
+ /* In non-stop mode, we always stop with no signal instead. */
remote_stop_ns (ptid);
}
else
- remote_interrupt_as (ptid);
+ {
+ /* 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 ();
+ }
}
/* Ask the user what to do when an interrupt is received. */
add_packet_config_cmd (&remote_protocol_packets[PACKET_exec_event_feature],
"exec-event-feature", "exec-event-feature", 0);
+ add_packet_config_cmd (&remote_protocol_packets[PACKET_vCtrlC],
+ "vCtrlC", "ctrl-c", 0);
+
/* Assert that we've registered "set remote foo-packet" commands
for all packet configs. */
{