From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17468 invoked by alias); 13 May 2013 06:02:52 -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 17459 invoked by uid 89); 13 May 2013 06:02:51 -0000 X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,SPF_PASS autolearn=ham version=3.3.1 Received: from mail-ob0-f177.google.com (HELO mail-ob0-f177.google.com) (209.85.214.177) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 13 May 2013 06:02:50 +0000 Received: by mail-ob0-f177.google.com with SMTP id uz6so1259593obc.36 for ; Sun, 12 May 2013 23:02:48 -0700 (PDT) X-Received: by 10.60.149.231 with SMTP id ud7mr1107273oeb.119.1368424968695; Sun, 12 May 2013 23:02:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.60.13.133 with HTTP; Sun, 12 May 2013 23:02:08 -0700 (PDT) In-Reply-To: <516E01BD.5080101@codesourcery.com> References: <51665508.5050706@mentor.com> <5166558B.90201@mentor.com> <5166B259.10704@codesourcery.com> <516E01BD.5080101@codesourcery.com> From: Hui Zhu Date: Mon, 13 May 2013 06:02:00 -0000 Message-ID: Subject: Re: [PATCH] store trace default-collect to target [3/6] tfile To: gdb-patches ml Cc: Hui Zhu , Yao Qi Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2013-05/txt/msg00418.txt.bz2 Ping http://sourceware.org/ml/gdb-patches/2013-04/msg00502.html Thanks, Hui On Wed, Apr 17, 2013 at 9:58 AM, Yao Qi wrote: > On 04/16/2013 05:30 PM, Hui Zhu wrote: >> The old patch cannot patch to the upstream, so post a new version for th= at. >> >> Thanks, >> Hui >> >> 2013-04-16 Hui Zhu >> >> * ctf.c (ctf_write_default_collect): New. >> (trace_file_write_ops): Add ctf_write_default_collect. >> * tracepoint.c (tfile_write_default_collect): New. >> (trace_file_write_ops): Add tfile_write_default_collect. >> (trace_save): Call writer->ops->write_default_collect. >> (tfile_interp_line): Add collectp. >> (tfile_open): Add support of default collect. >> * tracepoint.h (trace_file_write_ops): Add write_default_collect. > > Hui, it is pity (again) to see you didn't incorporate my ctf part into > this patch, so I did it for you. > > -- > Yao (=E9=BD=90=E5=B0=A7) > > gdb: > > 2013-04-17 Hui Zhu > Yao Qi > > * ctf.c (CTF_EVENT_ID_DEFAULT_COLLECT): New macro. > (ctf_write_header): Write metadata for "default-collect" > action. > (ctf_write_default_collect): New. > (trace_file_write_ops): Add ctf_write_default_collect. > (ctf_read_default_collect): New. > (ctf_open): Call ctf_read_default_collect. > * tracepoint.c (tfile_write_default_collect): New. > (trace_file_write_ops): Add tfile_write_default_collect. > (trace_save): Call writer->ops->write_default_collect. > (tfile_interp_line): Add parameter 'collectp'. > (tfile_open): Add support of default collect. > * tracepoint.h (trace_file_write_ops) : > New. > --- > gdb/ctf.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++++ > gdb/tracepoint.c | 32 +++++++++++++++++++++++-- > gdb/tracepoint.h | 4 +++ > 3 files changed, 101 insertions(+), 3 deletions(-) > > diff --git a/gdb/ctf.c b/gdb/ctf.c > index b8252e4..413ce52 100644 > --- a/gdb/ctf.c > +++ b/gdb/ctf.c > @@ -75,6 +75,7 @@ > #define CTF_EVENT_ID_STATUS 4 > #define CTF_EVENT_ID_TSV_DEF 5 > #define CTF_EVENT_ID_TP_DEF 6 > +#define CTF_EVENT_ID_DEFAULT_COLLECT 7 > > /* The state kept while writing the CTF datastream file. */ > > @@ -429,6 +430,16 @@ ctf_write_header (struct trace_file_writer *self) > "\t};\n" > "};\n", CTF_EVENT_ID_TP_DEF); > > + ctf_save_write_metadata (&writer->tcs, "\n"); > + ctf_save_write_metadata (&writer->tcs, > + "event {\n\tname =3D \"default_collect\";\n" > + "\tid =3D %u;\n" > + "\tfields :=3D struct { \n" > + "\t\tchars contents;\n" > + "\t};\n" > + "};\n", > + CTF_EVENT_ID_DEFAULT_COLLECT); > + > gdb_assert (writer->tcs.content_size =3D=3D 0); > gdb_assert (writer->tcs.packet_start =3D=3D 0); > > @@ -617,6 +628,26 @@ ctf_write_uploaded_tp (struct trace_file_writer *sel= f, > } > > /* This is the implementation of trace_file_write_ops method > + write_default_collect. */ > + > +static void > +ctf_write_default_collect (struct trace_file_writer *self, > + char *collect) > +{ > + struct ctf_trace_file_writer *writer > + =3D (struct ctf_trace_file_writer *) self; > + int32_t int32; > + > + /* Event Id. */ > + int32 =3D CTF_EVENT_ID_DEFAULT_COLLECT; > + ctf_save_align_write (&writer->tcs, (gdb_byte *) &int32, 4, 4); > + > + /* Contents. */ > + ctf_save_write (&writer->tcs, collect, strlen (collect) + 1); > + > +} > + > +/* This is the implementation of trace_file_write_ops method > write_definition_end. */ > > static void > @@ -848,6 +879,7 @@ static const struct trace_file_write_ops ctf_write_op= s =3D > ctf_write_status, > ctf_write_uploaded_tsv, > ctf_write_uploaded_tp, > + ctf_write_default_collect, > ctf_write_definition_end, > NULL, > &ctf_write_frame_ops, > @@ -1138,6 +1170,40 @@ ctf_read_tp (struct uploaded_tp **uploaded_tps) > } > } > > +/* Read a CTF event on "default-collect" and update the > + "default-collect" action. */ > + > +static void > +ctf_read_default_collect (void) > +{ > + struct bt_ctf_event *event; > + const struct bt_definition *scope; > + uint32_t u32; > + char *default_collect; > + > + event =3D bt_ctf_iter_read_event (ctf_iter); > + scope =3D bt_ctf_get_top_level_scope (event, > + BT_STREAM_EVENT_HEADER); > + u32 =3D bt_ctf_get_uint64 (bt_ctf_get_field (event, scope, > + "id")); > + > + if (u32 !=3D CTF_EVENT_ID_DEFAULT_COLLECT) > + error (_("Wrong event id!")); > + > + scope =3D bt_ctf_get_top_level_scope (event, BT_EVENT_FIELDS); > + default_collect > + =3D bt_ctf_get_string (bt_ctf_get_field (event, scope, "contents")); > + > + if (default_collect =3D=3D NULL) > + default_collect =3D xstrdup (""); > + else > + default_collect =3D xstrdup (default_collect); > + > + trace_set_default_collect (default_collect); > + > + bt_iter_next (bt_ctf_get_iter (ctf_iter)); > +} > + > /* This is the implementation of target_ops method to_open. Open CTF > trace data, read trace status, trace state variables and tracepoint > definitions from the first packet. Set the start position at the > @@ -1179,6 +1245,8 @@ ctf_open (char *dirname, int from_tty) > > ctf_read_tp (&uploaded_tps); > > + ctf_read_default_collect (); > + > event =3D bt_ctf_iter_read_event (ctf_iter); > /* EVENT can be NULL if we've already gone to the end of stream of > events. */ > diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c > index c1c4d8f..b2ce6f4 100644 > --- a/gdb/tracepoint.c > +++ b/gdb/tracepoint.c > @@ -3237,6 +3237,19 @@ tfile_write_uploaded_tp (struct trace_file_writer = *self, > } > > /* This is the implementation of trace_file_write_ops method > + write_default_collect. */ > + > +static void > +tfile_write_default_collect (struct trace_file_writer *self, > + char *collect) > +{ > + struct tfile_trace_file_writer *writer > + =3D (struct tfile_trace_file_writer *) self; > + > + fprintf (writer->fp, "dc %s\n", collect); > +} > + > +/* This is the implementation of trace_file_write_ops method > write_definition_end. */ > > static void > @@ -3289,6 +3302,7 @@ static const struct trace_file_write_ops tfile_writ= e_ops =3D > tfile_write_status, > tfile_write_uploaded_tsv, > tfile_write_uploaded_tp, > + tfile_write_default_collect, > tfile_write_definition_end, > tfile_write_raw_data, > NULL, > @@ -3378,6 +3392,8 @@ trace_save (const char *filename, struct trace_file= _writer *writer, > for (utp =3D uploaded_tps; utp; utp =3D utp->next) > writer->ops->write_uploaded_tp (writer, utp); > > + writer->ops->write_default_collect (writer, default_collect); > + > free_uploaded_tps (&uploaded_tps); > > /* Mark the end of the definition section. */ > @@ -4147,7 +4163,8 @@ int trace_regblock_size; > > static void tfile_interp_line (char *line, > struct uploaded_tp **utpp, > - struct uploaded_tsv **utsvp); > + struct uploaded_tsv **utsvp, > + char **collectp); > > /* Read SIZE bytes into READBUF from the trace frame, starting at > TRACE_FD's current position. Note that this call `read' > @@ -4182,6 +4199,7 @@ tfile_open (char *filename, int from_tty) > struct trace_status *ts; > struct uploaded_tp *uploaded_tps =3D NULL; > struct uploaded_tsv *uploaded_tsvs =3D NULL; > + char *uploaded_default_collect =3D NULL; > > target_preopen (from_tty); > if (!filename) > @@ -4251,7 +4269,8 @@ tfile_open (char *filename, int from_tty) > break; > linebuf[i] =3D '\0'; > i =3D 0; > - tfile_interp_line (linebuf, &uploaded_tps, &uploaded_tsvs); > + tfile_interp_line (linebuf, &uploaded_tps, &uploaded_tsvs, > + &uploaded_default_collect); > } > else > linebuf[i++] =3D byte; > @@ -4289,6 +4308,8 @@ tfile_open (char *filename, int from_tty) > > merge_uploaded_tracepoints (&uploaded_tps); > > + trace_set_default_collect (uploaded_default_collect); > + > post_create_inferior (&tfile_ops, from_tty); > } > > @@ -4297,7 +4318,7 @@ tfile_open (char *filename, int from_tty) > > static void > tfile_interp_line (char *line, struct uploaded_tp **utpp, > - struct uploaded_tsv **utsvp) > + struct uploaded_tsv **utsvp, char **collectp) > { > char *p =3D line; > > @@ -4321,6 +4342,11 @@ tfile_interp_line (char *line, struct uploaded_tp = **utpp, > p +=3D strlen ("tsv "); > parse_tsv_definition (p, utsvp); > } > + else if (strncmp (p, "dc ", strlen ("dc ")) =3D=3D 0) > + { > + p +=3D strlen ("dc "); > + *collectp =3D xstrdup (p); > + } > else > warning (_("Ignoring trace file definition \"%s\""), line); > } > diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h > index 3bf8d8f..cc38121 100644 > --- a/gdb/tracepoint.h > +++ b/gdb/tracepoint.h > @@ -296,6 +296,10 @@ struct trace_file_write_ops > void (*write_uploaded_tp) (struct trace_file_writer *self, > struct uploaded_tp *tp); > > + /* Write the tracepoint default collect. */ > + void (*write_default_collect) (struct trace_file_writer *self, > + char *collect); > + > /* Write to mark the end of the definition part. */ > void (*write_definition_end) (struct trace_file_writer *self); > > -- > 1.7.7.6