Commit 4adcc430 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf tools: Fix srcline sort key behavior

Currently the srcline sort key compares ip rather than srcline info.  I
guess this was due to a performance reason to run external addr2line
utility.  Now we have implemented the functionality inside, use the
srcline info when comparing hist entries.

Also constantly print "??:0" string for unknown srcline rather than
printing ip.
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Reviewed-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1378876173-13363-10-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 2f48fcd8
...@@ -243,33 +243,32 @@ struct sort_entry sort_sym = { ...@@ -243,33 +243,32 @@ struct sort_entry sort_sym = {
static int64_t static int64_t
sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right) sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right)
{ {
return (int64_t)(right->ip - left->ip); if (!left->srcline) {
if (!left->ms.map)
left->srcline = SRCLINE_UNKNOWN;
else {
struct map *map = left->ms.map;
left->srcline = get_srcline(map->dso,
map__rip_2objdump(map, left->ip));
}
}
if (!right->srcline) {
if (!right->ms.map)
right->srcline = SRCLINE_UNKNOWN;
else {
struct map *map = right->ms.map;
right->srcline = get_srcline(map->dso,
map__rip_2objdump(map, right->ip));
}
}
return strcmp(left->srcline, right->srcline);
} }
static int hist_entry__srcline_snprintf(struct hist_entry *self, char *bf, static int hist_entry__srcline_snprintf(struct hist_entry *self, char *bf,
size_t size, size_t size,
unsigned int width __maybe_unused) unsigned int width __maybe_unused)
{ {
FILE *fp = NULL; return repsep_snprintf(bf, size, "%s", self->srcline);
char *path = self->srcline;
if (path != NULL)
goto out_path;
if (!self->ms.map)
goto out_ip;
path = get_srcline(self->ms.map->dso, self->ip);
self->srcline = path;
out_path:
if (fp)
pclose(fp);
return repsep_snprintf(bf, size, "%s", path);
out_ip:
if (fp)
pclose(fp);
return repsep_snprintf(bf, size, "%-#*llx", BITS_PER_LONG / 4, self->ip);
} }
struct sort_entry sort_srcline = { struct sort_entry sort_srcline = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment