Date: Sat, 14 Dec 2013 20:12:28 +0000 (UTC) From: Justin Hibbits <jhibbits@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r259395 - head/sys/dev/hwpmc Message-ID: <201312142012.rBEKCS3m035854@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhibbits Date: Sat Dec 14 20:12:28 2013 New Revision: 259395 URL: http://svnweb.freebsd.org/changeset/base/259395 Log: Add userland PMC backtracing, and use the PMC trapframe macros for kernel backtraces. MFC after: 1 week Modified: head/sys/dev/hwpmc/hwpmc_powerpc.c Modified: head/sys/dev/hwpmc/hwpmc_powerpc.c ============================================================================== --- head/sys/dev/hwpmc/hwpmc_powerpc.c Sat Dec 14 19:01:24 2013 (r259394) +++ head/sys/dev/hwpmc/hwpmc_powerpc.c Sat Dec 14 20:12:28 2013 (r259395) @@ -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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201312142012.rBEKCS3m035854>