diff options
-rw-r--r-- | tools/perf/util/hist.h | 1 | ||||
-rw-r--r-- | tools/perf/util/sort.c | 76 | ||||
-rw-r--r-- | tools/perf/util/sort.h | 1 |
3 files changed, 62 insertions, 16 deletions
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 36439bfad059..15b22c563d30 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -52,6 +52,7 @@ 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_TRACE, | ||
55 | HISTC_NR_COLS, /* Last entry */ | 56 | HISTC_NR_COLS, /* Last entry */ |
56 | }; | 57 | }; |
57 | 58 | ||
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 22d28c7e0b01..db8476a9b103 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
@@ -445,6 +445,65 @@ struct sort_entry sort_socket = { | |||
445 | .se_width_idx = HISTC_SOCKET, | 445 | .se_width_idx = HISTC_SOCKET, |
446 | }; | 446 | }; |
447 | 447 | ||
448 | /* --sort trace */ | ||
449 | |||
450 | static char *get_trace_output(struct hist_entry *he) | ||
451 | { | ||
452 | struct trace_seq seq; | ||
453 | struct perf_evsel *evsel; | ||
454 | struct pevent_record rec = { | ||
455 | .data = he->raw_data, | ||
456 | .size = he->raw_size, | ||
457 | }; | ||
458 | |||
459 | evsel = hists_to_evsel(he->hists); | ||
460 | |||
461 | trace_seq_init(&seq); | ||
462 | pevent_event_info(&seq, evsel->tp_format, &rec); | ||
463 | return seq.buffer; | ||
464 | } | ||
465 | |||
466 | static int64_t | ||
467 | sort__trace_cmp(struct hist_entry *left, struct hist_entry *right) | ||
468 | { | ||
469 | struct perf_evsel *evsel; | ||
470 | |||
471 | evsel = hists_to_evsel(left->hists); | ||
472 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) | ||
473 | return 0; | ||
474 | |||
475 | if (left->trace_output == NULL) | ||
476 | left->trace_output = get_trace_output(left); | ||
477 | if (right->trace_output == NULL) | ||
478 | right->trace_output = get_trace_output(right); | ||
479 | |||
480 | hists__new_col_len(left->hists, HISTC_TRACE, strlen(left->trace_output)); | ||
481 | hists__new_col_len(right->hists, HISTC_TRACE, strlen(right->trace_output)); | ||
482 | |||
483 | return strcmp(right->trace_output, left->trace_output); | ||
484 | } | ||
485 | |||
486 | static int hist_entry__trace_snprintf(struct hist_entry *he, char *bf, | ||
487 | size_t size, unsigned int width) | ||
488 | { | ||
489 | struct perf_evsel *evsel; | ||
490 | |||
491 | evsel = hists_to_evsel(he->hists); | ||
492 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) | ||
493 | return scnprintf(bf, size, "%-*.*s", width, width, "N/A"); | ||
494 | |||
495 | if (he->trace_output == NULL) | ||
496 | he->trace_output = get_trace_output(he); | ||
497 | return repsep_snprintf(bf, size, "%-*.*s", width, width, he->trace_output); | ||
498 | } | ||
499 | |||
500 | struct sort_entry sort_trace = { | ||
501 | .se_header = "Trace output", | ||
502 | .se_cmp = sort__trace_cmp, | ||
503 | .se_snprintf = hist_entry__trace_snprintf, | ||
504 | .se_width_idx = HISTC_TRACE, | ||
505 | }; | ||
506 | |||
448 | /* sort keys for branch stacks */ | 507 | /* sort keys for branch stacks */ |
449 | 508 | ||
450 | static int64_t | 509 | static int64_t |
@@ -1314,6 +1373,7 @@ static struct sort_dimension common_sort_dimensions[] = { | |||
1314 | DIM(SORT_LOCAL_WEIGHT, "local_weight", sort_local_weight), | 1373 | DIM(SORT_LOCAL_WEIGHT, "local_weight", sort_local_weight), |
1315 | DIM(SORT_GLOBAL_WEIGHT, "weight", sort_global_weight), | 1374 | DIM(SORT_GLOBAL_WEIGHT, "weight", sort_global_weight), |
1316 | DIM(SORT_TRANSACTION, "transaction", sort_transaction), | 1375 | DIM(SORT_TRANSACTION, "transaction", sort_transaction), |
1376 | DIM(SORT_TRACE, "trace", sort_trace), | ||
1317 | }; | 1377 | }; |
1318 | 1378 | ||
1319 | #undef DIM | 1379 | #undef DIM |
@@ -1560,22 +1620,6 @@ static int hde_width(struct hpp_dynamic_entry *hde) | |||
1560 | return hde->hpp.len; | 1620 | return hde->hpp.len; |
1561 | } | 1621 | } |
1562 | 1622 | ||
1563 | static char *get_trace_output(struct hist_entry *he) | ||
1564 | { | ||
1565 | struct trace_seq seq; | ||
1566 | struct perf_evsel *evsel; | ||
1567 | struct pevent_record rec = { | ||
1568 | .data = he->raw_data, | ||
1569 | .size = he->raw_size, | ||
1570 | }; | ||
1571 | |||
1572 | evsel = hists_to_evsel(he->hists); | ||
1573 | |||
1574 | trace_seq_init(&seq); | ||
1575 | pevent_event_info(&seq, evsel->tp_format, &rec); | ||
1576 | return seq.buffer; | ||
1577 | } | ||
1578 | |||
1579 | static void update_dynamic_len(struct hpp_dynamic_entry *hde, | 1623 | static void update_dynamic_len(struct hpp_dynamic_entry *hde, |
1580 | struct hist_entry *he) | 1624 | struct hist_entry *he) |
1581 | { | 1625 | { |
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index f6d2a7e3e7f2..6b7590ade229 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h | |||
@@ -183,6 +183,7 @@ enum sort_type { | |||
183 | SORT_LOCAL_WEIGHT, | 183 | SORT_LOCAL_WEIGHT, |
184 | SORT_GLOBAL_WEIGHT, | 184 | SORT_GLOBAL_WEIGHT, |
185 | SORT_TRANSACTION, | 185 | SORT_TRANSACTION, |
186 | SORT_TRACE, | ||
186 | 187 | ||
187 | /* branch stack specific sort keys */ | 188 | /* branch stack specific sort keys */ |
188 | __SORT_BRANCH_STACK, | 189 | __SORT_BRANCH_STACK, |