From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2117 invoked by alias); 12 Dec 2013 13:51:16 -0000 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 Received: (qmail 1942 invoked by uid 89); 12 Dec 2013 13:51:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,T_FROM_12LTRDOM autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Dec 2013 13:51:12 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1Vr6fV-0002oP-Bj from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Thu, 12 Dec 2013 05:51:09 -0800 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 12 Dec 2013 05:51:09 -0800 Received: from qiyao.dyndns.org.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.2.247.3; Thu, 12 Dec 2013 05:51:07 -0800 From: Yao Qi To: Subject: [PATCH 2/4] async remote notification 'Trace'. Date: Thu, 12 Dec 2013 13:51:00 -0000 Message-ID: <1386856184-16519-3-git-send-email-yao@codesourcery.com> In-Reply-To: <1386856184-16519-1-git-send-email-yao@codesourcery.com> References: <1386856184-16519-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00496.txt.bz2 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 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. 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. --- gdb/Makefile.in | 5 ++- gdb/doc/gdb.texinfo | 9 +++++ gdb/gdbserver/notif.c | 1 + gdb/gdbserver/notif.h | 1 + gdb/gdbserver/tracepoint.c | 27 +++++++++++++++ gdb/remote-notif-trace.c | 76 ++++++++++++++++++++++++++++++++++++++++++++ gdb/remote-notif.c | 1 + gdb/remote-notif.h | 2 + 8 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 gdb/remote-notif-trace.c diff --git a/gdb/Makefile.in b/gdb/Makefile.in index be30dfd..2829aba 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -526,7 +526,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@ @@ -756,7 +756,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 e76f73b..e91c01e 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -38550,6 +38550,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{}} @@ -40570,6 +40572,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. @@ -41100,6 +41103,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 4766bba..123581d 100644 --- a/gdb/gdbserver/notif.c +++ b/gdb/gdbserver/notif.c @@ -52,6 +52,7 @@ static struct notif_server *notifs[] = { ¬if_stop, + ¬if_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 80e084e..c1abae0 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 ea1a8a1..c47dd88 100644 --- a/gdb/gdbserver/tracepoint.c +++ b/gdb/gdbserver/tracepoint.c @@ -3381,6 +3381,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, "status:"); + cmd_qtstatus (own_buf + 7); +} + +struct notif_server notif_trace = +{ + "vTraced", "Trace", NULL, notif_reply_trace, 0, +}; + +#endif + /* End a tracing run, filling in a stop reason to report back to GDB, and removing the tracepoints from the code. */ @@ -3481,6 +3500,14 @@ stop_tracing (void) } unpause_all (1); + + if (notif_trace.supported) + { + struct notif_event *event + = xmalloc (sizeof (struct notif_event)); + + notif_push (¬if_trace, event); + } } static int diff --git a/gdb/remote-notif-trace.c b/gdb/remote-notif-trace.c new file mode 100644 index 0000000..ec7f46c --- /dev/null +++ b/gdb/remote-notif-trace.c @@ -0,0 +1,76 @@ +/* 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 . */ + +#include "defs.h" +#include +#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 4685d30..86a709a 100644 --- a/gdb/remote-notif.c +++ b/gdb/remote-notif.c @@ -49,6 +49,7 @@ int notif_debug = 0; static struct notif_client *notifs[] = { ¬if_client_stop, + ¬if_client_trace, }; gdb_static_assert (ARRAY_SIZE (notifs) == REMOTE_NOTIF_LAST); diff --git a/gdb/remote-notif.h b/gdb/remote-notif.h index 14984b4..1a9e81c 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, }; @@ -125,6 +126,7 @@ void remote_notif_qsupported_reply (const char *reply, struct remote_notif_state *state); extern struct notif_client notif_client_stop; +extern struct notif_client notif_client_trace; extern int notif_debug; -- 1.7.7.6