Author: gonzo
Date: Thu Oct 22 05:07:25 2020
New Revision: 366924
URL: https://svnweb.freebsd.org/changeset/base/366924

Log:
  [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.

Modified:
  head/sys/arm64/include/pmc_mdep.h

Modified: head/sys/arm64/include/pmc_mdep.h
==============================================================================
--- head/sys/arm64/include/pmc_mdep.h   Thu Oct 22 04:49:14 2020        
(r366923)
+++ head/sys/arm64/include/pmc_mdep.h   Thu Oct 22 05:07:25 2020        
(r366924)
@@ -54,7 +54,7 @@ union pmc_md_pmc {
        ((S) >= (START) && (S) < (END))
 #define        PMC_IN_KERNEL(va)       INKERNEL((va))
 #define        PMC_IN_USERSPACE(va) ((va) <= VM_MAXUSER_ADDRESS)
-#define        PMC_TRAPFRAME_TO_PC(TF)         ((TF)->tf_lr)
+#define        PMC_TRAPFRAME_TO_PC(TF)         ((TF)->tf_elr)
 #define        PMC_TRAPFRAME_TO_FP(TF)         ((TF)->tf_x[29])
 
 /*
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to