This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 6/6] new notification "TEST".
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-09-24 Yao Qi <yao@codesourcery.com>
* linux-low.c (linux_fetch_registers): Call circular_queue_enque
and async_file_mark.
* notif.c (notif_process_vtested): New.
(notif_test): New variable.
(notfi_packets): Add new element 'notif_test'.
* notif.h (notif_type): New enum 'NOTIF_TEST'.
* server.c (handle_target_event): Handle 'NOTIF_V_TESTED'.
gdb:
2012-09-24 Yao Qi <yao@codesourcery.com>
* remote-notif.c (struct test_reply): New.
(remote_notif_parse_test): New.
(remote_notif_ack_test): New.
(remote_notif_alloc_reply_test): New.
(notif_packet_test): New variable.
(notifs): New element 'notif_packet_test'.
---
gdb/gdbserver/linux-low.c | 7 +++++++
gdb/gdbserver/notif.c | 15 +++++++++++++++
gdb/gdbserver/notif.h | 3 ++-
gdb/remote-notif.c | 41 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 65 insertions(+), 1 deletions(-)
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 1c62ccc..5588889 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -4334,6 +4334,13 @@ linux_fetch_registers (struct regcache *regcache, int regno)
int use_regsets;
int all = 0;
+ if (notif_queue != NULL)
+ {
+ /* Only for test. */
+ QUEUE_enque (notif_p, notif_queue, ¬if_test);
+ async_file_mark ();
+ }
+
if (regno == -1)
{
if (the_low_target.fetch_register != NULL)
diff --git a/gdb/gdbserver/notif.c b/gdb/gdbserver/notif.c
index d047ac5..c5de0ec 100644
--- a/gdb/gdbserver/notif.c
+++ b/gdb/gdbserver/notif.c
@@ -19,9 +19,21 @@
#include "notif.h"
+static void
+notif_reply_test (struct notif_reply *reply, char *own_buf)
+{
+ strcpy (own_buf, "CESHI");
+}
+
+struct notif notif_test =
+{
+ "vTested", "NTest", NOTIF_TEST, NULL, notif_reply_test
+};
+
static struct notif *notif_packets [] =
{
¬if_stop,
+ ¬if_test,
NULL,
};
@@ -114,6 +126,9 @@ notif_process (struct notif *np, char *buf,
new_notif = (struct notif_reply *) vstop_notif;
}
break;
+ case NOTIF_TEST:
+ new_notif = xmalloc (sizeof (struct notif_reply));
+ break;
default:
error ("Unknown notification type");
}
diff --git a/gdb/gdbserver/notif.h b/gdb/gdbserver/notif.h
index 9f6e555..da9ce60 100644
--- a/gdb/gdbserver/notif.h
+++ b/gdb/gdbserver/notif.h
@@ -42,7 +42,7 @@ struct vstop_notif
struct target_waitstatus status;
};
-enum notif_type { NOTIF_STOP };
+enum notif_type { NOTIF_STOP, NOTIF_TEST };
/* A notification to GDB. */
@@ -77,6 +77,7 @@ void notif_process (struct notif *np, char *buf,
struct target_waitstatus status, ptid_t ptid);
void notif_reply_enque (struct notif *notif, struct notif_reply *reply);
+extern struct notif notif_test;
extern QUEUE (notif_p) *notif_queue;
DECLARE_QUEUE_P (notif_p);
diff --git a/gdb/remote-notif.c b/gdb/remote-notif.c
index ff22d1e..395b70c 100644
--- a/gdb/remote-notif.c
+++ b/gdb/remote-notif.c
@@ -29,11 +29,52 @@
int notif_debug = 0;
+struct test_reply
+{
+ struct notif_reply base;
+};
+
+static void
+remote_notif_parse_test (struct notif *self, char *buf, void *data)
+{
+ if (strncmp (buf, "CESHI", 5) != 0)
+ error (_("'CESHI' is expected"));
+}
+
+static void
+remote_notif_ack_test (struct notif *self, char *buf, void *data)
+{
+ struct notif_reply *reply = (struct notif_reply *) data;
+
+ /* acknowledge */
+ putpkt ((char *) self->ack_command);
+}
+
+static struct notif_reply *
+remote_notif_alloc_reply_test (void)
+{
+ struct notif_reply *reply = xmalloc (sizeof (struct test_reply));
+
+ reply->dtr = NULL;
+
+ return reply;
+}
+
+static struct notif notif_packet_test =
+{
+ "NTest", "vTested",
+ remote_notif_parse_test,
+ remote_notif_ack_test,
+ remote_notif_alloc_reply_test,
+ NULL, NULL,
+};
+
/* Supported notifications. */
static struct notif *notifs[] =
{
(struct notif *) ¬if_packet_stop,
+ ¬if_packet_test,
};
static void do_notif_reply_xfree (void *arg);
--
1.7.7.6