mstange / samply

Command-line sampling profiler for macOS and Linux
Apache License 2.0
2.04k stars 49 forks source link

linux: PE binaries need a different debug_name from name #164

Open ishitatsuyuki opened 3 months ago

ishitatsuyuki commented 3 months ago

The Linux backend currently assumes that files have a debug_name equivalent to name (and likewise for name): https://github.com/mstange/samply/blob/5bf04b01ff1f564ed20bdc4b60d7baa94cbe03cd/samply/src/linux_shared/converter.rs#L1451-L1460

This assumption is valid for ELF, but not for PE (e.g. binaries running on Wine). PE binaries would get the wrong debug_name which will:

We already have a helper in wholesym to determine the correct debug_ids, so we should probably extend the helper to the entire LibraryInfo.

mstange commented 3 months ago

wholesym has library_info_for_binary_at_path, but it's async.

In https://github.com/mstange/samply/pull/141/commits/2bcbdf1667ea3f9b4248100894865d3246e06760 we're duplicating this code into the samply package (but with sync IO). Once that PR lands we can move it to samply/src/shared and use it in the Linux converter.