Date: Wed, 15 Jan 2014 04:44:53 +0000 (UTC) From: Justin Hibbits <jhibbits@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r260669 - in stable/10/sys: dev/hwpmc powerpc/include Message-ID: <201401150444.s0F4irhv045628@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhibbits Date: Wed Jan 15 04:44:52 2014 New Revision: 260669 URL: http://svnweb.freebsd.org/changeset/base/260669 Log: MFC r259394,r259395,r259699 r259394: Rebase the PMC indices at 1, since PMC_SOFT is at 0. r259395,r259699: Add userland PMC backtracing, and use the PMC trapframe macros for kernel backtraces. Modified: stable/10/sys/dev/hwpmc/hwpmc_powerpc.c stable/10/sys/powerpc/include/pmc_mdep.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hwpmc/hwpmc_powerpc.c ============================================================================== --- stable/10/sys/dev/hwpmc/hwpmc_powerpc.c Wed Jan 15 04:25:54 2014 (r260668) +++ stable/10/sys/dev/hwpmc/hwpmc_powerpc.c Wed Jan 15 04:44:52 2014 (r260669) @@ -45,6 +45,8 @@ __FBSDID("$FreeBSD$"); #define INKERNEL(x) (((vm_offset_t)(x)) <= VM_MAX_KERNEL_ADDRESS && \ ((vm_offset_t)(x)) >= VM_MIN_KERNEL_ADDRESS) +#define INUSER(x) (((vm_offset_t)(x)) <= VM_MAXUSER_ADDRESS && \ + ((vm_offset_t)(x)) >= VM_MIN_ADDRESS) struct powerpc_cpu **powerpc_pcpu; @@ -55,13 +57,13 @@ pmc_save_kernel_callchain(uintptr_t *cc, int frames = 0; uintptr_t *sp; - cc[frames++] = tf->srr0; - sp = (uintptr_t *)tf->fixreg[1]; + cc[frames++] = PMC_TRAPFRAME_TO_PC(tf); + sp = (uintptr_t *)PMC_TRAPFRAME_TO_FP(tf); for (frames = 1; frames < maxsamples; frames++) { if (!INKERNEL(sp)) break; - cc[frames++] = *(sp + 1); + cc[frames++] = sp[1]; sp = (uintptr_t *)*sp; } return (frames); @@ -172,8 +174,17 @@ int pmc_save_user_callchain(uintptr_t *cc, int maxsamples, struct trapframe *tf) { - (void) cc; - (void) maxsamples; - (void) tf; - return (0); + uintptr_t *sp; + int frames = 0; + + cc[frames++] = PMC_TRAPFRAME_TO_PC(tf); + sp = (uintptr_t *)PMC_TRAPFRAME_TO_FP(tf); + + for (frames = 1; frames < maxsamples; frames++) { + if (!INUSER(sp)) + break; + cc[frames++] = fuword(sp + 1); + sp = (uintptr_t *)fuword(sp); + } + return (frames); } Modified: stable/10/sys/powerpc/include/pmc_mdep.h ============================================================================== --- stable/10/sys/powerpc/include/pmc_mdep.h Wed Jan 15 04:25:54 2014 (r260668) +++ stable/10/sys/powerpc/include/pmc_mdep.h Wed Jan 15 04:44:52 2014 (r260669) @@ -7,8 +7,8 @@ #ifndef _MACHINE_PMC_MDEP_H_ #define _MACHINE_PMC_MDEP_H_ -#define PMC_MDEP_CLASS_INDEX_PPC7450 0 -#define PMC_MDEP_CLASS_INDEX_PPC970 0 +#define PMC_MDEP_CLASS_INDEX_PPC7450 1 +#define PMC_MDEP_CLASS_INDEX_PPC970 1 union pmc_md_op_pmcallocate { uint64_t __pad[4]; @@ -28,8 +28,8 @@ union pmc_md_pmc { struct pmc_md_powerpc_pmc pm_powerpc; }; -#define PMC_TRAPFRAME_TO_PC(TF) (0) /* Stubs */ -#define PMC_TRAPFRAME_TO_FP(TF) (0) +#define PMC_TRAPFRAME_TO_PC(TF) ((TF)->srr0) +#define PMC_TRAPFRAME_TO_FP(TF) ((TF)->fixreg[1]) #define PMC_TRAPFRAME_TO_SP(TF) (0) #endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201401150444.s0F4irhv045628>