Skip to content

Commit

Permalink
perf callchain: Enable printing the srcline in the history
Browse files Browse the repository at this point in the history
For lbr-as-callgraph we need to see the line number in the history,
because many LBR entries can be in a single function, and just
showing the same function name many times is not useful.

When the history code is configured to sort by address, also try to
resolve the address to a file:srcline and display this in the browser.
If that doesn't work still display the address.

This can be also useful without LBRs for understanding which call in a large
function (or in which inlined function) called something else.

Contains fixes from Namhyung Kim

v2: Refactor code into common function
v3: Fix GTK build
v4: Rebase

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1415844328-4884-7-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Andi Kleen authored and Arnaldo Carvalho de Melo committed Nov 24, 2014
1 parent a7444af commit 23f0981
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
11 changes: 10 additions & 1 deletion tools/perf/util/callchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,16 @@ char *callchain_list__sym_name(struct callchain_list *cl,
int printed;

if (cl->ms.sym) {
printed = scnprintf(bf, bfsize, "%s", cl->ms.sym->name);
if (callchain_param.key == CCKEY_ADDRESS &&
cl->ms.map && !cl->srcline)
cl->srcline = get_srcline(cl->ms.map->dso,
map__rip_2objdump(cl->ms.map,
cl->ip));
if (cl->srcline)
printed = scnprintf(bf, bfsize, "%s %s",
cl->ms.sym->name, cl->srcline);
else
printed = scnprintf(bf, bfsize, "%s", cl->ms.sym->name);
} else
printed = scnprintf(bf, bfsize, "%#" PRIx64, cl->ip);

Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/callchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ extern struct callchain_param callchain_param;
struct callchain_list {
u64 ip;
struct map_symbol ms;
char *srcline;
struct list_head list;
};

Expand Down
6 changes: 4 additions & 2 deletions tools/perf/util/srcline.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ char *get_srcline(struct dso *dso, unsigned long addr)
const char *dso_name;

if (!dso->has_srcline)
return SRCLINE_UNKNOWN;
goto out;

if (dso->symsrc_filename)
dso_name = dso->symsrc_filename;
Expand Down Expand Up @@ -289,7 +289,9 @@ char *get_srcline(struct dso *dso, unsigned long addr)
dso->has_srcline = 0;
dso__free_a2l(dso);
}
return SRCLINE_UNKNOWN;
if (asprintf(&srcline, "%s[%lx]", dso->short_name, addr) < 0)
return SRCLINE_UNKNOWN;
return srcline;
}

void free_srcline(char *srcline)
Expand Down

0 comments on commit 23f0981

Please sign in to comment.