From owner-svn-src-all@FreeBSD.ORG Thu Feb 27 04:45:30 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 607FD624; Thu, 27 Feb 2014 04:45:30 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 2E68214E8; Thu, 27 Feb 2014 04:45:30 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s1R4jUhI004267; Thu, 27 Feb 2014 04:45:30 GMT (envelope-from jhibbits@svn.freebsd.org) Received: (from jhibbits@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s1R4jURD004266; Thu, 27 Feb 2014 04:45:30 GMT (envelope-from jhibbits@svn.freebsd.org) Message-Id: <201402270445.s1R4jURD004266@svn.freebsd.org> From: Justin Hibbits Date: Thu, 27 Feb 2014 04:45:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262547 - head/sys/dev/hwpmc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Feb 2014 04:45:30 -0000 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 #include #include +#include #include #include @@ -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); }