perf probe: Fix retrieval of source files from a debuginfod server
Arnaldo Carvalho de Melo
maintainerPATCH 1/1 perf probe: Fix retrieval of source files from a debuginfod server
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:~#
--- tools/perf/util/probe-finder.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/util/probe-finder.c +5 -1
@@ -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 ; }
Signature · 1 line
2.47.0
Hi -
tools/perf/util/probe-finder.c int find_source_path(const char *raw_path, const char *sbuild_id,
Quoted 6 lines
tools/perf/util/probe-finder.c +5
-1-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
Quoted 9 lines · Arnaldo Carvalho de Melo
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