From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3180 invoked by alias); 12 Apr 2013 10:46:01 -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 3170 invoked by uid 89); 12 Apr 2013 10:46:01 -0000 X-Spam-SWARE-Status: No, score=-4.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE autolearn=ham version=3.3.1 Received: from mail-oa0-f43.google.com (HELO mail-oa0-f43.google.com) (209.85.219.43) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 12 Apr 2013 10:46:00 +0000 Received: by mail-oa0-f43.google.com with SMTP id l10so2401499oag.30 for ; Fri, 12 Apr 2013 03:45:59 -0700 (PDT) X-Received: by 10.60.63.11 with SMTP id c11mr3778794oes.28.1365763559073; Fri, 12 Apr 2013 03:45:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.60.13.133 with HTTP; Fri, 12 Apr 2013 03:45:19 -0700 (PDT) In-Reply-To: <5166B259.10704@codesourcery.com> References: <51665508.5050706@mentor.com> <5166558B.90201@mentor.com> <5166B259.10704@codesourcery.com> From: Hui Zhu Date: Fri, 12 Apr 2013 14:58:00 -0000 Message-ID: Subject: Re: [PATCH] store trace default-collect to target [3/6] tfile To: Yao Qi Cc: Hui Zhu , gdb-patches ml Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2013-04/txt/msg00379.txt.bz2 Hi Yao, Thanks for your patch. I should do it but I didn't because when I work on this part I cannot find example in GDB src bceause the code that can be example is still not check in. :P Best, Hui On Thu, Apr 11, 2013 at 8:53 PM, Yao Qi wrote: > On 04/11/2013 02:17 PM, Hui Zhu wrote: >> /* 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) >> +{ >> + /* It is not supported yet to write default collect >> + into CTF trace data. */ >> +} >> + > > It is pity to see "default-collect" is not written to CTF in this > patch. The patch below is about teaching GDB to write > "default-collect" action in CTF and read "default-collect" action from > CTF. Do you mind incorporating the patch below into your patch series, > so that your series is more complete. > > -- > Yao (=E9=BD=90=E5=B0=A7) > > gdb: > > 2013-04-11 Yao Qi > > * ctf.c (CTF_EVENT_ID_DEFAULT_COLLECT): New macro. > (ctf_write_header): Write metadata for "default-collect" > action. > (ctf_write_default_collect): Write "default-collect" action > in CTF. > (ctf_read_default_collect): New. > (ctf_open): Call ctf_read_default_collect. > --- > gdb/ctf.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++-- > 1 files changed, 57 insertions(+), 2 deletions(-) > > diff --git a/gdb/ctf.c b/gdb/ctf.c > index 2dd2ed8..5757b47 100644 > --- a/gdb/ctf.c > +++ b/gdb/ctf.c > @@ -74,6 +74,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. */ > > @@ -428,6 +429,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); > > @@ -622,8 +633,17 @@ static void > ctf_write_default_collect (struct trace_file_writer *self, > char *collect) > { > - /* It is not supported yet to write default collect > - into CTF trace data. */ > + 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 > @@ -1149,6 +1169,39 @@ 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!")); > + > + 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 > @@ -1190,6 +1243,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. */ > -- > 1.7.7.6