From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16377 invoked by alias); 11 Dec 2012 06:41:11 -0000 Received: (qmail 16224 invoked by uid 22791); 11 Dec 2012 06:41:08 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_CP,TW_EG X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 11 Dec 2012 06:41:04 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1TiJWZ-0002Gt-VH from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Mon, 10 Dec 2012 22:41:03 -0800 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 10 Dec 2012 22:41:03 -0800 Received: from qiyao.dyndns.org.com (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.1.289.1; Mon, 10 Dec 2012 22:41:02 -0800 From: Yao Qi To: Subject: [PATCH 8/8] RSP notification 'Test'. Date: Tue, 11 Dec 2012 06:41:00 -0000 Message-ID: <1355208017-9204-9-git-send-email-yao@codesourcery.com> In-Reply-To: <1355208017-9204-1-git-send-email-yao@codesourcery.com> References: <1355208017-9204-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-12/txt/msg00303.txt.bz2 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 * 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 * 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 @@ -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