Bug 472973

Summary: add debuginfod client support for source code downloading on the fly
Product: [Developer tools] kcachegrind Reporter: Frank Ch. Eigler <fche>
Component: generalAssignee: Josef Weidendorfer <josef.weidendorfer>
Status: REPORTED ---    
Severity: normal CC: kde
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Frank Ch. Eigler 2023-08-03 18:48:19 UTC
Several modern linux distros run debuginfo + source code downloading service called debuginfod -  https://sourceware.org/elfutils/Debuginfod.html .  kcachegrind could take advantage to download source code to binaries and especially shared libraries being profiled.  This could get rid of many occurrences of the "There is no source available for ...." diagnostics.

The simplest way to use it would be to extend libviews/sourceview.cpp to call out to "debuginfod-find $PATH source $SOURCEFILE", consume its standard output as a file name (if rc==0).  That file should contain the contents of the source file.

In the case of callgrind output files, $PATH would probably come from "ob=(N) $PATH" and "cob=(N) $PATH", and $SOURCEFILE is the nearby "fi=(N) $SOURCEFILE".

callgrind.out:

[...]
cob=(2) /usr/lib64/libc.so.6
[...]
fi=(349) /usr/src/debug/glibc-2.37-4.fc38.x86_64/libio/libioP.h


% debuginfod-find /usr/lib64/libc.so.6 source /usr/src/debug/glibc-2.37-4.fc38.x86_64/libio/libioP.h
/home/you/.cache/debuginfod_client/SOMETHING/ELSE.h
% cat /home/you/.cache/debuginfod_client/SOMETHING/ELSE.h
/* ..... glibc goodness ..... */