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 2/3] async remote notification 'Trace'.


Hi,
This patch adds a new async remote notification 'Trace' to report the
trace-related changes in the stub.  So far, it is only used for
reporting 'tracing stopped', like this,

%Trace:stop:T0;tstop::0;tframes:0;tcreated:0;tfree:500000;tsize:500000;circular:0;disconn:0;starttime:001355728912543287;stoptime:001355728912543768;username::;notes:666f6f:\n

and of course, it can be used for other trace-related changes.  For
example, the trace can be started by something other than GDB, and
then GDB will get a notification about trace is started,

  %Trace:start:

Since notification infrastructure may recorder the notifications, so
it is better to handle all trace-related changes in a single type of
notification, %Trace (because notifications of the same type can't be
reordered).

The doc on %Trace and vTraced will be posted later.

gdb/gdbserver:

2012-12-19  Yao Qi  <yao@codesourcery.com>

	* notif.c (notifs): Add "notif_trace".
	* notif.h (ontif_trace): Declare.
	* tracepoint.c [!IN_PRCESS_AGENT]: Include "notif.h".
	(notif_reply_trace): New.
	(notif_trace): New variable.
	(stop_tracing) [!IN_PROCESS_AGENT]: Call notif_push.
gdb:

2012-12-19  Yao Qi  <yao@codesourcery.com>

	* Makefile.in (REMOTE_OBS): Append remote-notif-trace.o
	(SFILES): Add remote-notif-trace.c
	* remote-notif.c (notifs): Add "notif_client_trace".
	* remote-notif.h (notif_client_trace): Declare.
	* remote-notif-trace.c: New.
---
 gdb/Makefile.in            |    5 ++-
 gdb/gdbserver/notif.c      |    1 +
 gdb/gdbserver/notif.h      |    1 +
 gdb/gdbserver/tracepoint.c |   27 +++++++++++++++++
 gdb/remote-notif-trace.c   |   70 ++++++++++++++++++++++++++++++++++++++++++++
 gdb/remote-notif.c         |    1 +
 gdb/remote-notif.h         |    1 +
 7 files changed, 104 insertions(+), 2 deletions(-)
 create mode 100644 gdb/remote-notif-trace.c

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 8e7b589..c18f3c1 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -508,7 +508,7 @@ SER_HARDWIRE = @SER_HARDWIRE@
 # The `remote' debugging target is supported for most architectures,
 # but not all (e.g. 960)
 REMOTE_OBS = remote.o dcache.o tracepoint.o ax-general.o ax-gdb.o remote-fileio.o \
-	remote-notif.o
+	remote-notif.o remote-notif-trace.o
 
 # This is remote-sim.o if a simulator is to be linked in.
 SIM_OBS = @SIM_OBS@
@@ -730,7 +730,8 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
 	p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c printcmd.c \
 	proc-service.list progspace.c \
 	prologue-value.c psymtab.c \
-	regcache.c reggroups.c remote.c remote-fileio.c remote-notif.c reverse.c \
+	regcache.c reggroups.c remote.c remote-fileio.c remote-notif.c \
+	remote-notif-trace.c reverse.c \
 	sentinel-frame.c \
 	serial.c ser-base.c ser-unix.c skip.c \
 	solib.c solib-target.c source.c \
