diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2010-07-09 05:29:11 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-07-16 10:48:09 -0400 |
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) | |||
144 | return src; | 144 | return src; |
145 | } | 145 | } |
146 | 146 | ||
147 | /* Get DW_AT_comp_dir (should be NULL with older gcc) */ | ||
148 | static const char *cu_get_comp_dir(Dwarf_Die *cu_die) | ||
149 | { | ||
150 | Dwarf_Attribute attr; | ||
151 | if (dwarf_attr(cu_die, DW_AT_comp_dir, &attr) == NULL) | ||
152 | return NULL; | ||
153 | return dwarf_formstring(&attr); | ||
154 | } | ||
155 | |||
147 | /* Compare diename and tname */ | 156 | /* Compare diename and tname */ |
148 | static bool die_compare_name(Dwarf_Die *dw_die, const char *tname) | 157 | static bool die_compare_name(Dwarf_Die *dw_die, const char *tname) |
149 | { | 158 | { |
@@ -1374,6 +1383,7 @@ int find_line_range(int fd, struct line_range *lr) | |||
1374 | size_t cuhl; | 1383 | size_t cuhl; |
1375 | Dwarf_Die *diep; | 1384 | Dwarf_Die *diep; |
1376 | Dwarf *dbg; | 1385 | Dwarf *dbg; |
1386 | const char *comp_dir; | ||
1377 | 1387 | ||
1378 | dbg = dwarf_begin(fd, DWARF_C_READ); | 1388 | dbg = dwarf_begin(fd, DWARF_C_READ); |
1379 | if (!dbg) { | 1389 | if (!dbg) { |
@@ -1409,6 +1419,17 @@ int find_line_range(int fd, struct line_range *lr) | |||
1409 | } | 1419 | } |
1410 | off = noff; | 1420 | off = noff; |
1411 | } | 1421 | } |
1422 | |||
1423 | /* Store comp_dir */ | ||
1424 | if (lf.found) { | ||
1425 | comp_dir = cu_get_comp_dir(&lf.cu_die); | ||
1426 | if (comp_dir) { | ||
1427 | lr->comp_dir = strdup(comp_dir); | ||
1428 | if (!lr->comp_dir) | ||
1429 | ret = -ENOMEM; | ||
1430 | } | ||
1431 | } | ||
1432 | |||
1412 | pr_debug("path: %s\n", lr->path); | 1433 | pr_debug("path: %s\n", lr->path); |
1413 | dwarf_end(dbg); | 1434 | dwarf_end(dbg); |
1414 | 1435 | ||