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)
May 19 2024, 10:07 PM
Unknown Object (File)
Apr 29 2024, 10:23 PM
Unknown Object (File)
Apr 11 2024, 7:47 PM
Unknown Object (File)
Apr 11 2024, 7:45 PM
Unknown Object (File)
Apr 11 2024, 1:34 AM
Unknown Object (File)
Mar 28 2024, 1:00 AM
Unknown Object (File)
Feb 11 2024, 5:44 AM
Unknown Object (File)
Feb 9 2024, 10:42 PM
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