Implement TARGET_WAITKIND_NO_RESUMED in the remote protocol

Testing with "maint set target-non-stop on" causes regressions in
tests that rely on TARGET_WAITKIND_NO_RESUMED, which isn't modelled on
the RSP.  In real all-stop, gdbserver detects the situation and
reporst error to GDB, and so the tests (e.g.,
gdb.threads/no-unwaited-for-left.exp) at fail quickly.  But with
"maint set target-non-stop on", GDB instead hangs forever waiting for
a stop reply that never comes, and so the tests take longer to time
out.

This adds a new "N" stop reply packet that maps 1-1 to
TARGET_WAITKIND_NO_RESUMED.

gdb/ChangeLog:
2015-11-30  Pedro Alves  <palves@redhat.com>

	PR 14618
	* NEWS (New remote packets): Mention the N stop reply.
	* remote.c (remote_protocol_features): Add "no-resumed" entry.
	(remote_query_supported): Report no-resumed+ support.
	(remote_parse_stop_reply): Handle 'N'.
	(process_stop_reply): Handle TARGET_WAITKIND_NO_RESUMED.
	(remote_wait_as): Handle 'N' / TARGET_WAITKIND_NO_RESUMED.
	(_initialize_remote): Register "set/show remote
	no-resumed-stop-reply" commands.

gdb/doc/ChangeLog:
2015-11-30  Pedro Alves  <palves@redhat.com>

	PR 14618
	* gdb.texinfo (Stop Reply Packets): Document the N stop reply.
	(Remote Configuration): Add the "set/show remote
	no-resumed-stop-reply" to the available settings table.
	(General Query Packets): Document the "no-resumed" qSupported
	feature.

gdb/gdbserver/ChangeLog:
2015-11-30  Pedro Alves  <palves@redhat.com>

	PR 14618
	* linux-low.c (linux_wait_1): If the last resumed thread is gone,
	report TARGET_WAITKIND_NO_RESUMED.
	* remote-utils.c (prepare_resume_reply): Handle
	TARGET_WAITKIND_NO_RESUMED.
	* server.c (report_no_resumed): New global.
	(handle_query) <qSupported>: Handle "no-resumed+".  Report
	"no-resumed+" support.
	(resume): When the target reports TARGET_WAITKIND_NO_RESUMED, only
	return error if the client doesn't support no-resumed events.
	(push_stop_notification): New function.
	(handle_target_event): Use it.  Report TARGET_WAITKIND_NO_RESUMED
	events if the client supports them.

gdb/testsuite/ChangeLog:
2015-11-30  Pedro Alves  <palves@redhat.com>

	* gdb.threads/no-unwaited-for-left.exp: Remove setup_kfail calls.
This commit is contained in:
Pedro Alves
2015-11-30 16:05:25 +00:00
parent f4836ba964
commit f2faf941ae
11 changed files with 143 additions and 23 deletions

View File

@@ -61,6 +61,10 @@ int report_fork_events;
int report_vfork_events;
int report_exec_events;
int report_thread_events;
/* Whether to report TARGET_WAITKING_NO_RESUMED events. */
static int report_no_resumed;
int non_stop;
int swbreak_feature;
int hwbreak_feature;
@@ -2187,6 +2191,12 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
vCont_supported = 1;
else if (strcmp (p, "QThreadEvents+") == 0)
;
else if (strcmp (p, "no-resumed+") == 0)
{
/* GDB supports and wants TARGET_WAITKIND_NO_RESUMED
events. */
report_no_resumed = 1;
}
else
{
/* Move the unknown features all together. */
@@ -2309,6 +2319,8 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
strcat (own_buf, ";QThreadEvents+");
strcat (own_buf, ";no-resumed+");
/* Reinitialize components as needed for the new connection. */
hostio_handle_new_gdb_connection ();
target_handle_new_gdb_connection ();
@@ -2716,10 +2728,11 @@ resume (struct thread_resume *actions, size_t num_actions)
{
last_ptid = mywait (minus_one_ptid, &last_status, 0, 1);
if (last_status.kind == TARGET_WAITKIND_NO_RESUMED)
if (last_status.kind == TARGET_WAITKIND_NO_RESUMED
&& !report_no_resumed)
{
/* No proper RSP support for this yet. At least return
error. */
/* The client does not support this stop reply. At least
return error. */
sprintf (own_buf, "E.No unwaited-for children left.");
disable_async_io ();
return;
@@ -4332,6 +4345,19 @@ handle_serial_event (int err, gdb_client_data client_data)
return 0;
}
/* Push a stop notification on the notification queue. */
static void
push_stop_notification (ptid_t ptid, struct target_waitstatus *status)
{
struct vstop_notif *vstop_notif = XNEW (struct vstop_notif);
vstop_notif->status = *status;
vstop_notif->ptid = ptid;
/* Push Stop notification. */
notif_push (&notif_stop, (struct notif_event *) vstop_notif);
}
/* Event-loop callback for target events. */
int
@@ -4345,7 +4371,8 @@ handle_target_event (int err, gdb_client_data client_data)
if (last_status.kind == TARGET_WAITKIND_NO_RESUMED)
{
/* No RSP support for this yet. */
if (gdb_connected () && report_no_resumed)
push_stop_notification (null_ptid, &last_status);
}
else if (last_status.kind != TARGET_WAITKIND_IGNORE)
{
@@ -4405,15 +4432,7 @@ handle_target_event (int err, gdb_client_data client_data)
}
}
else
{
struct vstop_notif *vstop_notif = XNEW (struct vstop_notif);
vstop_notif->status = last_status;
vstop_notif->ptid = last_ptid;
/* Push Stop notification. */
notif_push (&notif_stop,
(struct notif_event *) vstop_notif);
}
push_stop_notification (last_ptid, &last_status);
}
/* Be sure to not change the selected thread behind GDB's back.