aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/sort.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/sort.c')
-rw-r--r--tools/perf/util/sort.c76
1 files changed, 60 insertions, 16 deletions
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
450static 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
466static int64_t
467sort__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
486static 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
500struct 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
450static int64_t 509static 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
1563static 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
1579static void update_dynamic_len(struct hpp_dynamic_entry *hde, 1623static void update_dynamic_len(struct hpp_dynamic_entry *hde,
1580 struct hist_entry *he) 1624 struct hist_entry *he)
1581{ 1625{