From owner-svn-src-all@FreeBSD.ORG Sat Dec 14 20:12:29 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2AAD8CCF; Sat, 14 Dec 2013 20:12:29 +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 168361AB7; Sat, 14 Dec 2013 20:12:29 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rBEKCSMm035855; Sat, 14 Dec 2013 20:12:28 GMT (envelope-from jhibbits@svn.freebsd.org) Received: (from jhibbits@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rBEKCS3m035854; Sat, 14 Dec 2013 20:12:28 GMT (envelope-from jhibbits@svn.freebsd.org) Message-Id: <201312142012.rBEKCS3m035854@svn.freebsd.org> From: Justin Hibbits Date: Sat, 14 Dec 2013 20:12:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r259395 - 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: Sat, 14 Dec 2013 20:12:29 -0000 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); }