From 906049c8276eb99af997f73d602649a98e360035 Mon Sep 17 00:00:00 2001 From: Adrian Hunter Date: Tue, 3 Dec 2013 09:23:10 +0200 Subject: perf tools: Do not disable source line lookup just because of 1 failure Looking up an ip's source file name and line number does not succeed always. Current logic disables the lookup for a dso entirely on any failure. Change it so that disabling never happens if there has ever been a successful lookup for that dso but disable if the first 123 lookups fail. Signed-off-by: Adrian Hunter Cc: Andi Kleen Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Jiri Olsa Cc: Mike Galbraith Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1386055390-13757-8-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/srcline.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'tools/perf/util/srcline.c') diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c index 93795f9..0c07556 100644 --- a/tools/perf/util/srcline.c +++ b/tools/perf/util/srcline.c @@ -244,6 +244,12 @@ void dso__free_a2l(struct dso *dso __maybe_unused) #endif /* HAVE_LIBBFD_SUPPORT */ +/* + * Number of addr2line failures (without success) before disabling it for that + * dso. + */ +#define A2L_FAIL_LIMIT 123 + char *get_srcline(struct dso *dso, unsigned long addr) { char *file = NULL; @@ -268,15 +274,21 @@ char *get_srcline(struct dso *dso, unsigned long addr) if (!addr2line(dso_name, addr, &file, &line, dso)) goto out; - if (asprintf(&srcline, "%s:%u", file, line) < 0) - srcline = SRCLINE_UNKNOWN; + if (asprintf(&srcline, "%s:%u", file, line) < 0) { + free(file); + goto out; + } + + dso->a2l_fails = 0; free(file); return srcline; out: - dso->has_srcline = 0; - dso__free_a2l(dso); + if (dso->a2l_fails && ++dso->a2l_fails > A2L_FAIL_LIMIT) { + dso->has_srcline = 0; + dso__free_a2l(dso); + } return SRCLINE_UNKNOWN; } -- cgit v1.1