Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 3/5] async remote notification 'Trace'.
Date: Sat, 16 Feb 2013 04:02:00 -0000	[thread overview]
Message-ID: <1360987214-16592-4-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1360987214-16592-1-git-send-email-yao@codesourcery.com>

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 status change', like this,

%Trace:status: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, with
different annex.

gdb/gdbserver:

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

	* 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.
	(NOTIF_ANNEX_TRACE_STATUS): New macro.
	* remote-notif-trace.c: New.

gdb/doc:

	* gdb.texinfo (Packets): Add "vTraced".
	(Notification Packets): Add doc about "Trace" notification
	and "vTraced" packet.
---
 gdb/Makefile.in            |    4 +-
 gdb/doc/gdb.texinfo        |   10 ++++++
 gdb/gdbserver/notif.c      |    1 +
 gdb/gdbserver/notif.h      |    1 +
 gdb/gdbserver/tracepoint.c |   36 +++++++++++++++++++++
 gdb/remote-notif-trace.c   |   75 ++++++++++++++++++++++++++++++++++++++++++++
 gdb/remote-notif.c         |    1 +
 gdb/remote-notif.h         |    1 +
 8 files changed, 127 insertions(+), 2 deletions(-)
 create mode 100644 gdb/remote-notif-trace.c

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 4eb1548..3bd6333 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -510,7 +510,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 common-notif.o
+	remote-notif.o common-notif.o remote-notif-trace.o
 
 # This is remote-sim.o if a simulator is to be linked in.
 SIM_OBS = @SIM_OBS@
@@ -737,7 +737,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
 	proc-service.list progspace.c \
 	prologue-value.c psymtab.c \
 	regcache.c reggroups.c remote.c remote-fileio.c remote-notif.c \
-	common-notif.c reverse.c \
+	common-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/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index c94a203..6719a05 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -36372,6 +36372,8 @@ for success (@pxref{Stop Reply Packets})
 
 @item vStopped
 @cindex @samp{vStopped} packet
+@itemx vTraced
+@cindex @samp{vTraced} packet
 @xref{Notification Packets}.
 
 @item X @var{addr},@var{length}:@var{XX@dots{}}
@@ -38273,6 +38275,7 @@ continue the tracing run, while 0 tells the target to stop tracing if
 @value{GDBN} is no longer in the picture.
 
 @item qTStatus
+@anchor{qTStatus packet}
 @cindex @samp{qTStatus} packet
 Ask the stub if there is a trace experiment running right now.
 
@@ -38800,6 +38803,13 @@ for information on how these notifications are acknowledged by
 @value{GDBN}.
 @tab Report an asynchronous stop event in non-stop mode.
 
+@item Trace
+@tab vTraced
+@tab @code{status}
+@tab @var{reply}.  The @var{reply} has the form of the reply to packet
+@samp{qTStatus}, as described in @ref{qTStatus packet}.
+@tab Report an asynchronous trace-related event.
+
 @end multitable
 
 @node Remote Non-Stop
diff --git a/gdb/gdbserver/notif.c b/gdb/gdbserver/notif.c
index e6b3756..5a533f4 100644
--- a/gdb/gdbserver/notif.c
+++ b/gdb/gdbserver/notif.c
@@ -52,6 +52,7 @@
 static struct notif_server *notifs[] =
 {
   &notif_stop,
+  &notif_trace,
 };
 
 /* Helper function to write EVENT of NOTIF to buffer OWN_BUF.  */
diff --git a/gdb/gdbserver/notif.h b/gdb/gdbserver/notif.h
index 72417aa..52d09cc 100644
--- a/gdb/gdbserver/notif.h
+++ b/gdb/gdbserver/notif.h
@@ -55,6 +55,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 51b6a0c..8becbbf 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -3370,6 +3370,32 @@ 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)
+{
+  cmd_qtstatus (own_buf);
+}
+
+#define NOTIF_ANNEX_TRACE_STATUS 0
+
+static struct notif_annex notif_annex_trace[] =
+{
+  { "status", 0, notif_reply_trace, },
+  { NULL, 0, NULL, },
+};
+
+struct notif_server notif_trace =
+{
+  { "Trace", "vTraced", notif_annex_trace, }, NULL,
+};
+
+#endif
+
 /* End a tracing run, filling in a stop reason to report back to GDB,
    and removing the tracepoints from the code.  */
 
@@ -3470,6 +3496,16 @@ stop_tracing (void)
     }
 
   unpause_all (1);
+
+  if (NOTIF_ANNEX_SUPPORTED_P (notif_trace.base,
+			       NOTIF_ANNEX_TRACE_STATUS))
+    {
+      struct notif_annex_event *event
+	= xmalloc (sizeof (struct notif_annex_event));
+
+      event->annex_index = NOTIF_ANNEX_TRACE_STATUS;
+      notif_push (&notif_trace, (struct notif_event *) event);
+    }
 }
 
 static int
