diff options
| author | Adrian Hunter <adrian.hunter@intel.com> | 2018-09-20 09:00:43 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-09-20 10:09:55 -0400 |
| commit | 62cb1b8868a70c932b15959a98594df537df2ffc (patch) | |
| tree | 005a3ed330685c835cf004ec9b47a144301370ed | |
| parent | 035c450ffa0483e715fc7b14a2e8b744bf8a740a (diff) | |
perf script: Enhance sample flags for trace begin / end
Allow for different combinations of sample flags with "trace begin" or
"trace end".
Previously, the Intel PT decoder would indicate begin / end by a branch
from / to zero. That hides useful information, in particular when a
trace ends with a call. Before remedying that, prepare 'perf script' to
display sample flags with more combinations that include trace begin /
end. In those cases display 'tr start' and 'tr end' separately.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20180920130048.31432-2-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
| -rw-r--r-- | tools/perf/builtin-script.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 7732346bd9dd..4da5e32b9e03 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
| @@ -1262,6 +1262,18 @@ static struct { | |||
| 1262 | {0, NULL} | 1262 | {0, NULL} |
| 1263 | }; | 1263 | }; |
| 1264 | 1264 | ||
| 1265 | static const char *sample_flags_to_name(u32 flags) | ||
| 1266 | { | ||
| 1267 | int i; | ||
| 1268 | |||
| 1269 | for (i = 0; sample_flags[i].name ; i++) { | ||
| 1270 | if (sample_flags[i].flags == flags) | ||
| 1271 | return sample_flags[i].name; | ||
| 1272 | } | ||
| 1273 | |||
| 1274 | return NULL; | ||
| 1275 | } | ||
| 1276 | |||
| 1265 | static int perf_sample__fprintf_flags(u32 flags, FILE *fp) | 1277 | static int perf_sample__fprintf_flags(u32 flags, FILE *fp) |
| 1266 | { | 1278 | { |
| 1267 | const char *chars = PERF_IP_FLAG_CHARS; | 1279 | const char *chars = PERF_IP_FLAG_CHARS; |
| @@ -1271,11 +1283,20 @@ static int perf_sample__fprintf_flags(u32 flags, FILE *fp) | |||
| 1271 | char str[33]; | 1283 | char str[33]; |
| 1272 | int i, pos = 0; | 1284 | int i, pos = 0; |
| 1273 | 1285 | ||
| 1274 | for (i = 0; sample_flags[i].name ; i++) { | 1286 | name = sample_flags_to_name(flags & ~PERF_IP_FLAG_IN_TX); |
| 1275 | if (sample_flags[i].flags == (flags & ~PERF_IP_FLAG_IN_TX)) { | 1287 | if (name) |
| 1276 | name = sample_flags[i].name; | 1288 | return fprintf(fp, " %-15s%4s ", name, in_tx ? "(x)" : ""); |
| 1277 | break; | 1289 | |
| 1278 | } | 1290 | if (flags & PERF_IP_FLAG_TRACE_BEGIN) { |
| 1291 | name = sample_flags_to_name(flags & ~(PERF_IP_FLAG_IN_TX | PERF_IP_FLAG_TRACE_BEGIN)); | ||
| 1292 | if (name) | ||
| 1293 | return fprintf(fp, " tr strt %-7s%4s ", name, in_tx ? "(x)" : ""); | ||
| 1294 | } | ||
| 1295 | |||
| 1296 | if (flags & PERF_IP_FLAG_TRACE_END) { | ||
| 1297 | name = sample_flags_to_name(flags & ~(PERF_IP_FLAG_IN_TX | PERF_IP_FLAG_TRACE_END)); | ||
| 1298 | if (name) | ||
| 1299 | return fprintf(fp, " tr end %-7s%4s ", name, in_tx ? "(x)" : ""); | ||
| 1279 | } | 1300 | } |
| 1280 | 1301 | ||
| 1281 | for (i = 0; i < n; i++, flags >>= 1) { | 1302 | for (i = 0; i < n; i++, flags >>= 1) { |
| @@ -1288,10 +1309,7 @@ static int perf_sample__fprintf_flags(u32 flags, FILE *fp) | |||
| 1288 | } | 1309 | } |
| 1289 | str[pos] = 0; | 1310 | str[pos] = 0; |
| 1290 | 1311 | ||
| 1291 | if (name) | 1312 | return fprintf(fp, " %-19s ", str); |
| 1292 | return fprintf(fp, " %-7s%4s ", name, in_tx ? "(x)" : ""); | ||
| 1293 | |||
| 1294 | return fprintf(fp, " %-11s ", str); | ||
| 1295 | } | 1313 | } |
| 1296 | 1314 | ||
| 1297 | struct printer_data { | 1315 | struct printer_data { |
