diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/Documentation/perf-report.txt | 3 | ||||
-rw-r--r-- | tools/perf/util/hist.c | 9 | ||||
-rw-r--r-- | tools/perf/util/hist.h | 2 | ||||
-rw-r--r-- | tools/perf/util/sort.c | 84 | ||||
-rw-r--r-- | tools/perf/util/sort.h | 2 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 2 |
6 files changed, 101 insertions, 1 deletions
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index 496d42cdf02b..9cbddc290aff 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt | |||
@@ -103,12 +103,13 @@ OPTIONS | |||
103 | 103 | ||
104 | If --branch-stack option is used, following sort keys are also | 104 | If --branch-stack option is used, following sort keys are also |
105 | available: | 105 | available: |
106 | dso_from, dso_to, symbol_from, symbol_to, mispredict. | ||
107 | 106 | ||
108 | - dso_from: name of library or module branched from | 107 | - dso_from: name of library or module branched from |
109 | - dso_to: name of library or module branched to | 108 | - dso_to: name of library or module branched to |
110 | - symbol_from: name of function branched from | 109 | - symbol_from: name of function branched from |
111 | - symbol_to: name of function branched to | 110 | - symbol_to: name of function branched to |
111 | - srcline_from: source file and line branched from | ||
112 | - srcline_to: source file and line branched to | ||
112 | - mispredict: "N" for predicted branch, "Y" for mispredicted branch | 113 | - mispredict: "N" for predicted branch, "Y" for mispredicted branch |
113 | - in_tx: branch in TSX transaction | 114 | - in_tx: branch in TSX transaction |
114 | - abort: TSX transaction abort. | 115 | - abort: TSX transaction abort. |
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index cfab531437c7..d1f19e0012d4 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -117,6 +117,13 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) | |||
117 | hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen); | 117 | hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen); |
118 | hists__set_unres_dso_col_len(hists, HISTC_DSO_TO); | 118 | hists__set_unres_dso_col_len(hists, HISTC_DSO_TO); |
119 | } | 119 | } |
120 | |||
121 | if (h->branch_info->srcline_from) | ||
122 | hists__new_col_len(hists, HISTC_SRCLINE_FROM, | ||
123 | strlen(h->branch_info->srcline_from)); | ||
124 | if (h->branch_info->srcline_to) | ||
125 | hists__new_col_len(hists, HISTC_SRCLINE_TO, | ||
126 | strlen(h->branch_info->srcline_to)); | ||
120 | } | 127 | } |
121 | 128 | ||
122 | if (h->mem_info) { | 129 | if (h->mem_info) { |
@@ -1042,6 +1049,8 @@ void hist_entry__delete(struct hist_entry *he) | |||
1042 | if (he->branch_info) { | 1049 | if (he->branch_info) { |
1043 | map__zput(he->branch_info->from.map); | 1050 | map__zput(he->branch_info->from.map); |
1044 | map__zput(he->branch_info->to.map); | 1051 | map__zput(he->branch_info->to.map); |
1052 | free_srcline(he->branch_info->srcline_from); | ||
1053 | free_srcline(he->branch_info->srcline_to); | ||
1045 | zfree(&he->branch_info); | 1054 | zfree(&he->branch_info); |
1046 | } | 1055 | } |
1047 | 1056 | ||
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 0f84bfb42bb1..7b54ccf1b737 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -52,6 +52,8 @@ enum hist_column { | |||
52 | HISTC_MEM_IADDR_SYMBOL, | 52 | HISTC_MEM_IADDR_SYMBOL, |
53 | HISTC_TRANSACTION, | 53 | HISTC_TRANSACTION, |
54 | HISTC_CYCLES, | 54 | HISTC_CYCLES, |
55 | HISTC_SRCLINE_FROM, | ||
56 | HISTC_SRCLINE_TO, | ||
55 | HISTC_TRACE, | 57 | HISTC_TRACE, |
56 | HISTC_NR_COLS, /* Last entry */ | 58 | HISTC_NR_COLS, /* Last entry */ |
57 | }; | 59 | }; |
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 20e69edd5006..c4e9bd70723c 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
@@ -353,6 +353,88 @@ struct sort_entry sort_srcline = { | |||
353 | .se_width_idx = HISTC_SRCLINE, | 353 | .se_width_idx = HISTC_SRCLINE, |
354 | }; | 354 | }; |
355 | 355 | ||
356 | /* --sort srcline_from */ | ||
357 | |||
358 | static int64_t | ||
359 | sort__srcline_from_cmp(struct hist_entry *left, struct hist_entry *right) | ||
360 | { | ||
361 | if (!left->branch_info->srcline_from) { | ||
362 | struct map *map = left->branch_info->from.map; | ||
363 | if (!map) | ||
364 | left->branch_info->srcline_from = SRCLINE_UNKNOWN; | ||
365 | else | ||
366 | left->branch_info->srcline_from = get_srcline(map->dso, | ||
367 | map__rip_2objdump(map, | ||
368 | left->branch_info->from.al_addr), | ||
369 | left->branch_info->from.sym, true); | ||
370 | } | ||
371 | if (!right->branch_info->srcline_from) { | ||
372 | struct map *map = right->branch_info->from.map; | ||
373 | if (!map) | ||
374 | right->branch_info->srcline_from = SRCLINE_UNKNOWN; | ||
375 | else | ||
376 | right->branch_info->srcline_from = get_srcline(map->dso, | ||
377 | map__rip_2objdump(map, | ||
378 | right->branch_info->from.al_addr), | ||
379 | right->branch_info->from.sym, true); | ||
380 | } | ||
381 | return strcmp(right->branch_info->srcline_from, left->branch_info->srcline_from); | ||
382 | } | ||
383 | |||
384 | static int hist_entry__srcline_from_snprintf(struct hist_entry *he, char *bf, | ||
385 | size_t size, unsigned int width) | ||
386 | { | ||
387 | return repsep_snprintf(bf, size, "%-*.*s", width, width, he->branch_info->srcline_from); | ||
388 | } | ||
389 | |||
390 | struct sort_entry sort_srcline_from = { | ||
391 | .se_header = "From Source:Line", | ||
392 | .se_cmp = sort__srcline_from_cmp, | ||
393 | .se_snprintf = hist_entry__srcline_from_snprintf, | ||
394 | .se_width_idx = HISTC_SRCLINE_FROM, | ||
395 | }; | ||
396 | |||
397 | /* --sort srcline_to */ | ||
398 | |||
399 | static int64_t | ||
400 | sort__srcline_to_cmp(struct hist_entry *left, struct hist_entry *right) | ||
401 | { | ||
402 | if (!left->branch_info->srcline_to) { | ||
403 | struct map *map = left->branch_info->to.map; | ||
404 | if (!map) | ||
405 | left->branch_info->srcline_to = SRCLINE_UNKNOWN; | ||
406 | else | ||
407 | left->branch_info->srcline_to = get_srcline(map->dso, | ||
408 | map__rip_2objdump(map, | ||
409 | left->branch_info->to.al_addr), | ||
410 | left->branch_info->from.sym, true); | ||
411 | } | ||
412 | if (!right->branch_info->srcline_to) { | ||
413 | struct map *map = right->branch_info->to.map; | ||
414 | if (!map) | ||
415 | right->branch_info->srcline_to = SRCLINE_UNKNOWN; | ||
416 | else | ||
417 | right->branch_info->srcline_to = get_srcline(map->dso, | ||
418 | map__rip_2objdump(map, | ||
419 | right->branch_info->to.al_addr), | ||
420 | right->branch_info->to.sym, true); | ||
421 | } | ||
422 | return strcmp(right->branch_info->srcline_to, left->branch_info->srcline_to); | ||
423 | } | ||
424 | |||
425 | static int hist_entry__srcline_to_snprintf(struct hist_entry *he, char *bf, | ||
426 | size_t size, unsigned int width) | ||
427 | { | ||
428 | return repsep_snprintf(bf, size, "%-*.*s", width, width, he->branch_info->srcline_to); | ||
429 | } | ||
430 | |||
431 | struct sort_entry sort_srcline_to = { | ||
432 | .se_header = "To Source:Line", | ||
433 | .se_cmp = sort__srcline_to_cmp, | ||
434 | .se_snprintf = hist_entry__srcline_to_snprintf, | ||
435 | .se_width_idx = HISTC_SRCLINE_TO, | ||
436 | }; | ||
437 | |||
356 | /* --sort srcfile */ | 438 | /* --sort srcfile */ |
357 | 439 | ||
358 | static char no_srcfile[1]; | 440 | static char no_srcfile[1]; |
@@ -1347,6 +1429,8 @@ static struct sort_dimension bstack_sort_dimensions[] = { | |||
1347 | DIM(SORT_IN_TX, "in_tx", sort_in_tx), | 1429 | DIM(SORT_IN_TX, "in_tx", sort_in_tx), |
1348 | DIM(SORT_ABORT, "abort", sort_abort), | 1430 | DIM(SORT_ABORT, "abort", sort_abort), |
1349 | DIM(SORT_CYCLES, "cycles", sort_cycles), | 1431 | DIM(SORT_CYCLES, "cycles", sort_cycles), |
1432 | DIM(SORT_SRCLINE_FROM, "srcline_from", sort_srcline_from), | ||
1433 | DIM(SORT_SRCLINE_TO, "srcline_to", sort_srcline_to), | ||
1350 | }; | 1434 | }; |
1351 | 1435 | ||
1352 | #undef DIM | 1436 | #undef DIM |
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 42927f448bcb..ebb59cacd092 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h | |||
@@ -215,6 +215,8 @@ enum sort_type { | |||
215 | SORT_ABORT, | 215 | SORT_ABORT, |
216 | SORT_IN_TX, | 216 | SORT_IN_TX, |
217 | SORT_CYCLES, | 217 | SORT_CYCLES, |
218 | SORT_SRCLINE_FROM, | ||
219 | SORT_SRCLINE_TO, | ||
218 | 220 | ||
219 | /* memory mode specific sort keys */ | 221 | /* memory mode specific sort keys */ |
220 | __SORT_MEMORY_MODE, | 222 | __SORT_MEMORY_MODE, |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index fa415347dbf9..b10d558a8803 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -186,6 +186,8 @@ struct branch_info { | |||
186 | struct addr_map_symbol from; | 186 | struct addr_map_symbol from; |
187 | struct addr_map_symbol to; | 187 | struct addr_map_symbol to; |
188 | struct branch_flags flags; | 188 | struct branch_flags flags; |
189 | char *srcline_from; | ||
190 | char *srcline_to; | ||
189 | }; | 191 | }; |
190 | 192 | ||
191 | struct mem_info { | 193 | struct mem_info { |