From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16117 invoked by alias); 24 Aug 2012 02:26:27 -0000 Received: (qmail 16051 invoked by uid 22791); 24 Aug 2012 02:26:25 -0000 X-SWARE-Spam-Status: No, hits=-4.3 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; Fri, 24 Aug 2012 02:26:09 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1T4jb4-0003we-23 from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Thu, 23 Aug 2012 19:26:06 -0700 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); Thu, 23 Aug 2012 19:26:05 -0700 Received: from qiyao.dyndns.org.dyndns.org (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; Thu, 23 Aug 2012 19:26:04 -0700 From: Yao Qi To: Subject: [PATCH 4/4] new notification "TEST". Date: Fri, 24 Aug 2012 02:26:00 -0000 Message-ID: <1345775139-13576-5-git-send-email-yao@codesourcery.com> In-Reply-To: <1345775139-13576-1-git-send-email-yao@codesourcery.com> References: <1345775139-13576-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-08/txt/msg00705.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-08-24 Yao Qi * 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 * 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