Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Feb 2014 04:45:30 +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: r262547 - head/sys/dev/hwpmc
Message-ID:  <201402270445.s1R4jURD004266@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhibbits
Date: Thu Feb 27 04:45:29 2014
New Revision: 262547
URL: http://svnweb.freebsd.org/changeset/base/262547

Log:
  Fix callchain capture for hwpmc(4).  While here, some style(9) fixes, too.
  
  MFC after:	2 weeks

Modified:
  head/sys/dev/hwpmc/hwpmc_powerpc.c

Modified: head/sys/dev/hwpmc/hwpmc_powerpc.c
==============================================================================
--- head/sys/dev/hwpmc/hwpmc_powerpc.c	Thu Feb 27 04:06:34 2014	(r262546)
+++ head/sys/dev/hwpmc/hwpmc_powerpc.c	Thu Feb 27 04:45:29 2014	(r262547)
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/param.h>
 #include <sys/pmc.h>
 #include <sys/pmckern.h>
+#include <sys/sysent.h>
 #include <sys/systm.h>
 
 #include <machine/pmc_mdep.h>
@@ -60,10 +61,14 @@ pmc_save_kernel_callchain(uintptr_t *cc,
 	cc[frames++] = PMC_TRAPFRAME_TO_PC(tf);
 	sp = (uintptr_t *)PMC_TRAPFRAME_TO_FP(tf);
 
-	for (frames = 1; frames < maxsamples; frames++) {
+	for (; frames < maxsamples; frames++) {
 		if (!INKERNEL(sp))
 			break;
+#ifdef __powerpc64__
+		cc[frames++] = sp[2];
+#else
 		cc[frames++] = sp[1];
+#endif
 		sp = (uintptr_t *)*sp;
 	}
 	return (frames);
@@ -72,12 +77,14 @@ pmc_save_kernel_callchain(uintptr_t *cc,
 static int
 powerpc_switch_in(struct pmc_cpu *pc, struct pmc_process *pp)
 {
+
 	return (0);
 }
 
 static int
 powerpc_switch_out(struct pmc_cpu *pc, struct pmc_process *pp)
 {
+
 	return (0);
 }
 
@@ -111,6 +118,7 @@ powerpc_describe(int cpu, int ri, struct
 int
 powerpc_get_config(int cpu, int ri, struct pmc **ppm)
 {
+
 	*ppm = powerpc_pcpu[cpu]->pc_ppcpmcs[ri].phw_pmc;
 
 	return (0);
@@ -182,11 +190,23 @@ pmc_save_user_callchain(uintptr_t *cc, i
 	cc[frames++] = PMC_TRAPFRAME_TO_PC(tf);
 	sp = (uintptr_t *)PMC_TRAPFRAME_TO_FP(tf);
 
-	for (frames = 1; frames < maxsamples; frames++) {
+	for (; frames < maxsamples; frames++) {
 		if (!INUSER(sp))
 			break;
-		cc[frames++] = fuword(sp + 1);
-		sp = (uintptr_t *)fuword(sp);
+#ifdef __powerpc64__
+		/* Check if 32-bit mode. */
+		if (!(tf->srr1 & PSL_SF)) {
+			cc[frames++] = fuword32((uint32_t *)sp + 1);
+			sp = (uintptr_t *)(uintptr_t)fuword32(sp);
+		} else {
+			cc[frames++] = fuword(sp + 2);
+			sp = (uintptr_t *)fuword(sp);
+		}
+#else
+		cc[frames++] = fuword32((uint32_t *)sp + 1);
+		sp = (uintptr_t *)fuword32(sp);
+#endif
 	}
+
 	return (frames);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201402270445.s1R4jURD004266>