diff --git a/gdb/gdbserver/notif.c b/gdb/gdbserver/notif.c
index 0713b36..bc56ae1 100644
--- a/gdb/gdbserver/notif.c
+++ b/gdb/gdbserver/notif.c
@@ -53,6 +53,7 @@
 static struct notif_server *notifs[] =
 {
   &notif_stop,
+  &notif_trace,
 };
 
 /* 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 b76ecfa..76d6710 100644
--- a/gdb/gdbserver/notif.h
+++ b/gdb/gdbserver/notif.h
@@ -54,6 +54,7 @@ typedef struct notif_server
 } *notif_server_p;
 
 extern struct notif_server notif_stop;
+extern struct notif_server notif_trace;
 
 int handle_notif_ack (char *own_buf, int packet_len);
 void notif_write_event (struct notif_server *notif, char *own_buf);
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index 1526838..e363ea4 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -3372,6 +3372,25 @@ cmd_qtstart (char *packet)
   write_ok (packet);
 }
 
+#ifndef IN_PROCESS_AGENT
+#include "notif.h"
+
+static void cmd_qtstatus (char *packet);
+
+static void
+notif_reply_trace (struct notif_event *event, char *own_buf)
+{
+  sprintf (own_buf, "stop:");
+  cmd_qtstatus (own_buf + 5);
+}
+
+struct notif_server notif_trace =
+{
+  "vTraced", "Trace", NULL, notif_reply_trace
+};
+
+#endif
+
 /* End a tracing run, filling in a stop reason to report back to GDB,
    and removing the tracepoints from the code.  */
 
@@ -3472,6 +3491,14 @@ stop_tracing (void)
     }
 
   unpause_all (1);
+
+#ifndef IN_PROCESS_AGENT
+  {
+    struct notif_event *event = malloc (sizeof (struct notif_event));
+
+    notif_push (&notif_trace, event);
+  }
+#endif
 }
 
 static int
diff --git a/gdb/remote-notif-trace.c b/gdb/remote-notif-trace.c
new file mode 100644
index 0000000..9f74580
--- /dev/null
+++ b/gdb/remote-notif-trace.c
@@ -0,0 +1,70 @@
+/* Async remote notification on trace.
+
+   Copyright (C) 2012 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include "defs.h"
+#include <string.h>
+#include "remote.h"
+#include "tracepoint.h"
+#include "remote-notif.h"
+
+static void
+remote_notif_trace_parse (struct notif_client *self, char *buf,
+			  struct notif_event *event)
+{
+  if (strncmp (buf, "stop:", 5) == 0)
+    parse_trace_status (buf + 5 + 1, current_trace_status ());
+  else
+    error (_("Unknown trace notification."));
+}
+
+static void
+remote_notif_trace_ack (struct notif_client *self, char *buf,
+			struct notif_event *event)
+{
+  /* acknowledge */
+  putpkt ((char *) self->ack_command);
+}
+
+static int
+remote_notif_trace_can_get_pending_events (struct notif_client *self)
+{
+  return 1;
+}
+
+static struct notif_event *
+remote_notif_trace_alloc_event (void)
+{
+  struct notif_event *event = xmalloc (sizeof (struct notif_event));
+
+  event->dtr = NULL;
+
+  return event;
+}
+
+/* A client of notification 'Trace'.  */
+
+struct notif_client notif_client_trace =
+{
+  "Trace", "vTraced",
+  remote_notif_trace_parse,
+  remote_notif_trace_ack,
+  remote_notif_trace_can_get_pending_events,
+  remote_notif_trace_alloc_event,
+  NULL,
+};
diff --git a/gdb/remote-notif.c b/gdb/remote-notif.c
index eee09a9..a52aa60 100644
--- a/gdb/remote-notif.c
+++ b/gdb/remote-notif.c
@@ -49,6 +49,7 @@ unsigned int notif_debug = 0;
 static struct notif_client *notifs[] =
 {
   &notif_client_stop,
+  &notif_client_trace,
 };
 
 static void do_notif_event_xfree (void *arg);
diff --git a/gdb/remote-notif.h b/gdb/remote-notif.h
index 92c4bb6..bf91229 100644
--- a/gdb/remote-notif.h
+++ b/gdb/remote-notif.h
@@ -79,6 +79,7 @@ void remote_notif_unregister_async_event_handler (void);
 
 void remote_notif_process (struct notif_client *except);
 extern struct notif_client notif_client_stop;
+extern struct notif_client notif_client_trace;
 
 extern unsigned int notif_debug;
 
-- 
1.7.7.6


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