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: Fri, 24 Jan 2014 09:43:00 -0000	[thread overview]
Message-ID: <1390556465-28796-4-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1390556465-28796-1-git-send-email-yao@codesourcery.com>

Hi,
This patch adds a new async remote notification 'Trace' to report the
trace-status-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

V8:
GDBserver sends async notification Trace when tracing is started or
stopped, in order to keep the order of events correct in GDB side.

gdb/gdbserver:

	* notif.c (notifs): Add "notif_trace".
	* notif.h (ontif_trace): Declare.
	* tracepoint.c [!IN_PROCESS_AGENT]: Include "notif.h".
	[!IN_PROCESS_AGENT] (notif_reply_trace): New function.
	[!IN_PROCESS_AGENT] (notif_trace): New variable.
	(stop_tracing): Call notif_push.
	(start_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.
	(REMOTE_NOTIF_TRACE): New enum
	* remote-notif-trace.c: New.

gdb/doc:

	* gdb.texinfo (Packets): Add "vTraced".
	(Notification Packets): Add doc about "Trace" notification
	and "vTraced" packet.
	(General Query Packets): Document NotifTrace feature and reply of
	qSupported.
---
 gdb/Makefile.in            |    5 ++-
 gdb/doc/gdb.texinfo        |   22 +++++++++++++
 gdb/gdbserver/notif.c      |    1 +
 gdb/gdbserver/notif.h      |    1 +
 gdb/gdbserver/tracepoint.c |   35 ++++++++++++++++++++
 gdb/remote-notif-trace.c   |   76 ++++++++++++++++++++++++++++++++++++++++++++
 gdb/remote-notif.c         |    1 +
 gdb/remote-notif.h         |    2 +
 8 files changed, 141 insertions(+), 2 deletions(-)
 create mode 100644 gdb/remote-notif-trace.c

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index ed84e35..0978440 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -531,7 +531,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 ctf.o
+	remote-notif.o ctf.o remote-notif-trace.o
 
 # This is remote-sim.o if a simulator is to be linked in.
 SIM_OBS = @SIM_OBS@
@@ -762,7 +762,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/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index a990d2a..573bc83 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -38658,6 +38658,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{}}
@@ -39491,6 +39493,10 @@ description.
 This feature indicates whether @value{GDBN} supports the
 @samp{qRelocInsn} packet (@pxref{Tracepoint Packets,,Relocate
 instruction reply packet}).
+
+@item NotifTrace
+This feature indicates that @value{GDBN} supports the async remote
+notification trace (@pxref{Notification Packets}).
 @end table
 
 Stubs should ignore any unknown values for
@@ -39709,6 +39715,11 @@ These are the currently defined stub features and their properties:
 @tab @samp{-}
 @tab No
 
+@item @samp{NotifTrace}
+@tab No
+@tab @samp{-}
+@tab No
+
 @end multitable
 
 These are the currently defined stub features, in more detail:
@@ -39876,6 +39887,10 @@ See @ref{Bytecode Descriptions} for details about the bytecode.
 The remote stub supports running a breakpoint's command list itself,
 rather than reporting the hit to @value{GDBN}.
 
+@item NotifTrace
+@cindex async notification trace, in remote protocol
+The remote stub supports the async notification trace.
+
 @item Qbtrace:off
 The remote stub understands the @samp{Qbtrace:off} packet.
 
@@ -40668,6 +40683,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.
 
@@ -41198,6 +41214,12 @@ 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 @var{status}.  The @var{reply} has the form of the reply to
+packet @samp{qTStatus}, as described in @ref{qTStatus packet}.
+@tab Report an asynchronous event related to trace status.
+
 @end multitable
 
 @node Remote Non-Stop
diff --git a/gdb/gdbserver/notif.c b/gdb/gdbserver/notif.c
index 3847110..437a9d0 100644
--- a/gdb/gdbserver/notif.c
+++ b/gdb/gdbserver/notif.c
@@ -52,6 +52,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 671ef32..2934d97 100644
--- a/gdb/gdbserver/notif.h
+++ b/gdb/gdbserver/notif.h
@@ -58,6 +58,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 3706577..22f88d9 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -3201,6 +3201,25 @@ install_tracepoint (struct tracepoint *tpoint, char *own_buf)
     write_ok (own_buf);
 }
 
