aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/srcline.c
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2014-11-12 21:05:27 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-11-24 16:03:47 -0500
commit85c116a6cb91a5c09b7a6c95ffc6a6cbd32cd237 (patch)
treeed4727c432cd2cfbd26a7e27cbed070f112d1df5 /tools/perf/util/srcline.c
parentaaba4e12a99cc56fc8614a3f2a3ec6db4fcde76e (diff)
perf callchain: Make get_srcline fall back to sym+offset
When the source line is not found fall back to sym + offset. This is generally much more useful than a raw address. For this we need to pass in the symbol from the caller. For some callers it's awkward to compute, so we stay at the old behaviour. 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-10-git-send-email-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/srcline.c')
-rw-r--r--tools/perf/util/srcline.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index ac877f96fed7..e73b6a5c9e0f 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -8,6 +8,8 @@
8#include "util/util.h" 8#include "util/util.h"
9#include "util/debug.h" 9#include "util/debug.h"
10 10
11#include "symbol.h"
12
11#ifdef HAVE_LIBBFD_SUPPORT 13#ifdef HAVE_LIBBFD_SUPPORT
12 14
13/* 15/*
@@ -250,7 +252,8 @@ void dso__free_a2l(struct dso *dso __maybe_unused)
250 */ 252 */
251#define A2L_FAIL_LIMIT 123 253#define A2L_FAIL_LIMIT 123
252 254
253char *get_srcline(struct dso *dso, unsigned long addr) 255char *get_srcline(struct dso *dso, unsigned long addr, struct symbol *sym,
256 bool show_sym)
254{ 257{
255 char *file = NULL; 258 char *file = NULL;
256 unsigned line = 0; 259 unsigned line = 0;
@@ -289,7 +292,11 @@ out:
289 dso->has_srcline = 0; 292 dso->has_srcline = 0;
290 dso__free_a2l(dso); 293 dso__free_a2l(dso);
291 } 294 }
292 if (asprintf(&srcline, "%s[%lx]", dso->short_name, addr) < 0) 295 if (sym) {
296 if (asprintf(&srcline, "%s+%ld", show_sym ? sym->name : "",
297 addr - sym->start) < 0)
298 return SRCLINE_UNKNOWN;
299 } else if (asprintf(&srcline, "%s[%lx]", dso->short_name, addr) < 0)
293 return SRCLINE_UNKNOWN; 300 return SRCLINE_UNKNOWN;
294 return srcline; 301 return srcline;
295} 302}