diff --git a/gdb/remote-notif-trace.c b/gdb/remote-notif-trace.c
new file mode 100644
index 0000000..a0cfa26
--- /dev/null
+++ b/gdb/remote-notif-trace.c
@@ -0,0 +1,75 @@
+/* Async remote notification on trace.
+
+   Copyright (C) 2013 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_status_parse (struct notif_client *self, char *buf,
+				 struct notif_event *event)
+{
+  struct trace_status *ts = current_trace_status ();
+
+  gdb_assert (buf[0] == 'T');
+  parse_trace_status (buf + 1, ts);
+}
+
+static void
+remote_notif_trace_ack (struct notif_client *self, char *buf,
+			struct notif_event *event)
+{
+  /* acknowledge */
+  putpkt ((char *) self->base.ack_name);
+}
+
+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;
+}
+
+static struct notif_annex notif_client_trace_annex[] =
+{
+  { "status", 0, remote_notif_trace_status_parse, },
+  { NULL, 0, NULL, },
+};
+
+/* A client of notification 'Trace'.  */
+
+struct notif_client notif_client_trace =
+{
+  { "Trace", "vTraced", notif_client_trace_annex, },
+  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 ae05bbf..aeff038 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 4859254..ce9fd07 100644
--- a/gdb/remote-notif.h
+++ b/gdb/remote-notif.h
@@ -74,6 +74,7 @@ char * remote_notif_qsupported (void);
 void remote_notif_qsupported_reply (const char *reply);
 
 extern struct notif_client notif_client_stop;
+extern struct notif_client notif_client_trace;
 
 extern unsigned int notif_debug;
 
-- 
1.7.7.6


  parent reply	other threads:[~2013-02-16  4:02 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-22  7:05 [PATCH 0/5] MI notification on trace started/stopped (V3) Yao Qi
2013-01-22  7:05 ` [PATCH 3/5] async remote notification 'Trace' Yao Qi
2013-01-22  8:06   ` Eli Zaretskii
2013-01-22  7:05 ` [PATCH 1/5] Add annex in a async remote notification Yao Qi
2013-01-22  8:06   ` Eli Zaretskii
2013-02-16  3:40     ` Yao Qi
2013-02-16  9:27       ` Eli Zaretskii
2013-03-29 17:17         ` Yao Qi
2013-03-31  0:39           ` Eli Zaretskii
2013-01-22  7:05 ` [PATCH 2/5] Query supported notifications by qSupported Yao Qi
2013-01-22  8:09   ` Eli Zaretskii
2013-01-22  8:41     ` Yao Qi
2013-01-22 10:26       ` Eli Zaretskii
2013-01-22  7:06 ` [PATCH 4/5] MI notification on trace started/stopped:basic Yao Qi
2013-01-22  8:11   ` Eli Zaretskii
2013-01-22  7:06 ` [PATCH 5/5] MI notification on trace stop: triggered by remote Yao Qi
2013-01-30  4:00 ` [ping]: [PATCH 0/5] MI notification on trace started/stopped (V3) Yao Qi
2013-02-07 12:41   ` [ping 2]: " Yao Qi
2013-02-16  4:01 ` [PATCH 0/5] MI notification on trace started/stopped (V3.1) Yao Qi
2013-02-16  4:01   ` [PATCH 1/5] Add annex in a async remote notification Yao Qi
2013-02-16  9:27     ` Eli Zaretskii
2013-02-16  4:02   ` [PATCH 2/5] Query supported notifications by qSupported Yao Qi
2013-02-16  9:33     ` Eli Zaretskii
2013-03-11  9:26       ` Yao Qi
2013-03-11 16:59         ` Eli Zaretskii
2013-02-16  4:02   ` Yao Qi [this message]
2013-02-16  9:34     ` [PATCH 3/5] async remote notification 'Trace' Eli Zaretskii
2013-02-16  4:02   ` [PATCH 4/5] MI notification on trace started/stopped:basic Yao Qi
2013-02-16  9:36     ` Eli Zaretskii
2013-02-16  4:02   ` [PATCH 5/5] MI notification on trace stop: triggered by remote Yao Qi
2013-02-25  3:14   ` ping: [PATCH 0/5] MI notification on trace started/stopped (V3.1) Yao Qi
2013-03-04  2:34   ` ping^2 : " Yao Qi
2013-04-02  2:33 ` [PATCH v4 0/5] MI notification on trace started/stopped Yao Qi
2013-04-02  3:15   ` [PATCH 2/5] Query supported notifications by qSupported Yao Qi
2013-04-02  3:58   ` [PATCH 3/5] async remote notification 'Trace' Yao Qi
2013-04-02 12:46   ` [PATCH 5/5] MI notification on trace stop: triggered by remote Yao Qi
2013-04-02 13:07   ` [PATCH 4/5] MI notification on trace started/stopped:basic Yao Qi
2013-04-02 13:30   ` [PATCH 1/5] Add annex in a async remote notification Yao Qi
2013-04-10 15:46   ` [PATCH v4 0/5] MI notification on trace started/stopped Yao Qi
2013-04-17 14:37     ` [ping 2]: " Yao Qi
2013-04-18 15:16       ` Pedro Alves
2013-04-18 16:14         ` Yao Qi
2013-06-04  9:20         ` Yao Qi
2014-01-24  9:43 [PATCH 0/5 V8] " Yao Qi
2014-01-24  9:43 ` [PATCH 3/5] async remote notification 'Trace' Yao Qi

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=1360987214-16592-4-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