From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 4/4] new notification "TEST".
Date: Fri, 24 Aug 2012 02:26:00 -0000 [thread overview]
Message-ID: <1345775139-13576-5-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1345775139-13576-1-git-send-email-yao@codesourcery.com>
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 (¬if_test, ¬if_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 [] =
{
¬if_stop,
+ ¬if_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[] =
{
¬if_packet_stop,
+ ¬if_packet_test,
};
/* Parse the BUF for the expected notification NP, and send packet to
--
1.7.7.6
next prev parent reply other threads:[~2012-08-24 2:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-24 2:26 [RCF 0/4] A general notification in GDB RSP Yao Qi
2012-08-24 2:26 ` [PATCH 3/4] de-couple %Stop from notification: gdbserver Yao Qi
2012-08-24 2:26 ` [PATCH 2/4] de-couple %Stop from notification: gdb Yao Qi
2012-08-24 16:52 ` Yao Qi
2012-08-24 19:00 ` dje
2012-08-30 6:40 ` Yao Qi
2012-08-24 2:26 ` [PATCH 1/4] new gdb_queue.h in common/ Yao Qi
2012-08-24 18:44 ` dje
2012-08-24 18:49 ` Doug Evans
2012-08-29 9:42 ` Yao Qi
2012-09-04 21:03 ` dje
2012-09-07 2:47 ` Yao Qi
2012-09-10 20:47 ` dje
2012-09-12 14:24 ` Yao Qi
2012-09-13 15:55 ` dje
2012-09-14 2:38 ` Yao Qi
2012-09-11 16:50 ` Tom Tromey
2012-08-24 2:26 ` Yao Qi [this message]
2012-08-24 17:53 ` [RCF 0/4] A general notification in GDB RSP Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1345775139-13576-5-git-send-email-yao@codesourcery.com \
--to=yao@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox