From: Steven Rostedt <rostedt@goodmis.org>
To: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH 3/6] trace-cmd library man pages: Read recorded events from a trace file.
Date: Wed, 13 Jan 2021 17:18:08 -0500 [thread overview]
Message-ID: <20210113171808.23c7cf5e@gandalf.local.home> (raw)
In-Reply-To: <20201223043429.586162-4-tz.stoyanov@gmail.com>
I think the below example should be also used in the tracecmd_open_head()
man page. That's because the current example in tracecmd_open_head() is
rather useless as nothing really can be done without the
tracecmd_init_data() call. By using the below example in the
tracecmd_open_head() page, it will show people a more informative way of
using that call.
Note, these man pages are already applied, any update should be done on top
of the current repo.
-- Steve
On Wed, 23 Dec 2020 06:34:26 +0200
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:
> +EXAMPLE
> +-------
> +[source,c]
> +--
> +#include <trace-cmd.h>
> +...
> +struct tracecmd_input *handle = tracecmd_open_head("trace.dat");
> + if (!handle) {
> + /* Failed to open trace.dat file */
> + }
> +...
> +unsigned long long offset = 0;
> +struct tep_record *rec;
> +int cpu = 0;
> +
> + if (tracecmd_init_data(handle) < 0) {
> + /* Failed to initialize hadle for reading the trace data */
> + }
> +
> + rec = tracecmd_read_cpu_first(handle, cpu);
> + while (rec) {
> + ...
> + if ( /* some interesting record noticed */) {
> + /* store the offset of the interesting record */
> + offset = rec->offset;
> + }
> + ...
> + tracecmd_free_record(rec);
> + rec = tracecmd_read_data(handle, cpu);
> + }
> + ...
> + if (offset) {
> + rec = tracecmd_read_at(handle, offset, &cpu);
> + if (rec) {
> + /* Got record at offset on cpu */
> + ...
> + tracecmd_free_record(rec);
> + }
> + }
> +
> +...
> + tracecmd_close(hadle);
> +
next prev parent reply other threads:[~2021-01-14 2:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-23 4:34 [PATCH 0/6] libtracecmd man pages Tzvetomir Stoyanov (VMware)
2020-12-23 4:34 ` [PATCH 1/6] trace-cmd: " Tzvetomir Stoyanov (VMware)
2020-12-23 4:34 ` [PATCH 2/6] trace-cmd: Update the RESOURCES section of the trace-cmd " Tzvetomir Stoyanov (VMware)
2020-12-23 4:34 ` [PATCH 3/6] trace-cmd library man pages: Read recorded events from a trace file Tzvetomir Stoyanov (VMware)
2021-01-13 22:18 ` Steven Rostedt [this message]
2020-12-23 4:34 ` [PATCH 4/6] trace-cmd library man pages: Open and close " Tzvetomir Stoyanov (VMware)
2020-12-23 4:34 ` [PATCH 5/6] trace-cmd library man pages: Manage trace session with multiple trace peers Tzvetomir Stoyanov (VMware)
2021-01-13 22:13 ` Steven Rostedt
2021-01-15 5:02 ` Tzvetomir Stoyanov
2020-12-23 4:34 ` [PATCH 6/6] trace-cmd library man pages: Read tracing instances from a trace file Tzvetomir Stoyanov (VMware)
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=20210113171808.23c7cf5e@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=tz.stoyanov@gmail.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;
as well as URLs for NNTP newsgroup(s).