[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191217183641.1729b821@gandalf.local.home>
Date: Tue, 17 Dec 2019 18:36:41 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: David Laight <David.Laight@...LAB.COM>
Cc: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Sudip Mukherjee <sudipm.mukherjee@...il.com>
Subject: Re: ftrace trace_raw_pipe format
On Tue, 17 Dec 2019 17:34:03 -0500
Steven Rostedt <rostedt@...dmis.org> wrote:
> static void read_raw_buffer(int i, const char *buffer)
> {
> struct trace_seq s;
> char buf[page_size];
> int fd;
> int r;
>
> printf("Parsing CPU %d buffer\n", i);
>
> fd = open(buffer, O_RDONLY);
> if (fd < 0)
> pdie("Failed to open %s", buffer);
>
> while ((r = read(fd, buf, page_size)) > 0) {
> kbuffer_load_subbuffer(kbuf, buf);
>
> for (;;) {
> struct tep_record record;
>
> record.data = kbuffer_read_event(kbuf, &record.ts);
> if (!record.data)
> break;
> kbuffer_next_event(kbuf, NULL);
>
Also note, once you are here, you don't need to use the
tep_print_event() to print out the fields of record. You can also
extract the data from the event directly. Or you could register a
handler that will get called via the tep_print_event().
Attached is a new version that has some fixes as well as adds its own
sched_switch handler.
-- Steve
> trace_seq_init(&s);
> tep_print_event(tep, &s, &record,
> "%s-%d %9d\t%s: %s\n",
> TEP_PRINT_COMM,
> TEP_PRINT_PID,
> TEP_PRINT_TIME,
> TEP_PRINT_NAME,
> TEP_PRINT_INFO);
> trace_seq_do_printf(&s);
> }
> }
>
> close(fd);
> }
View attachment "read-trace-pipe-raw.c" of type "text/x-c++src" (9620 bytes)
Powered by blists - more mailing lists