aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2016-06-23 09:40:56 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-06-23 15:36:59 -0400
commit055cd33d93ac310ce68e8b1ebcf88f829426adf5 (patch)
tree6805b938987d14e661c0522768bed7b0d7a546d8
parent10daf4d01bad77c6ae862367ad2148a8340d94e6 (diff)
perf script: Print sample flags more nicely
The flags field is synthesized and may have a value when Instruction Trace decoding. The flags are "bcrosyiABEx" which stand for branch, call, return, conditional, system, asynchronous, interrupt, transaction abort, trace begin, trace end, and in transaction, respectively. Change the display so that known combinations of flags are printed more nicely e.g.: "call" for "bc", "return" for "br", "jcc" for "bo", "jmp" for "b", "int" for "bci", "iret" for "bri", "syscall" for "bcs", "sysret" for "brs", "async" for "by", "hw int" for "bcyi", "tx abrt" for "bA", "tr strt" for "bB", "tr end" for "bE". However the "x" flag will be displayed separately in those cases e.g. "jcc (x)" for a condition branch within a transaction. Example: perf record -e intel_pt//u ls perf script --ns -F comm,cpu,pid,tid,time,ip,addr,sym,dso,symoff,flags ... ls 3689/3689 [001] 2062.020965237: jcc 7f06a958847a _dl_sysdep_start+0xfa (/lib/x86_64-linux-gnu/ld-2.19.so) => 7f06a9588450 _dl_sysdep_start+0xd0 (/lib/x86_64-linux-gnu/ld-2.19.so) ls 3689/3689 [001] 2062.020965237: jmp 7f06a9588461 _dl_sysdep_start+0xe1 (/lib/x86_64-linux-gnu/ld-2.19.so) => 7f06a95885a0 _dl_sysdep_start+0x220 (/lib/x86_64-linux-gnu/ld-2.19.so) ls 3689/3689 [001] 2062.020965237: jmp 7f06a95885a4 _dl_sysdep_start+0x224 (/lib/x86_64-linux-gnu/ld-2.19.so) => 7f06a9588470 _dl_sysdep_start+0xf0 (/lib/x86_64-linux-gnu/ld-2.19.so) ls 3689/3689 [001] 2062.020965904: call 7f06a95884c3 _dl_sysdep_start+0x143 (/lib/x86_64-linux-gnu/ld-2.19.so) => 7f06a9589140 brk+0x0 (/lib/x86_64-linux-gnu/ld-2.19.so) ls 3689/3689 [001] 2062.020965904: syscall 7f06a958914a brk+0xa (/lib/x86_64-linux-gnu/ld-2.19.so) => 0 [unknown] ([unknown]) ls 3689/3689 [001] 2062.020966237: tr strt 0 [unknown] ([unknown]) => 7f06a958914c brk+0xc (/lib/x86_64-linux-gnu/ld-2.19.so) ls 3689/3689 [001] 2062.020966237: return 7f06a9589165 brk+0x25 (/lib/x86_64-linux-gnu/ld-2.19.so) => 7f06a95884c8 _dl_sysdep_start+0x148 (/lib/x86_64-linux-gnu/ld-2.19.so) ls 3689/3689 [001] 2062.020966237: jcc 7f06a95884d7 _dl_sysdep_start+0x157 (/lib/x86_64-linux-gnu/ld-2.19.so) => 7f06a95885f0 _dl_sysdep_start+0x270 (/lib/x86_64-linux-gnu/ld-2.19.so) ls 3689/3689 [001] 2062.020966237: call 7f06a95885f0 _dl_sysdep_start+0x270 (/lib/x86_64-linux-gnu/ld-2.19.so) => 7f06a958ac50 strlen+0x0 (/lib/x86_64-linux-gnu/ld-2.19.so) ls 3689/3689 [001] 2062.020966237: jcc 7f06a958ac6e strlen+0x1e (/lib/x86_64-linux-gnu/ld-2.19.so) => 7f06a958ac60 strlen+0x10 (/lib/x86_64-linux-gnu/ld-2.19.so) ... Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: Andi Kleen <ak@linux.intel.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/1466689258-28493-2-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/Documentation/perf-script.txt7
-rw-r--r--tools/perf/builtin-script.c35
2 files changed, 40 insertions, 2 deletions
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index 4f34379ebd77..a46030d8962d 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -170,7 +170,12 @@ OPTIONS
170 Trace decoding. The flags are "bcrosyiABEx" which stand for branch, 170 Trace decoding. The flags are "bcrosyiABEx" which stand for branch,
171 call, return, conditional, system, asynchronous, interrupt, 171 call, return, conditional, system, asynchronous, interrupt,
172 transaction abort, trace begin, trace end, and in transaction, 172 transaction abort, trace begin, trace end, and in transaction,
173 respectively. 173 respectively. Known combinations of flags are printed more nicely e.g.
174 "call" for "bc", "return" for "br", "jcc" for "bo", "jmp" for "b",
175 "int" for "bci", "iret" for "bri", "syscall" for "bcs", "sysret" for "brs",
176 "async" for "by", "hw int" for "bcyi", "tx abrt" for "bA", "tr strt" for "bB",
177 "tr end" for "bE". However the "x" flag will be display separately in those
178 cases e.g. "jcc (x)" for a condition branch within a transaction.
174 179
175 Finally, a user may not set fields to none for all event types. 180 Finally, a user may not set fields to none for all event types.
176 i.e., -F "" is not allowed. 181 i.e., -F "" is not allowed.
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 0e18e06e7fd5..56b2fb8135ce 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -606,13 +606,42 @@ static void print_sample_bts(struct perf_sample *sample,
606 printf("\n"); 606 printf("\n");
607} 607}
608 608
609static struct {
610 u32 flags;
611 const char *name;
612} sample_flags[] = {
613 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL, "call"},
614 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN, "return"},
615 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CONDITIONAL, "jcc"},
616 {PERF_IP_FLAG_BRANCH, "jmp"},
617 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_INTERRUPT, "int"},
618 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN | PERF_IP_FLAG_INTERRUPT, "iret"},
619 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_SYSCALLRET, "syscall"},
620 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN | PERF_IP_FLAG_SYSCALLRET, "sysret"},
621 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_ASYNC, "async"},
622 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_ASYNC | PERF_IP_FLAG_INTERRUPT, "hw int"},
623 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TX_ABORT, "tx abrt"},
624 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TRACE_BEGIN, "tr strt"},
625 {PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TRACE_END, "tr end"},
626 {0, NULL}
627};
628
609static void print_sample_flags(u32 flags) 629static void print_sample_flags(u32 flags)
610{ 630{
611 const char *chars = PERF_IP_FLAG_CHARS; 631 const char *chars = PERF_IP_FLAG_CHARS;
612 const int n = strlen(PERF_IP_FLAG_CHARS); 632 const int n = strlen(PERF_IP_FLAG_CHARS);
633 bool in_tx = flags & PERF_IP_FLAG_IN_TX;
634 const char *name = NULL;
613 char str[33]; 635 char str[33];
614 int i, pos = 0; 636 int i, pos = 0;
615 637
638 for (i = 0; sample_flags[i].name ; i++) {
639 if (sample_flags[i].flags == (flags & ~PERF_IP_FLAG_IN_TX)) {
640 name = sample_flags[i].name;
641 break;
642 }
643 }
644
616 for (i = 0; i < n; i++, flags >>= 1) { 645 for (i = 0; i < n; i++, flags >>= 1) {
617 if (flags & 1) 646 if (flags & 1)
618 str[pos++] = chars[i]; 647 str[pos++] = chars[i];
@@ -622,7 +651,11 @@ static void print_sample_flags(u32 flags)
622 str[pos++] = '?'; 651 str[pos++] = '?';
623 } 652 }
624 str[pos] = 0; 653 str[pos] = 0;
625 printf(" %-4s ", str); 654
655 if (name)
656 printf(" %-7s%4s ", name, in_tx ? "(x)" : "");
657 else
658 printf(" %-11s ", str);
626} 659}
627 660
628struct printer_data { 661struct printer_data {