diff options
author | Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com> | 2013-11-01 17:53:53 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-11-04 12:33:12 -0500 |
commit | 1b372ca52a02cc97520c13d79bdfb0a7ff81b772 (patch) | |
tree | e954efc1834b4d76dfc832b7cc946fe9d5e7497f /tools/lib/traceevent/event-parse.c | |
parent | cc03c54296ccbeca5363dfe8f49af42d14960f28 (diff) |
tools lib traceevent: Add support for extracting trace_clock in report
If trace-cmd extracts trace_clock, trace-cmd reads trace_clock data from
the trace.dat and switches outputting format of timestamp for each
trace_clock.
Signed-off-by: Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20130424231305.14877.86147.stgit@yunodevel
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/traceevent/event-parse.c')
-rw-r--r-- | tools/lib/traceevent/event-parse.c | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index d1c2a6a4cd32..deedff9d06af 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c | |||
@@ -305,6 +305,11 @@ int pevent_register_comm(struct pevent *pevent, const char *comm, int pid) | |||
305 | return 0; | 305 | return 0; |
306 | } | 306 | } |
307 | 307 | ||
308 | void pevent_register_trace_clock(struct pevent *pevent, char *trace_clock) | ||
309 | { | ||
310 | pevent->trace_clock = trace_clock; | ||
311 | } | ||
312 | |||
308 | struct func_map { | 313 | struct func_map { |
309 | unsigned long long addr; | 314 | unsigned long long addr; |
310 | char *func; | 315 | char *func; |
@@ -4443,8 +4448,21 @@ void pevent_event_info(struct trace_seq *s, struct event_format *event, | |||
4443 | trace_seq_terminate(s); | 4448 | trace_seq_terminate(s); |
4444 | } | 4449 | } |
4445 | 4450 | ||
4451 | static bool is_timestamp_in_us(char *trace_clock, bool use_trace_clock) | ||
4452 | { | ||
4453 | if (!use_trace_clock) | ||
4454 | return true; | ||
4455 | |||
4456 | if (!strcmp(trace_clock, "local") || !strcmp(trace_clock, "global") | ||
4457 | || !strcmp(trace_clock, "uptime") || !strcmp(trace_clock, "perf")) | ||
4458 | return true; | ||
4459 | |||
4460 | /* trace_clock is setting in tsc or counter mode */ | ||
4461 | return false; | ||
4462 | } | ||
4463 | |||
4446 | void pevent_print_event(struct pevent *pevent, struct trace_seq *s, | 4464 | void pevent_print_event(struct pevent *pevent, struct trace_seq *s, |
4447 | struct pevent_record *record) | 4465 | struct pevent_record *record, bool use_trace_clock) |
4448 | { | 4466 | { |
4449 | static const char *spaces = " "; /* 20 spaces */ | 4467 | static const char *spaces = " "; /* 20 spaces */ |
4450 | struct event_format *event; | 4468 | struct event_format *event; |
@@ -4457,9 +4475,14 @@ void pevent_print_event(struct pevent *pevent, struct trace_seq *s, | |||
4457 | int pid; | 4475 | int pid; |
4458 | int len; | 4476 | int len; |
4459 | int p; | 4477 | int p; |
4478 | bool use_usec_format; | ||
4460 | 4479 | ||
4461 | secs = record->ts / NSECS_PER_SEC; | 4480 | use_usec_format = is_timestamp_in_us(pevent->trace_clock, |
4462 | nsecs = record->ts - secs * NSECS_PER_SEC; | 4481 | use_trace_clock); |
4482 | if (use_usec_format) { | ||
4483 | secs = record->ts / NSECS_PER_SEC; | ||
4484 | nsecs = record->ts - secs * NSECS_PER_SEC; | ||
4485 | } | ||
4463 | 4486 | ||
4464 | if (record->size < 0) { | 4487 | if (record->size < 0) { |
4465 | do_warning("ug! negative record size %d", record->size); | 4488 | do_warning("ug! negative record size %d", record->size); |
@@ -4484,15 +4507,20 @@ void pevent_print_event(struct pevent *pevent, struct trace_seq *s, | |||
4484 | } else | 4507 | } else |
4485 | trace_seq_printf(s, "%16s-%-5d [%03d]", comm, pid, record->cpu); | 4508 | trace_seq_printf(s, "%16s-%-5d [%03d]", comm, pid, record->cpu); |
4486 | 4509 | ||
4487 | if (pevent->flags & PEVENT_NSEC_OUTPUT) { | 4510 | if (use_usec_format) { |
4488 | usecs = nsecs; | 4511 | if (pevent->flags & PEVENT_NSEC_OUTPUT) { |
4489 | p = 9; | 4512 | usecs = nsecs; |
4490 | } else { | 4513 | p = 9; |
4491 | usecs = (nsecs + 500) / NSECS_PER_USEC; | 4514 | } else { |
4492 | p = 6; | 4515 | usecs = (nsecs + 500) / NSECS_PER_USEC; |
4493 | } | 4516 | p = 6; |
4517 | } | ||
4494 | 4518 | ||
4495 | trace_seq_printf(s, " %5lu.%0*lu: %s: ", secs, p, usecs, event->name); | 4519 | trace_seq_printf(s, " %5lu.%0*lu: %s: ", |
4520 | secs, p, usecs, event->name); | ||
4521 | } else | ||
4522 | trace_seq_printf(s, " %12llu: %s: ", | ||
4523 | record->ts, event->name); | ||
4496 | 4524 | ||
4497 | /* Space out the event names evenly. */ | 4525 | /* Space out the event names evenly. */ |
4498 | len = strlen(event->name); | 4526 | len = strlen(event->name); |