diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 2a1e883580a183fd7305ed159e44a391c68fdf0e..0f898d3ff84c3c68dfc97bef3cc3cbb98ccf806d 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -50,6 +50,8 @@ struct perf_c2c { int cpus_cnt; int *cpu2node; int node_info; + + bool show_src; }; static struct perf_c2c c2c; @@ -1363,6 +1365,11 @@ static struct c2c_dimension dim_cpucnt = { .width = 8, }; +static struct c2c_dimension dim_srcline = { + .name = "cl_srcline", + .se = &sort_srcline, +}; + static struct c2c_dimension *dimensions[] = { &dim_dcacheline, &dim_offset, @@ -1401,6 +1408,7 @@ static struct c2c_dimension *dimensions[] = { &dim_mean_lcl, &dim_mean_load, &dim_cpucnt, + &dim_srcline, NULL, }; @@ -1606,8 +1614,11 @@ static int c2c_hists__reinit(struct c2c_hists *c2c_hists, return hpp_list__parse(&c2c_hists->list, output, sort); } -static int filter_cb(struct hist_entry *he __maybe_unused) +static int filter_cb(struct hist_entry *he) { + if (c2c.show_src && !he->srcline) + he->srcline = hist_entry__get_srcline(he); + return 0; } diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 452e15a10dd28f53951b4ae8aaf08b1928e9a805..df622f4e301e2a2284ee5e728b09ade055680796 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -315,7 +315,7 @@ struct sort_entry sort_sym = { /* --sort srcline */ -static char *hist_entry__get_srcline(struct hist_entry *he) +char *hist_entry__get_srcline(struct hist_entry *he) { struct map *map = he->ms.map; diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 099c97557d33c5ed317278375fe78648d2744da0..7aff317fc7c4827b53986a4a7085ca8d8e2ef58f 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -280,4 +280,5 @@ int64_t sort__daddr_cmp(struct hist_entry *left, struct hist_entry *right); int64_t sort__dcacheline_cmp(struct hist_entry *left, struct hist_entry *right); +char *hist_entry__get_srcline(struct hist_entry *he); #endif /* __PERF_SORT_H */