[tip:perf/core] perf tools: Do not try to call addr2line on non-binary files

From: tip-bot for Namhyung Kim
Date: Tue Oct 15 2013 - 01:26:46 EST


Commit-ID: 58d91a0068694a5ba3efc99e88ce6b4b0dd0d085
Gitweb: http://git.kernel.org/tip/58d91a0068694a5ba3efc99e88ce6b4b0dd0d085
Author: Namhyung Kim <namhyung.kim@xxxxxxx>
AuthorDate: Wed, 11 Sep 2013 14:09:29 +0900
Committer: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
CommitDate: Wed, 9 Oct 2013 16:01:05 -0300

perf tools: Do not try to call addr2line on non-binary files

No need to call addr2line since they don't have such information.

Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
Reviewed-by: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Link: http://lkml.kernel.org/r/1378876173-13363-6-git-send-email-namhyung@xxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/util/sort.c | 3 ---
tools/perf/util/srcline.c | 11 +++++++++--
2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index b7e0ef0..d443593 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -259,9 +259,6 @@ static int hist_entry__srcline_snprintf(struct hist_entry *self, char *bf,
if (!self->ms.map)
goto out_ip;

- if (!strncmp(self->ms.map->dso->long_name, "/tmp/perf-", 10))
- goto out_ip;
-
path = get_srcline(self->ms.map->dso->long_name, self->ip);
self->srcline = path;

diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index 7e92cca..777f918 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -57,11 +57,17 @@ char *get_srcline(const char *dso_name, unsigned long addr)
{
char *file;
unsigned line;
- char *srcline;
+ char *srcline = SRCLINE_UNKNOWN;
size_t size;

+ if (dso_name[0] == '[')
+ goto out;
+
+ if (!strncmp(dso_name, "/tmp/perf-", 10))
+ goto out;
+
if (!addr2line(dso_name, addr, &file, &line))
- return SRCLINE_UNKNOWN;
+ goto out;

/* just calculate actual length */
size = snprintf(NULL, 0, "%s:%u", file, line) + 1;
@@ -73,6 +79,7 @@ char *get_srcline(const char *dso_name, unsigned long addr)
srcline = SRCLINE_UNKNOWN;

free(file);
+out:
return srcline;
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/