diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2010-07-09 18:29:11 +0900 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-07-16 11:48:09 -0300 |
commit | 6a330a3c8a648916b3c6bda79a78c38ac093af17 (patch) | |
tree | 76322d562a438cb47ebf95311d898394efceca8e /tools/perf/util/probe-finder.c | |
parent | 7cf0b79e6ffd04bba5d4e625a0fe2e30a5b383e5 (diff) |
perf probe: Support comp_dir to find an absolute source path
Gcc generates DW_AT_comp_dir and stores relative source path if building kernel
without O= option. In that case, perf probe --line sometimes doesn't work
without --source option, because it tries to access relative source path.
This adds DW_AT_comp_dir support to perf probe for finding an absolute source
path when no --source option.
LKML-Reference: <4C36EBE7.3060802@hitachi.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/probe-finder.c')
-rw-r--r-- | tools/perf/util/probe-finder.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index a934a364c30f..37dcdb651a69 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -144,6 +144,15 @@ static const char *cu_find_realpath(Dwarf_Die *cu_die, const char *fname) return src; } +/* Get DW_AT_comp_dir (should be NULL with older gcc) */ +static const char *cu_get_comp_dir(Dwarf_Die *cu_die) +{ + Dwarf_Attribute attr; + if (dwarf_attr(cu_die, DW_AT_comp_dir, &attr) == NULL) + return NULL; + return dwarf_formstring(&attr); +} + /* Compare diename and tname */ static bool die_compare_name(Dwarf_Die *dw_die, const char *tname) { @@ -1374,6 +1383,7 @@ int find_line_range(int fd, struct line_range *lr) size_t cuhl; Dwarf_Die *diep; Dwarf *dbg; + const char *comp_dir; dbg = dwarf_begin(fd, DWARF_C_READ); if (!dbg) { @@ -1409,6 +1419,17 @@ int find_line_range(int fd, struct line_range *lr) } off = noff; } + + /* Store comp_dir */ + if (lf.found) { + comp_dir = cu_get_comp_dir(&lf.cu_die); + if (comp_dir) { + lr->comp_dir = strdup(comp_dir); + if (!lr->comp_dir) + ret = -ENOMEM; + } + } + pr_debug("path: %s\n", lr->path); dwarf_end(dbg); |