diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-05-28 11:05:20 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-06-04 10:28:52 -0300 |
commit | e2d88aaa649e65851463426b133d87b61d3accbd (patch) | |
tree | c0cc4ebd2f25f237e668b12f2ed561beba3974a0 /tools/perf/util/sort.c | |
parent | 982d410bc6b405a75086236d3c1da1f18c40d6dd (diff) | |
download | linux-stable-e2d88aaa649e65851463426b133d87b61d3accbd.tar.gz linux-stable-e2d88aaa649e65851463426b133d87b61d3accbd.tar.bz2 linux-stable-e2d88aaa649e65851463426b133d87b61d3accbd.zip |
perf srcline: Introduce map__srcline() to make code more compact
Replacing a common open coded sequence.
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-2d7d1nzd3ksqornloqeer99r@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/sort.c')
-rw-r--r-- | tools/perf/util/sort.c | 60 |
1 files changed, 13 insertions, 47 deletions
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 4058ade352a5..71096dbfeb88 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -333,13 +333,7 @@ struct sort_entry sort_sym = { char *hist_entry__get_srcline(struct hist_entry *he) { - struct map *map = he->ms.map; - - if (!map) - return SRCLINE_UNKNOWN; - - return get_srcline(map->dso, map__rip_2objdump(map, he->ip), - he->ms.sym, true, true, he->ip); + return map__srcline(he->ms.map, he->ip, he->ms.sym); } static int64_t @@ -375,28 +369,14 @@ static int64_t sort__srcline_from_cmp(struct hist_entry *left, struct hist_entry *right) { if (!left->branch_info->srcline_from) { - struct map *map = left->branch_info->from.map; - if (!map) - left->branch_info->srcline_from = SRCLINE_UNKNOWN; - else - left->branch_info->srcline_from = get_srcline(map->dso, - map__rip_2objdump(map, - left->branch_info->from.al_addr), - left->branch_info->from.sym, - true, true, - left->branch_info->from.al_addr); + left->branch_info->srcline_from = map__srcline(left->branch_info->from.map, + left->branch_info->from.al_addr, + left->branch_info->from.sym); } if (!right->branch_info->srcline_from) { - struct map *map = right->branch_info->from.map; - if (!map) - right->branch_info->srcline_from = SRCLINE_UNKNOWN; - else - right->branch_info->srcline_from = get_srcline(map->dso, - map__rip_2objdump(map, - right->branch_info->from.al_addr), - right->branch_info->from.sym, - true, true, - right->branch_info->from.al_addr); + right->branch_info->srcline_from = map__srcline(right->branch_info->from.map, + right->branch_info->from.al_addr, + right->branch_info->from.sym); } return strcmp(right->branch_info->srcline_from, left->branch_info->srcline_from); } @@ -420,28 +400,14 @@ static int64_t sort__srcline_to_cmp(struct hist_entry *left, struct hist_entry *right) { if (!left->branch_info->srcline_to) { - struct map *map = left->branch_info->to.map; - if (!map) - left->branch_info->srcline_to = SRCLINE_UNKNOWN; - else - left->branch_info->srcline_to = get_srcline(map->dso, - map__rip_2objdump(map, - left->branch_info->to.al_addr), - left->branch_info->from.sym, - true, true, - left->branch_info->to.al_addr); + left->branch_info->srcline_to = map__srcline(left->branch_info->to.map, + left->branch_info->to.al_addr, + left->branch_info->to.sym); } if (!right->branch_info->srcline_to) { - struct map *map = right->branch_info->to.map; - if (!map) - right->branch_info->srcline_to = SRCLINE_UNKNOWN; - else - right->branch_info->srcline_to = get_srcline(map->dso, - map__rip_2objdump(map, - right->branch_info->to.al_addr), - right->branch_info->to.sym, - true, true, - right->branch_info->to.al_addr); + right->branch_info->srcline_to = map__srcline(right->branch_info->to.map, + right->branch_info->to.al_addr, + right->branch_info->to.sym); } return strcmp(right->branch_info->srcline_to, left->branch_info->srcline_to); } |