Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH 1/1 perf-tools-next] perf probe: Fix retrieval of source files from a debuginfod server
@ 2024-10-28 21:31 Arnaldo Carvalho de Melo
  2024-10-28 21:48 ` Frank Ch. Eigler
  2024-10-30 21:30 ` Namhyung Kim
  0 siblings, 2 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-10-28 21:31 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Masami Hiramatsu, Frank Ch. Eigler, Francesco Nigro, Aaron Merey,
	Adrian Hunter, Ian Rogers, Jiri Olsa, Kan Liang,
	Linux Kernel Mailing List, linux-perf-users

When perf is linked with libdebuginfod:

  root@number:~# ldd ~/bin/perf | grep debuginfod
	libdebuginfod.so.1 => /lib64/libdebuginfod.so.1 (0x00007ff5c3930000)
  root@number:~# perf check feature debuginfod
            debuginfod: [ on  ]  # HAVE_DEBUGINFOD_SUPPORT
  root@number:~#

And we don't have a debuginfo package installed for the binary we're
trying to use, vmlinux in this case as we didn't specify any using 'perf
probe -x', it will use the build for the running kernel:

  root@number:~# perf buildid-list -k
  38e927fd7799d50dbc4d99ec5e3f781b6105a6a9
  root@number:~#

And communicate with a debuginfo server, be it configured in a
~/.perfconfig file, excerpt from the 'perf config' man page:

       buildid-cache.*
           buildid-cache.debuginfod=URLs Specify debuginfod URLs to be
	   used when retrieving perf.data binaries, it follows the same
	   syntax as the DEBUGINFOD_URLS variable, like:

               buildid-cache.debuginfod=http://192.168.122.174:8002

Or via the DEBUGINFOD_URLS env var, as distros like fedora do by
default:

  root@number:~# echo $DEBUGINFOD_URLS
  https://debuginfod.fedoraproject.org/
  root@number:~#

To pick and cache just what is needed, instead of requiring the manual
installation of the entire kernel-debuginfo package, which is really
large.

It will, in this example, use the following cache files, deleted
before/after this patch just to test the whole process:

  root@number:~# rm -f /root/.cache/debuginfod_client/38e927fd7799d50dbc4d99ec5e3f781b6105a6a9/source-a1414a5d-#usr#src#debug#kernel-6.11.4#linux-6.11.4-201.fc40.x86_64#net#ipv4#icmp.c
  root@number:~# rm -f /root/.cache/debuginfod_client/38e927fd7799d50dbc4d99ec5e3f781b6105a6a9/debuginfo

Before this patch:

  root@number:~# perf probe -L icmp_rcv
  Failed to find source file path.
    Error: Failed to show lines.
  root@number:~#

This is because 'perf probe' was using just the relative file name, in
this case "net/ipv4/icmp.c", that is where the 'icmp_rcv' function is
located, if we add it and comply with the debuginfo_find_source()
function man page, it contacts the server, finds the necessary files,
cache them locally and all works:

  root@number:~# perf probe -L icmp_rcv | head
  <icmp_rcv@/root/.cache/debuginfod_client/38e927fd7799d50dbc4d99ec5e3f781b6105a6a9/source-a1414a5d-#usr#src#debug#kernel-6.11.4#linux-6.11.4-201.fc40.x86_64#net#ipv4#icmp.c:0>
        0  int icmp_rcv(struct sk_buff *skb)
           {
        2  	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
           	struct rtable *rt = skb_rtable(skb);
           	struct net *net = dev_net(rt->dst.dev);
           	struct icmphdr *icmph;

           	if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
        8  		struct sec_path *sp = skb_sec_path(skb);
  root@number:~#

Cc: Aaron Merey <amerey@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Francesco Nigro <fnigro@redhat.com>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-finder.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 18181017f5fd344e..c2ca94e29aca3849 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -1874,7 +1874,11 @@ int find_source_path(const char *raw_path, const char *sbuild_id,
 	const char *prefix = symbol_conf.source_prefix;
 
 	if (sbuild_id && !prefix) {
-		if (!get_source_from_debuginfod(raw_path, sbuild_id, new_path))
+		char prefixed_raw_path[PATH_MAX];
+
+		path__join(prefixed_raw_path, sizeof(prefixed_raw_path), comp_dir, raw_path);
+
+		if (!get_source_from_debuginfod(prefixed_raw_path, sbuild_id, new_path))
 			return 0;
 	}
 
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1 perf-tools-next] perf probe: Fix retrieval of source files from a debuginfod server
  2024-10-28 21:31 [PATCH 1/1 perf-tools-next] perf probe: Fix retrieval of source files from a debuginfod server Arnaldo Carvalho de Melo
@ 2024-10-28 21:48 ` Frank Ch. Eigler
  2024-10-30 21:30 ` Namhyung Kim
  1 sibling, 0 replies; 3+ messages in thread
From: Frank Ch. Eigler @ 2024-10-28 21:48 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, Masami Hiramatsu, Francesco Nigro, Aaron Merey,
	Adrian Hunter, Ian Rogers, Jiri Olsa, Kan Liang,
	Linux Kernel Mailing List, linux-perf-users

Hi -

> -		if (!get_source_from_debuginfod(raw_path, sbuild_id, new_path))
> +		char prefixed_raw_path[PATH_MAX];
> +
> +		path__join(prefixed_raw_path, sizeof(prefixed_raw_path), comp_dir, raw_path);
> +
> +		if (!get_source_from_debuginfod(prefixed_raw_path, sbuild_id, n
ew_path))

lgtm!

- FChE


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1 perf-tools-next] perf probe: Fix retrieval of source files from a debuginfod server
  2024-10-28 21:31 [PATCH 1/1 perf-tools-next] perf probe: Fix retrieval of source files from a debuginfod server Arnaldo Carvalho de Melo
  2024-10-28 21:48 ` Frank Ch. Eigler
@ 2024-10-30 21:30 ` Namhyung Kim
  1 sibling, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2024-10-30 21:30 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Masami Hiramatsu, Frank Ch. Eigler, Francesco Nigro, Aaron Merey,
	Adrian Hunter, Ian Rogers, Jiri Olsa, Kan Liang,
	Linux Kernel Mailing List, linux-perf-users

On Mon, 28 Oct 2024 18:31:28 -0300, Arnaldo Carvalho de Melo wrote:

> When perf is linked with libdebuginfod:
> 
>   root@number:~# ldd ~/bin/perf | grep debuginfod
> 	libdebuginfod.so.1 => /lib64/libdebuginfod.so.1 (0x00007ff5c3930000)
>   root@number:~# perf check feature debuginfod
>             debuginfod: [ on  ]  # HAVE_DEBUGINFOD_SUPPORT
>   root@number:~#
> 
> [...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-30 21:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-28 21:31 [PATCH 1/1 perf-tools-next] perf probe: Fix retrieval of source files from a debuginfod server Arnaldo Carvalho de Melo
2024-10-28 21:48 ` Frank Ch. Eigler
2024-10-30 21:30 ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox