[hwpmc] Fix call chain capture for ARM64
authorOleksandr Tymoshenko <gonzo@FreeBSD.org>
Thu, 22 Oct 2020 05:07:25 +0000 (05:07 +0000)
committerOleksandr Tymoshenko <gonzo@FreeBSD.org>
Thu, 22 Oct 2020 05:07:25 +0000 (05:07 +0000)
commitf85aa8589510cea6386047163985c8ea1fa6b73e
tree4b8d008425e607db75d1639405a479402c9971a7
parentd2112ab098225f37dbba3f24be16a49fc521f7e8
[hwpmc] Fix call chain capture for ARM64

Use ELR register value instead of LR for PMC_TRAPFRAME_TO_PC macro since
it's the former that indicates PC if the interrupted execution thread.

This fixes a bug where pmcstat lost the leaf function of the call chain
and started with the second function in the chain.

Although this change is an improvement over the previous logic there is still
posibility for incomplete data: if the leaf function does not have stack
variables and does not call any other functions compiler would not generate
a stack frame for it and the FP value would point to the caller's frame, so
instead of the actual "caller1 -> caller2 -> leaf" chain only
"caller1 -> leaf" would be captured.

Sponsored by: Ampere Computing
Submitted by: Klara, Inc.
sys/arm64/include/pmc_mdep.h