+#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, "status:");
+  cmd_qtstatus (own_buf + 7);
+}
+
+struct notif_server notif_trace =
+{
+  "vTraced", "Trace", NULL, notif_reply_trace, 0,
+};
+
+#endif
+
 static void download_tracepoint_1 (struct tracepoint *tpoint);
 
 static void
@@ -3394,6 +3413,14 @@ cmd_qtstart (char *packet)
   unpause_all (1);
 
   write_ok (packet);
+
+  if (notif_trace.supported)
+    {
+      struct notif_event *event
+	= xmalloc (sizeof (struct notif_event));
+
+      notif_push (&notif_trace, event);
+    }
 }
 
 /* End a tracing run, filling in a stop reason to report back to GDB,
@@ -3496,6 +3523,14 @@ stop_tracing (void)
     }
 
   unpause_all (1);
+
+  if (notif_trace.supported)
+    {
+      struct notif_event *event
+	= xmalloc (sizeof (struct notif_event));
+
+      notif_push (&notif_trace, event);
+    }
 }
 
 static int
diff --git a/gdb/remote-notif-trace.c b/gdb/remote-notif-trace.c
new file mode 100644
index 0000000..9ae1d33
--- /dev/null
+++ b/gdb/remote-notif-trace.c
@@ -0,0 +1,76 @@
+/* Async remote notification on trace.
+
+   Copyright (C) 2014 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, "status:", 7) == 0)
+    {
+      struct trace_status *ts = current_trace_status ();
+
+      if (buf[7] != 'T')
+	error (_("Unknown trace status in trace notification."));
+      parse_trace_status (buf + 7 + 1, ts);
+    }
+  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,
+  REMOTE_NOTIF_TRACE,
+};
diff --git a/gdb/remote-notif.c b/gdb/remote-notif.c
index ee2c2c4..8672696 100644
--- a/gdb/remote-notif.c
+++ b/gdb/remote-notif.c
@@ -49,6 +49,7 @@ int notif_debug = 0;
 static struct notif_client *notifs[] =
 {
   &notif_client_stop,
+  &notif_client_trace,
 };
 
 gdb_static_assert (ARRAY_SIZE (notifs) == REMOTE_NOTIF_LAST);
diff --git a/gdb/remote-notif.h b/gdb/remote-notif.h
index 6fd58bf..1b55aab 100644
--- a/gdb/remote-notif.h
+++ b/gdb/remote-notif.h
@@ -36,6 +36,7 @@ struct notif_event
 enum REMOTE_NOTIF_ID
 {
   REMOTE_NOTIF_STOP = 0,
+  REMOTE_NOTIF_TRACE,
   REMOTE_NOTIF_LAST,
 };
 
@@ -123,6 +124,7 @@ struct notif_client *remote_notif_find (const char *name);
 char *remote_notif_qsupported (char *buf);
 
 extern struct notif_client notif_client_stop;
+extern struct notif_client notif_client_trace;
 
 extern int notif_debug;
 
-- 
1.7.7.6


  reply	other threads:[~2014-01-24  9:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-24  9:43 [PATCH 0/5 V8] MI notification on trace started/stopped Yao Qi
2014-01-24  9:43 ` Yao Qi [this message]
2014-01-24  9:43 ` [PATCH 4/5] " Yao Qi
2014-01-24  9:43 ` [PATCH 2/5] Query supported notifications by qSupported Yao Qi
2014-01-24  9:43 ` [PATCH 5/5] New test case mi-trace-changed.exp Yao Qi
2014-01-24  9:43 ` [PATCH 1/5] Process notifications when reply is got Yao Qi
  -- strict thread matches above, loose matches on Subject: below --
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-02-16  4:01 ` [PATCH 0/5] MI notification on trace started/stopped (V3.1) Yao Qi
2013-02-16  4:02   ` [PATCH 3/5] async remote notification 'Trace' Yao Qi
2013-02-16  9:34     ` Eli Zaretskii
2013-04-02  2:33 ` [PATCH v4 0/5] MI notification on trace started/stopped Yao Qi
2013-04-02  3:58   ` [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=1390556465-28796-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