mstange / samply

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

Dont double adjust return addresses in imported simpleperf profiles #237

Closed mstange closed 1 month ago

mstange commented 1 month ago

The addresses in call chains in perf.data files from simpleperf have already been adjusted to point into the call instruction. This is different from what we're used to from perf.data files generated by Linux perf.

The adjustment happens in two places:

If the unwinding happens in the kernel, the callchains are adjusted in SampleRecord::AdjustCallChainGeneratedByKernel().

If simpleperf does the unwinding of the user stack itself, the callchains are adjusted in libunwindstack, i.e in the unwinder that's used by simpleperf:

https://cs.android.com/android/platform/superproject/+/main:system/unwinding/libunwindstack/Unwinder.cpp;l=177;drc=8e2c60d01e0928275d30f320c3f83ac4f29b880c https://cs.android.com/android/platform/superproject/+/main:system/unwinding/libunwindstack/Regs.cpp;l=175-224;drc=c0fa0c327e58eda604b2fd00b81f1c12817542d3