From: Hui Zhu <teawater@gmail.com>
To: gdb-patches ml <gdb-patches@sourceware.org>
Cc: Hui Zhu <hui_zhu@mentor.com>, Yao Qi <yao@codesourcery.com>
Subject: Re: [PATCH] store trace default-collect to target [3/6] tfile
Date: Tue, 16 Apr 2013 15:34:00 -0000 [thread overview]
Message-ID: <CANFwon13paiR+pLnYpvKzAYCO5iMXWomyVBpwXjiJG9ufKO9ZA@mail.gmail.com> (raw)
In-Reply-To: <CANFwon2V1Vh12kHcjrrfR9ZJLam2Y7XfPfSyRVy1w1d_fi5Zeg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 6546 bytes --]
The old patch cannot patch to the upstream, so post a new version for that.
Thanks,
Hui
2013-04-16 Hui Zhu <hui@codesourcery.com>
* 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.
On Mon, Apr 15, 2013 at 11:11 PM, Hui Zhu <teawater@gmail.com> wrote:
> Post a new version to fix the typo of "collest".
>
> Thanks,
> Hui
>
> 2013-04-15 Hui Zhu <hui@codesourcery.com>
>
> * 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.
>
> On Fri, Apr 12, 2013 at 6:45 PM, Hui Zhu <teawater@gmail.com> wrote:
>> 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 <yao@codesourcery.com> 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 (齐尧)
>>>
>>> gdb:
>>>
>>> 2013-04-11 Yao Qi <yao@codesourcery.com>
>>>
>>> * 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 = \"default_collect\";\n"
>>> + "\tid = %u;\n"
>>> + "\tfields := struct { \n"
>>> + "\t\tchars contents;\n"
>>> + "\t};\n"
>>> + "};\n",
>>> + CTF_EVENT_ID_DEFAULT_COLLECT);
>>> +
>>> gdb_assert (writer->tcs.content_size == 0);
>>> gdb_assert (writer->tcs.packet_start == 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
>>> + = (struct ctf_trace_file_writer *) self;
>>> + int32_t int32;
>>> +
>>> + /* Event Id. */
>>> + int32 = 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 = bt_ctf_iter_read_event (ctf_iter);
>>> + scope = bt_ctf_get_top_level_scope (event,
>>> + BT_STREAM_EVENT_HEADER);
>>> + u32 = bt_ctf_get_uint64 (bt_ctf_get_field (event, scope,
>>> + "id"));
>>> +
>>> + if (u32 != CTF_EVENT_ID_DEFAULT_COLLECT)
>>> + error (_("Wrong event id!"));
>>> +
>>> + default_collect
>>> + = bt_ctf_get_string (bt_ctf_get_field (event, scope, "contents"));
>>> +
>>> + if (default_collect == NULL)
>>> + default_collect = xstrdup ("");
>>> + else
>>> + default_collect = 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 = 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
[-- Attachment #2: defc-tfile.txt --]
[-- Type: text/plain, Size: 4062 bytes --]
--- a/ctf.c
+++ b/ctf.c
@@ -617,6 +617,17 @@ ctf_write_uploaded_tp (struct trace_file
}
/* 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. */
+}
+
+/* This is the implementation of trace_file_write_ops method
write_definition_end. */
static void
@@ -848,6 +859,7 @@ static const struct trace_file_write_ops
ctf_write_status,
ctf_write_uploaded_tsv,
ctf_write_uploaded_tp,
+ ctf_write_default_collect,
ctf_write_definition_end,
NULL,
&ctf_write_frame_ops,
--- a/tracepoint.c
+++ b/tracepoint.c
@@ -3237,6 +3237,19 @@ tfile_write_uploaded_tp (struct trace_fi
}
/* 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
+ = (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_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
for (utp = uploaded_tps; utp; utp = 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 = NULL;
struct uploaded_tsv *uploaded_tsvs = NULL;
+ char *uploaded_default_collect = NULL;
target_preopen (from_tty);
if (!filename)
@@ -4251,7 +4269,8 @@ tfile_open (char *filename, int from_tty
break;
linebuf[i] = '\0';
i = 0;
- tfile_interp_line (linebuf, &uploaded_tps, &uploaded_tsvs);
+ tfile_interp_line (linebuf, &uploaded_tps, &uploaded_tsvs,
+ &uploaded_default_collect);
}
else
linebuf[i++] = 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 = line;
@@ -4321,6 +4342,11 @@ tfile_interp_line (char *line, struct up
p += strlen ("tsv ");
parse_tsv_definition (p, utsvp);
}
+ else if (strncmp (p, "dc ", strlen ("dc ")) == 0)
+ {
+ p += strlen ("dc ");
+ *collectp = xstrdup (p);
+ }
else
warning (_("Ignoring trace file definition \"%s\""), line);
}
--- a/tracepoint.h
+++ b/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);
next prev parent reply other threads:[~2013-04-16 9:31 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-11 8:35 [PATCH] store trace default-collect to target [0/6] Hui Zhu
2013-04-11 8:37 ` [PATCH] store trace default-collect to target [1/6] target, trace and remote Hui Zhu
2013-04-11 22:58 ` Yao Qi
2013-04-16 15:22 ` Hui Zhu
2013-05-13 6:00 ` Hui Zhu
2013-04-11 22:59 ` Abid, Hafiz
2013-04-11 9:14 ` [PATCH] store trace default-collect to target [2/6] gdbserver Hui Zhu
2013-05-13 6:01 ` Hui Zhu
2013-04-11 10:33 ` [PATCH] store trace default-collect to target [3/6] tfile Hui Zhu
2013-04-11 22:59 ` Yao Qi
2013-04-12 14:58 ` Hui Zhu
2013-04-15 19:01 ` Hui Zhu
2013-04-16 15:34 ` Hui Zhu [this message]
2013-04-17 11:21 ` Yao Qi
2013-05-13 6:02 ` Hui Zhu
2013-04-11 10:36 ` [PATCH] store trace default-collect to target [4/6] save tracepoint Hui Zhu
2013-05-13 6:03 ` Hui Zhu
2013-04-11 10:48 ` [PATCH] store trace default-collect to target [5/6] doc Hui Zhu
2013-04-11 22:59 ` Yao Qi
2013-04-16 14:35 ` Hui Zhu
2013-04-11 23:00 ` Eli Zaretskii
2013-04-16 15:39 ` Hui Zhu
2013-04-16 15:44 ` Eli Zaretskii
2013-04-16 15:44 ` Hui Zhu
2013-05-13 6:04 ` Hui Zhu
2013-05-13 16:02 ` Eli Zaretskii
2013-05-14 1:36 ` Hui Zhu
2013-04-11 10:49 ` [PATCH] store trace default-collect to target [6/6] test Hui Zhu
2013-04-11 13:14 ` Yao Qi
2013-04-11 14:01 ` Hui Zhu
2013-04-11 15:24 ` Yao Qi
2013-04-16 15:44 ` Hui Zhu
2013-05-13 6:06 ` Hui Zhu
2013-05-13 5:33 ` [PATCH] store trace default-collect to target [0/6] Hui Zhu
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=CANFwon13paiR+pLnYpvKzAYCO5iMXWomyVBpwXjiJG9ufKO9ZA@mail.gmail.com \
--to=teawater@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=hui_zhu@mentor.com \
--cc=yao@codesourcery.com \
/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