linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Subject: [PATCH 2/2] trace-cmd: Use usecs unless specified not to
Date: Fri, 25 Oct 2019 02:52:45 -0400	[thread overview]
Message-ID: <20191025065323.618139839@goodmis.org> (raw)
In-Reply-To: 20191025065243.627023108@goodmis.org

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

Old trace-cmd data files did not have an option to store the clock that was
used. It was always assumed that the clock would be in usecs. If there's no
clock in the options of the trace.dat file, then use usecs by default to
stay compatible with older versions of trace-cmd trace.dat files.

Fixes: 150d479b623a ("libtraceevent, perf tools: Changes in tep_print_event_* APIs")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 lib/trace-cmd/trace-input.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 43bdf6ace33b..ef8f0762a535 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -2311,6 +2311,9 @@ static int handle_options(struct tracecmd_input *handle)
 	char *buf;
 	int cpus;
 
+	/* By default, use usecs, unless told otherwise */
+	handle->flags |= TRACECMD_FL_IN_USECS;
+
 	for (;;) {
 		if (do_read_check(handle, &option, 2))
 			return -1;
@@ -2586,10 +2589,11 @@ static void extract_trace_clock(struct tracecmd_input *handle, char *line)
 	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;
+	/* Clear usecs if not one of the specified clocks */
+	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.23.0



      parent reply	other threads:[~2019-10-25  6:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25  6:52 [PATCH 0/2] trace-cmd: Fixes for reading older trace-cmd trace.dat files Steven Rostedt
2019-10-25  6:52 ` [PATCH 1/2] libtraceevent: Remove extra \n in print_event_time() Steven Rostedt
2019-10-25  6:52 ` Steven Rostedt [this message]

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=20191025065323.618139839@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    /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).