linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] trace-cmd: Fixes for reading older trace-cmd trace.dat files
@ 2019-10-25  6:52 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 ` [PATCH 2/2] trace-cmd: Use usecs unless specified not to Steven Rostedt
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Rostedt @ 2019-10-25  6:52 UTC (permalink / raw)
  To: linux-trace-devel


Fix two bugs that caused reading an trace.dat file created
by an older trace-cmd not to print properly.

Steven Rostedt (VMware) (2):
      libtraceevent: Remove extra '\n' in print_event_time()
      trace-cmd: Use usecs unless specified not to

----
 lib/trace-cmd/trace-input.c  | 12 ++++++++----
 lib/traceevent/event-parse.c |  2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] libtraceevent: Remove extra \n in print_event_time()
  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 ` Steven Rostedt
  2019-10-25  6:52 ` [PATCH 2/2] trace-cmd: Use usecs unless specified not to Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2019-10-25  6:52 UTC (permalink / raw)
  To: linux-trace-devel

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

If the precesion of print_event_time() is zero or greater than the
timestamp, it uses a different format. But that format had an extra new line
at the end, and caused the output to not look right:

cpus=2
           sleep-3946  [001]111264306005
: function:             inotify_inode_queue_event
           sleep-3946  [001]111264307158
: function:             __fsnotify_parent
           sleep-3946  [001]111264307637
: function:             inotify_dentry_parent_queue_event
           sleep-3946  [001]111264307989
: function:             fsnotify
           sleep-3946  [001]111264308401
: function:             audit_syscall_exit

Fixes: 150d479b623a ("libtraceevent, perf tools: Changes in tep_print_event_* APIs")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 lib/traceevent/event-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/traceevent/event-parse.c b/lib/traceevent/event-parse.c
index eb84fbb49e4d..0a49eb936b34 100644
--- a/lib/traceevent/event-parse.c
+++ b/lib/traceevent/event-parse.c
@@ -5528,7 +5528,7 @@ static void print_event_time(struct tep_handle *tep, struct trace_seq *s,
 	if (p10 > 1 && p10 < time)
 		trace_seq_printf(s, "%5llu.%0*llu", time / p10, prec, time % p10);
 	else
-		trace_seq_printf(s, "%12llu\n", time);
+		trace_seq_printf(s, "%12llu", time);
 }
 
 struct print_event_type {
-- 
2.23.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] trace-cmd: Use usecs unless specified not to
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2019-10-25  6:52 UTC (permalink / raw)
  To: linux-trace-devel

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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-25  6:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/2] trace-cmd: Use usecs unless specified not to Steven Rostedt

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).