svn commit: r259395 - head/sys/dev/hwpmc
Justin Hibbits
jhibbits at FreeBSD.org
Sat Dec 14 20:12:29 UTC 2013
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);
}
More information about the svn-src-head
mailing list