Page MenuHomeFreeBSD

libpmcstat: Teach pmcstat_image_get_elf_params about debug files
Changes PlannedPublic

Authored by jrtc27 on Apr 17 2023, 7:50 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 2 2024, 10:05 PM
Unknown Object (File)
Oct 2 2024, 9:14 AM
Unknown Object (File)
Oct 2 2024, 5:48 AM
Unknown Object (File)
Sep 24 2024, 6:41 AM
Unknown Object (File)
Sep 23 2024, 4:40 PM
Unknown Object (File)
Sep 5 2024, 2:14 PM
Unknown Object (File)
Sep 4 2024, 2:39 PM
Unknown Object (File)
Aug 26 2024, 8:12 AM
Subscribers

Details

Summary

libpmcstat scans the image (executable or library) for symbol tables in
order to be able to symbolicate callgraphs. However, we strip objects by
default, relying on separate debug files in /usr/lib/debug to provide
full symbol information to debuggers, and libpmcstat does not scan these
currently (though pmcstat itself does for other purposes). Thus, fix
this deficiency by also scanning a corresponding debug file, should it
exist, for symbols. This makes system-wide profiling of base much more
useful.

MFC after: 1 month

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 50971
Build 47862: arc lint + arc unit

Event Timeline

Oh, humm. We should probably be honoring the debug link (.gnu_debuglink section). Fix the kernel modules path thing would avoid a combinatorics explosion here since you would just have the !kernel-modules case to deal with. What GDB does when looking for separate files is something like this:

  • debug_file = read_section('.gnu_debuglink')
  • check dirname(executable) + debug_file
  • check /usr/lib/debug + dirname(executable) + debug_file

Checking the link would fix the problem you ran into with hardlinks (clang vs clang++, etc.) since the link would always be "clang.debug".

In D39626#902584, @jhb wrote:

Oh, humm. We should probably be honoring the debug link (.gnu_debuglink section). Fix the kernel modules path thing would avoid a combinatorics explosion here since you would just have the !kernel-modules case to deal with. What GDB does when looking for separate files is something like this:

  • debug_file = read_section('.gnu_debuglink')
  • check dirname(executable) + debug_file
  • check /usr/lib/debug + dirname(executable) + debug_file

Checking the link would fix the problem you ran into with hardlinks (clang vs clang++, etc.) since the link would always be "clang.debug".

That does indeed sound nicer, and explains why we don't need to have /usr/lib/debug links with GDB.

This revision is now accepted and ready to land.May 12 2023, 6:10 AM

In-progress rework to use .gnu_debuglink, but that requires no ABI changes, especially not to the kernel