[3/5] trace-cmd: Add check for trace_clock using usecs into tracecmd_parse_trace_clock()
diff mbox series

Message ID 20190918020530.655810800@goodmis.org
State New
Headers show
Series
  • trace-cmd: Update for the new trace_print_event() logic
Related show

Commit Message

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

In preparation for using the new tep_print_event() format, move the logic of
checking if the trace_clock used should be default as printed in usecs into
tracecmd_parse_trace_clock() when it parses the trace_clock.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 include/trace-cmd/trace-cmd.h | 1 +
 lib/trace-cmd/trace-input.c   | 8 ++++++++
 2 files changed, 9 insertions(+)

Comments

Tzvetomir Stoyanov Sept. 20, 2019, 3:10 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>
>
> In preparation for using the new tep_print_event() format, move the logic of
> checking if the trace_clock used should be default as printed in usecs into
> tracecmd_parse_trace_clock() when it parses the trace_clock.
>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
>  include/trace-cmd/trace-cmd.h | 1 +
>  lib/trace-cmd/trace-input.c   | 8 ++++++++
>  2 files changed, 9 insertions(+)
>
> diff --git a/include/trace-cmd/trace-cmd.h b/include/trace-cmd/trace-cmd.h
> index eb36a1f20c30..7c3bc2229461 100644
> --- a/include/trace-cmd/trace-cmd.h
> +++ b/include/trace-cmd/trace-cmd.h
> @@ -87,6 +87,7 @@ enum {
>         TRACECMD_FL_IGNORE_DATE         = (1 << 0),
>         TRACECMD_FL_BUFFER_INSTANCE     = (1 << 1),
>         TRACECMD_FL_LATENCY             = (1 << 2),
> +       TRACECMD_FL_IN_USECS            = (1 << 3),
>  };
>
>  struct tracecmd_ftrace {
> diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
> index 5533d42fd7c2..73f27a4e50d0 100644
> --- a/lib/trace-cmd/trace-input.c
> +++ b/lib/trace-cmd/trace-input.c
> @@ -2582,6 +2582,14 @@ static void extract_trace_clock(struct tracecmd_input *handle, char *line)
>         sscanf(data, "%ms", &clock);
>         /* TODO: report if it fails to allocate */
>         handle->trace_clock = clock;
> +
> +       if (!clock)
> +               return;
> +
> +       if (!strcmp(clock, "local") || !strcmp(clock, "global")
> +           || !strcmp(clock, "uptime") || !strcmp(clock, "perf")
> +           || !strncmp(clock, "mono", 4))
> +               handle->flags |= TRACECMD_FL_IN_USECS;
>  }
>
>  void tracecmd_parse_trace_clock(struct tracecmd_input *handle,
> --
> 2.20.1
>
>

Looks OK.
Reviewed-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>

Patch
diff mbox series

diff --git a/include/trace-cmd/trace-cmd.h b/include/trace-cmd/trace-cmd.h
index eb36a1f20c30..7c3bc2229461 100644
--- a/include/trace-cmd/trace-cmd.h
+++ b/include/trace-cmd/trace-cmd.h
@@ -87,6 +87,7 @@  enum {
 	TRACECMD_FL_IGNORE_DATE		= (1 << 0),
 	TRACECMD_FL_BUFFER_INSTANCE	= (1 << 1),
 	TRACECMD_FL_LATENCY		= (1 << 2),
+	TRACECMD_FL_IN_USECS		= (1 << 3),
 };
 
 struct tracecmd_ftrace {
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 5533d42fd7c2..73f27a4e50d0 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -2582,6 +2582,14 @@  static void extract_trace_clock(struct tracecmd_input *handle, char *line)
 	sscanf(data, "%ms", &clock);
 	/* TODO: report if it fails to allocate */
 	handle->trace_clock = clock;
+
+	if (!clock)
+		return;
+
+	if (!strcmp(clock, "local") || !strcmp(clock, "global")
+	    || !strcmp(clock, "uptime") || !strcmp(clock, "perf")
+	    || !strncmp(clock, "mono", 4))
+		handle->flags |= TRACECMD_FL_IN_USECS;
 }
 
 void tracecmd_parse_trace_clock(struct tracecmd_input *handle,