* [PATCH 1/2] perf symbols: use .gnu_debuglink as gdb does
@ 2016-07-21 9:48 Uwe Kleine-König
2016-07-21 9:48 ` [PATCH 2/2] perf probe: Add option --symfs Uwe Kleine-König
2017-01-19 9:51 ` [PATCH 1/2] perf symbols: use .gnu_debuglink as gdb does Uwe Kleine-König
0 siblings, 2 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2016-07-21 9:48 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo
Cc: Alexander Shishkin, Jiri Olsa, linux-kernel, kernel
As documented in the comment gdb looks for debug files not only relative
to the binary's directory, but also in .debug and /usr/lib/debug/.
Let perf do the same thing.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
tools/perf/util/dso.c | 49 +++++++++++++++++++++++++++++++++++++++----------
1 file changed, 39 insertions(+), 10 deletions(-)
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 774f6ec884d5..51d39f37cabd 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -45,21 +45,50 @@ int dso__read_binary_type_filename(const struct dso *dso,
switch (type) {
case DSO_BINARY_TYPE__DEBUGLINK: {
- char *debuglink;
+ /* gdb interprets the content of the debuglink section as
+ * path relative to
+ * - the binary's directory
+ * - .debug/ in the binary's directory
+ * - /usr/lib/debug
+ * and uses the first one that exists.
+ */
+ char debuglink[512];
+ char *pathbase;
len = __symbol__join_symfs(filename, size, dso->long_name);
- debuglink = filename + len;
- while (debuglink != filename && *debuglink != '/')
- debuglink--;
- if (*debuglink == '/')
- debuglink++;
+ if (!is_regular_file(filename)) {
+ ret = -1;
+ break;
+ }
- ret = -1;
- if (!is_regular_file(filename))
+ ret = filename__read_debuglink(filename,
+ debuglink, sizeof(debuglink));
+ if (ret < 0)
+ break;
+
+ pathbase = filename + len;
+ while (pathbase != filename && *pathbase != '/')
+ pathbase--;
+ if (*pathbase == '/')
+ pathbase++;
+
+ snprintf(pathbase, size - (pathbase - filename),
+ "%s", debuglink);
+ if (is_regular_file(filename))
+ break;
+
+ snprintf(pathbase, size - (pathbase - filename),
+ ".debug/%s", debuglink);
+ if (is_regular_file(filename))
+ break;
+
+ len = __symbol__join_symfs(filename, size, "/usr/lib/debug");
+ snprintf(filename + len, size - len, "%s", debuglink);
+
+ if (is_regular_file(filename))
break;
- ret = filename__read_debuglink(filename, debuglink,
- size - (debuglink - filename));
+ ret = -1;
}
break;
case DSO_BINARY_TYPE__BUILD_ID_CACHE:
--
2.8.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] perf probe: Add option --symfs
2016-07-21 9:48 [PATCH 1/2] perf symbols: use .gnu_debuglink as gdb does Uwe Kleine-König
@ 2016-07-21 9:48 ` Uwe Kleine-König
2017-01-19 9:51 ` [PATCH 1/2] perf symbols: use .gnu_debuglink as gdb does Uwe Kleine-König
1 sibling, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2016-07-21 9:48 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo
Cc: Alexander Shishkin, Jiri Olsa, linux-kernel, kernel
perf probe makes use of debug symbols, so add --symfs as the other
commands have.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
tools/perf/builtin-probe.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index ee5b42173ba3..f82d9b453366 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -542,6 +542,8 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
"Enable kernel symbol demangling"),
OPT_BOOLEAN(0, "cache", &probe_conf.cache, "Manipulate probe cache"),
+ OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
+ "Look for files with symbols relative to this directory"),
OPT_END()
};
int ret;
--
2.8.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] perf symbols: use .gnu_debuglink as gdb does
2016-07-21 9:48 [PATCH 1/2] perf symbols: use .gnu_debuglink as gdb does Uwe Kleine-König
2016-07-21 9:48 ` [PATCH 2/2] perf probe: Add option --symfs Uwe Kleine-König
@ 2017-01-19 9:51 ` Uwe Kleine-König
2017-02-08 12:27 ` Arnaldo Carvalho de Melo
1 sibling, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2017-01-19 9:51 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo
Cc: Alexander Shishkin, kernel, linux-kernel, Jiri Olsa
On Thu, Jul 21, 2016 at 11:48:31AM +0200, Uwe Kleine-König wrote:
> As documented in the comment gdb looks for debug files not only relative
> to the binary's directory, but also in .debug and /usr/lib/debug/.
> Let perf do the same thing.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
ping.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] perf symbols: use .gnu_debuglink as gdb does
2017-01-19 9:51 ` [PATCH 1/2] perf symbols: use .gnu_debuglink as gdb does Uwe Kleine-König
@ 2017-02-08 12:27 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-02-08 12:27 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Peter Zijlstra, Ingo Molnar, Alexander Shishkin, kernel,
linux-kernel, Jiri Olsa
Em Thu, Jan 19, 2017 at 10:51:39AM +0100, Uwe Kleine-König escreveu:
> On Thu, Jul 21, 2016 at 11:48:31AM +0200, Uwe Kleine-König wrote:
> > As documented in the comment gdb looks for debug files not only relative
> > to the binary's directory, but also in .debug and /usr/lib/debug/.
> > Let perf do the same thing.
> >
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>
> ping.
Sorry, completely lost track of these two :-\
Applied 'perf probe --symfs' one, the other should be already dealt with
by another patch, this one:
t 9343e45bf6cc4a05f6e271e9f8d06bc87875c604
Author: Matija Glavinic Pecotic <matija.glavinic-pecotic.ext@nokia.com>
Date: Tue Jan 17 15:50:35 2017 +0100
perf unwind: Fix looking up dwarf unwind stack info
-----------
That is in tip/perf/core now.
- Arnaldo
> Best regards
> Uwe
>
> --
> Pengutronix e.K. | Uwe Kleine-König |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-02-08 12:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-21 9:48 [PATCH 1/2] perf symbols: use .gnu_debuglink as gdb does Uwe Kleine-König
2016-07-21 9:48 ` [PATCH 2/2] perf probe: Add option --symfs Uwe Kleine-König
2017-01-19 9:51 ` [PATCH 1/2] perf symbols: use .gnu_debuglink as gdb does Uwe Kleine-König
2017-02-08 12:27 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox