This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 5/5] Add TARGET_WAITKIND_NO_RESUMED support to the RSP.
- From: Pedro Alves <palves at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: teawater at gmail dot com, luis_gustavo at mentor dot com
- Date: Thu, 23 Jan 2014 14:10:09 +0000
- Subject: [PATCH 5/5] Add TARGET_WAITKIND_NO_RESUMED support to the RSP.
- Authentication-results: sourceware.org; auth=none
- References: <52E12075 dot 3040601 at redhat dot com> <1390486209-8167-1-git-send-email-palves at redhat dot com>
Makes gdb.threads/no-unwaited-for-left.exp pass.
WIP.
---
gdb/gdbserver/remote-utils.c | 3 +++
gdb/gdbserver/server.c | 30 ++++++++++++++++++------------
gdb/remote.c | 13 ++++++++++---
3 files changed, 31 insertions(+), 15 deletions(-)
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 3b88995..f5acd12 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -1429,6 +1429,9 @@ prepare_resume_reply (char *buf, ptid_t ptid,
else
sprintf (buf, "X%02x", status->value.sig);
break;
+ case TARGET_WAITKIND_NO_RESUMED:
+ sprintf (buf, "N");
+ break;
default:
error ("unhandled waitkind");
break;
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 0f50afe..e779793 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -2321,7 +2321,8 @@ 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
+ && 0 /* XXX Check if GDB supports this. */)
{
/* No proper RSP support for this yet. At least return
error. */
@@ -3847,6 +3848,18 @@ handle_serial_event (int err, gdb_client_data client_data)
return 0;
}
+static void
+push_stop_notification (ptid_t ptid, struct target_waitstatus *status)
+{
+ struct vstop_notif *vstop_notif
+ = xmalloc (sizeof (struct vstop_notif));
+
+ vstop_notif->status = *status;
+ vstop_notif->ptid = ptid;
+ /* Push Stop notification. */
+ notif_push (¬if_stop, (struct notif_event *) vstop_notif);
+}
+
/* Event-loop callback for target events. */
int
@@ -3860,7 +3873,9 @@ 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 ()
+ && 1 /* XXX Check here if GDB supports for this stop reply. */)
+ push_stop_notification (null_ptid, &last_status);
}
else if (last_status.kind != TARGET_WAITKIND_IGNORE)
{
@@ -3915,16 +3930,7 @@ handle_target_event (int err, gdb_client_data client_data)
target_pid_to_str (last_ptid));
}
else
- {
- struct vstop_notif *vstop_notif
- = xmalloc (sizeof (struct vstop_notif));
-
- vstop_notif->status = last_status;
- vstop_notif->ptid = last_ptid;
- /* Push Stop notification. */
- notif_push (¬if_stop,
- (struct notif_event *) vstop_notif);
- }
+ push_stop_notification (last_ptid, &last_status);
}
/* Be sure to not change the selected inferior behind GDB's back.
diff --git a/gdb/remote.c b/gdb/remote.c
index d886929..94552a3 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -5838,6 +5838,10 @@ Packet: '%s'\n"),
event->ptid = pid_to_ptid (pid);
}
break;
+ case 'N':
+ event->ws.kind = TARGET_WAITKIND_NO_RESUMED;
+ event->ptid = minus_one_ptid;
+ break;
}
if (non_stop && ptid_equal (event->ptid, null_ptid))
@@ -5939,7 +5943,8 @@ process_stop_reply (struct stop_reply *stop_reply,
ptid = inferior_ptid;
if (status->kind != TARGET_WAITKIND_EXITED
- && status->kind != TARGET_WAITKIND_SIGNALLED)
+ && status->kind != TARGET_WAITKIND_SIGNALLED
+ && status->kind != TARGET_WAITKIND_NO_RESUMED)
{
struct remote_state *rs = get_remote_state ();
@@ -6108,7 +6113,7 @@ remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
remote_fileio_request (buf, rs->ctrlc_pending_p);
rs->ctrlc_pending_p = 0;
break;
- case 'T': case 'S': case 'X': case 'W':
+ case 'N': case 'T': case 'S': case 'X': case 'W':
{
struct stop_reply *stop_reply
= (struct stop_reply *) remote_notif_parse (¬if_client_stop,
@@ -6152,7 +6157,9 @@ remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
break;
}
- if (status->kind == TARGET_WAITKIND_IGNORE)
+ if (status->kind == TARGET_WAITKIND_NO_RESUMED)
+ return minus_one_ptid;
+ else if (status->kind == TARGET_WAITKIND_IGNORE)
{
/* Nothing interesting happened. If we're doing a non-blocking
poll, we're done. Otherwise, go back to waiting. */
--
1.7.11.7