diff mbox series

[2/5] trace-cmd: Separate out time diff code in trace_show_data()

Message ID 20190918020530.499901908@goodmis.org (mailing list archive)
State Superseded
Headers show
Series trace-cmd: Update for the new trace_print_event() logic | expand

Commit Message

Steven Rostedt Sept. 18, 2019, 2:03 a.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

To make it easier to convert to the new tep_print_event() format, use the
open coded version of the tracing data regardless if a different timestamp
is to be used.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tracecmd/trace-read.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

Comments

Tzvetomir Stoyanov Sept. 20, 2019, 3:08 p.m. UTC | #1
On Wed, Sep 18, 2019 at 5:03 AM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
>
> To make it easier to convert to the new tep_print_event() format, use the
> open coded version of the tracing data regardless if a different timestamp
> is to be used.
>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
>  tracecmd/trace-read.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c
> index c14e87f76a32..01d904964edf 100644
> --- a/tracecmd/trace-read.c
> +++ b/tracecmd/trace-read.c
> @@ -757,6 +757,7 @@ void trace_show_data(struct tracecmd_input *handle, struct tep_record *record)
>  {
>         tracecmd_show_data_func func = tracecmd_get_show_data_func(handle);
>         struct tep_handle *pevent;
> +       struct tep_event *event;
>         struct trace_seq s;
>         int cpu = record->cpu;
>         bool use_trace_clock;
> @@ -793,14 +794,13 @@ void trace_show_data(struct tracecmd_input *handle, struct tep_record *record)
>                 }
>         }
>         use_trace_clock = tracecmd_get_use_trace_clock(handle);
> +       event = tep_find_event_by_record(pevent, record);
> +       tep_print_event_task(pevent, &s, event, record);
> +       tep_print_event_time(pevent, &s, event, record,
> +                            use_trace_clock);
>         if (tsdiff) {
>                 unsigned long long rec_ts = record->ts;
> -               struct tep_event *event;
>
> -               event = tep_find_event_by_record(pevent, record);
> -               tep_print_event_task(pevent, &s, event, record);
> -               tep_print_event_time(pevent, &s, event, record,
> -                                       use_trace_clock);
>                 buf[0] = 0;
>                 if (use_trace_clock && !tep_test_flag(pevent, TEP_NSEC_OUTPUT))
>                         rec_ts = (rec_ts + 500) / 1000;
> @@ -811,9 +811,10 @@ void trace_show_data(struct tracecmd_input *handle, struct tep_record *record)
>                 }
>                 last_ts = rec_ts;
>                 trace_seq_printf(&s, " %-8s", buf);
> -               tep_print_event_data(pevent, &s, event, record);
> -       } else
> -               tep_print_event(pevent, &s, record, use_trace_clock);
> +       }
> +
> +       tep_print_event_data(pevent, &s, event, record);
> +
>         if (s.len && *(s.buffer + s.len - 1) == '\n')
>                 s.len--;
>         if (tracecmd_get_debug()) {
> --
> 2.20.1
>
>

Looks good to me.
Reviewed-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
diff mbox series

Patch

diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c
index c14e87f76a32..01d904964edf 100644
--- a/tracecmd/trace-read.c
+++ b/tracecmd/trace-read.c
@@ -757,6 +757,7 @@  void trace_show_data(struct tracecmd_input *handle, struct tep_record *record)
 {
 	tracecmd_show_data_func func = tracecmd_get_show_data_func(handle);
 	struct tep_handle *pevent;
+	struct tep_event *event;
 	struct trace_seq s;
 	int cpu = record->cpu;
 	bool use_trace_clock;
@@ -793,14 +794,13 @@  void trace_show_data(struct tracecmd_input *handle, struct tep_record *record)
 		}
 	}
 	use_trace_clock = tracecmd_get_use_trace_clock(handle);
+	event = tep_find_event_by_record(pevent, record);
+	tep_print_event_task(pevent, &s, event, record);
+	tep_print_event_time(pevent, &s, event, record,
+			     use_trace_clock);
 	if (tsdiff) {
 		unsigned long long rec_ts = record->ts;
-		struct tep_event *event;
 
-		event = tep_find_event_by_record(pevent, record);
-		tep_print_event_task(pevent, &s, event, record);
-		tep_print_event_time(pevent, &s, event, record,
-					use_trace_clock);
 		buf[0] = 0;
 		if (use_trace_clock && !tep_test_flag(pevent, TEP_NSEC_OUTPUT))
 			rec_ts = (rec_ts + 500) / 1000;
@@ -811,9 +811,10 @@  void trace_show_data(struct tracecmd_input *handle, struct tep_record *record)
 		}
 		last_ts = rec_ts;
 		trace_seq_printf(&s, " %-8s", buf);
-		tep_print_event_data(pevent, &s, event, record);
-	} else
-		tep_print_event(pevent, &s, record, use_trace_clock);
+	}
+
+	tep_print_event_data(pevent, &s, event, record);
+
 	if (s.len && *(s.buffer + s.len - 1) == '\n')
 		s.len--;
 	if (tracecmd_get_debug()) {