aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2018-05-28 10:11:47 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-06-04 09:28:52 -0400
commitbfa63519fb94fd8b4b0e5ffcd8bde650ea8b20c1 (patch)
tree1b85fa0b658d3a431b57981aaf85f3525b5211a3 /tools
parente2d88aaa649e65851463426b133d87b61d3accbd (diff)
perf sort: Introduce addr_map_symbol__srcline() to make code more compact
Since we have 'struct addr_map_symbol' and the srcline sort order keys all operate on those, make the code more compact by introducing a function that receives a pointer to such struct and expands the arguments to map__srcline(). Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-j540wq7n3ukkh70gk5be0in5@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/sort.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 71096dbfeb88..4ab0b4ab24e4 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -365,19 +365,20 @@ struct sort_entry sort_srcline = {
365 365
366/* --sort srcline_from */ 366/* --sort srcline_from */
367 367
368static char *addr_map_symbol__srcline(struct addr_map_symbol *ams)
369{
370 return map__srcline(ams->map, ams->al_addr, ams->sym);
371}
372
368static int64_t 373static int64_t
369sort__srcline_from_cmp(struct hist_entry *left, struct hist_entry *right) 374sort__srcline_from_cmp(struct hist_entry *left, struct hist_entry *right)
370{ 375{
371 if (!left->branch_info->srcline_from) { 376 if (!left->branch_info->srcline_from)
372 left->branch_info->srcline_from = map__srcline(left->branch_info->from.map, 377 left->branch_info->srcline_from = addr_map_symbol__srcline(&left->branch_info->from);
373 left->branch_info->from.al_addr, 378
374 left->branch_info->from.sym); 379 if (!right->branch_info->srcline_from)
375 } 380 right->branch_info->srcline_from = addr_map_symbol__srcline(&right->branch_info->from);
376 if (!right->branch_info->srcline_from) { 381
377 right->branch_info->srcline_from = map__srcline(right->branch_info->from.map,
378 right->branch_info->from.al_addr,
379 right->branch_info->from.sym);
380 }
381 return strcmp(right->branch_info->srcline_from, left->branch_info->srcline_from); 382 return strcmp(right->branch_info->srcline_from, left->branch_info->srcline_from);
382} 383}
383 384
@@ -399,16 +400,12 @@ struct sort_entry sort_srcline_from = {
399static int64_t 400static int64_t
400sort__srcline_to_cmp(struct hist_entry *left, struct hist_entry *right) 401sort__srcline_to_cmp(struct hist_entry *left, struct hist_entry *right)
401{ 402{
402 if (!left->branch_info->srcline_to) { 403 if (!left->branch_info->srcline_to)
403 left->branch_info->srcline_to = map__srcline(left->branch_info->to.map, 404 left->branch_info->srcline_to = addr_map_symbol__srcline(&left->branch_info->to);
404 left->branch_info->to.al_addr, 405
405 left->branch_info->to.sym); 406 if (!right->branch_info->srcline_to)
406 } 407 right->branch_info->srcline_to = addr_map_symbol__srcline(&right->branch_info->to);
407 if (!right->branch_info->srcline_to) { 408
408 right->branch_info->srcline_to = map__srcline(right->branch_info->to.map,
409 right->branch_info->to.al_addr,
410 right->branch_info->to.sym);
411 }
412 return strcmp(right->branch_info->srcline_to, left->branch_info->srcline_to); 409 return strcmp(right->branch_info->srcline_to, left->branch_info->srcline_to);
413} 410}
414 411