[PATCH 8/8] RSP notification 'Test'.
Yao Qi
yao@codesourcery.com
Tue Dec 11 06:41:00 GMT 2012
This patch is only to present how do we add a new type of notifcation
in the future, and to test two types of notifications coexist together
for testing purpose. In each time GDB fetches registers, a new event
is pushed, and GDBserver will send a notification %Test to GDB.
This patch is not for committing to CVS trunk.
gdb/gdbserver:
2012-12-11 Yao Qi <yao@codesourcery.com>
* linux-low.c: Include "notif.h".
(linux_fetch_registers): Call notif_push.
* notif.c (notif_reply_test): New.
(notif_test): New variable.
(notifs): Add new element 'notif_test'.
notif.h (notif_test) Declaration.
gdb:
2012-12-11 Yao Qi <yao@codesourcery.com>
* remote-notif.c (remote_notif_parse_test): New.
(remote_notif_test_ack): New.
(remote_notif_test_alloc_event): New.
(notif_client_test): New variable.
(notifs): New element 'notif_client_test'.
---
gdb/gdbserver/linux-low.c | 10 ++++++++++
gdb/gdbserver/notif.c | 12 ++++++++++++
gdb/gdbserver/notif.h | 2 ++
gdb/remote-notif.c | 43 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 67 insertions(+), 0 deletions(-)
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index c697f6b..ef4b3a9 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -20,6 +20,7 @@
#include "linux-low.h"
#include "linux-osdata.h"
#include "agent.h"
+#include "notif.h"
#include "gdb_wait.h"
#include <stdio.h>
@@ -4336,6 +4337,15 @@ linux_fetch_registers (struct regcache *regcache, int regno)
int use_regsets;
int all = 0;
+ /* Only for test. */
+ if (notif_test.queue != NULL)
+ {
+ struct notif_event *new_event
+ = xmalloc (sizeof (struct notif_event));
+
+ notif_push (¬if_test, new_event);
+ }
+
if (regno == -1)
{
if (the_low_target.fetch_register != NULL)
diff --git a/gdb/gdbserver/notif.c b/gdb/gdbserver/notif.c
index 0713b36..f9d4110 100644
--- a/gdb/gdbserver/notif.c
+++ b/gdb/gdbserver/notif.c
@@ -50,9 +50,21 @@
#include "notif.h"
+static void
+notif_reply_test (struct notif_event *event, char *own_buf)
+{
+ strcpy (own_buf, "CESHI");
+}
+
+struct notif_server notif_test =
+{
+ "vTested", "Test", NULL, notif_reply_test
+};
+
static struct notif_server *notifs[] =
{
¬if_stop,
+ ¬if_test,
};
/* Write another event or an OK, if there are no more left, to
diff --git a/gdb/gdbserver/notif.h b/gdb/gdbserver/notif.h
index e153b48..4223c0c 100644
--- a/gdb/gdbserver/notif.h
+++ b/gdb/gdbserver/notif.h
@@ -63,4 +63,6 @@ void notif_push (struct notif_server *np, struct notif_event *event);
void notif_event_enque (struct notif_server *notif,
struct notif_event *event);
+extern struct notif_server notif_test;
+
void initialize_notif (void);
diff --git a/gdb/remote-notif.c b/gdb/remote-notif.c
index c02394a..916e297 100644
--- a/gdb/remote-notif.c
+++ b/gdb/remote-notif.c
@@ -44,11 +44,54 @@
unsigned int notif_debug = 0;
+static void
+remote_notif_test_parse (struct notif_client *self, char *buf,
+ struct notif_event *event)
+{
+ if (strncmp (buf, "CESHI", 5) != 0)
+ error (_("'CESHI' is expected"));
+}
+
+static void
+remote_notif_test_ack (struct notif_client *self, char *buf,
+ struct notif_event *event)
+{
+ /* acknowledge */
+ putpkt ((char *) self->ack_command);
+}
+
+static int
+remote_notif_test_can_get_pending_events (struct notif_client *self)
+{
+ return 1;
+}
+
+static struct notif_event *
+remote_notif_test_alloc_event (void)
+{
+ struct notif_event *event = xmalloc (sizeof (struct notif_event));
+
+ event->dtr = NULL;
+
+ return event;
+}
+
+static struct notif_client notif_client_test =
+{
+ "Test", "vTested",
+ remote_notif_test_parse,
+ remote_notif_test_ack,
+ remote_notif_test_can_get_pending_events,
+ remote_notif_test_alloc_event,
+ NULL,
+};
+
/* Supported clients of notifications. */
static struct notif_client *notifs[] =
{
¬if_client_stop,
+ ¬if_client_test,
};
static void do_notif_event_xfree (void *arg);
--
1.7.7.6
More information about the Gdb-patches
mailing list