This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 4/4] 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-08-24  Yao Qi  <yao@codesourcery.com>

   	* linux-low.c (linux_fetch_registers): Call circular_queue_enque
	and async_file_mark.
	* notif.c (notif_reply_test): 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_TEST'.
gdb:

2012-08-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 |   10 ++++++++++
 gdb/gdbserver/notif.c     |   12 ++++++++++++
 gdb/gdbserver/notif.h     |    2 +-
 gdb/gdbserver/server.c    |    3 +++
 gdb/remote-notif.c        |   41 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 67 insertions(+), 1 deletions(-)

diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index e9752b0..2045717 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -4341,6 +4341,16 @@ linux_fetch_registers (struct regcache *regcache, int regno)
   int use_regsets;
   int all = 0;
 
+  if (target_is_async_p ())
+    {
+      /* Only for test.  */
+
+      extern struct notif notif_test;
+
+      gdb_queue_notif_enque (&notif_test, &notif_queue);
+      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 838f391..b94a196 100644
--- a/gdb/gdbserver/notif.c
+++ b/gdb/gdbserver/notif.c
@@ -19,11 +19,23 @@
 
 #include "notif.h"
 
+static void
+notif_reply_test (struct notif_reply *reply, char *own_buf)
+{
+  strcpy (own_buf, "CESHI");
+}
+
+struct notif notif_test =
+{
+  "vTested", "Test", NOTIF_TEST, NULL, notif_reply_test
+};
+
 extern struct notif notif_stop;
 
 static struct notif *notif_packets [] =
 {
   &notif_stop,
+  &notif_test,
   NULL,
 };
 
diff --git a/gdb/gdbserver/notif.h b/gdb/gdbserver/notif.h
index ac62eab..f929616 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.  */
 
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 0b756cd..01db55f 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -3412,6 +3412,9 @@ handle_target_event (int err, gdb_client_data client_data)
 		    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/remote-notif.c b/gdb/remote-notif.c
index ca7f821..3c1634a 100644
--- a/gdb/remote-notif.c
+++ b/gdb/remote-notif.c
@@ -27,11 +27,52 @@
 
 extern struct remote_state *get_remote_state (void);
 
+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 =
+{
+  "Test", "vTested",
+  remote_notif_parse_test,
+  remote_notif_ack_test,
+  remote_notif_alloc_reply_test,
+  NULL, NULL,
+};
+
 /* Supported notifications.  */
 
 static struct notif *notifs[] =
 {
   &notif_packet_stop,
+  &notif_packet_test,
 };
 
 /* Parse the BUF for the expected notification NP, and send packet to
-- 
1.7.7.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]