From owner-p4-projects@FreeBSD.ORG Wed Feb 29 02:35:04 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A39C9106575D; Wed, 29 Feb 2012 02:35:03 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 65CE4106575B for ; Wed, 29 Feb 2012 02:35:03 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 4ABC18FC08 for ; Wed, 29 Feb 2012 02:35:03 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id q1T2Z3u5048846 for ; Wed, 29 Feb 2012 02:35:03 GMT (envelope-from gonzo@FreeBSD.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id q1T2Z3rP048843 for perforce@freebsd.org; Wed, 29 Feb 2012 02:35:03 GMT (envelope-from gonzo@FreeBSD.org) Date: Wed, 29 Feb 2012 02:35:03 GMT Message-Id: <201202290235.q1T2Z3rP048843@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 207064 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Feb 2012 02:35:04 -0000 http://p4web.freebsd.org/@@207064?ac=10 Change 207064 by gonzo@gonzo_thinkpad on 2012/02/29 02:34:41 Implement getstack function Affected files ... .. //depot/projects/dtrace-mips/sys/cddl/dev/dtrace/mips/dtrace_isa.c#3 edit Differences ... ==== //depot/projects/dtrace-mips/sys/cddl/dev/dtrace/mips/dtrace_isa.c#3 (text+ko) ==== @@ -60,7 +60,49 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes, uint32_t *intrpc) { - printf("IMPLEMENT ME: %s\n", __func__); + int depth = 0; + vm_offset_t callpc; + pc_t caller = (pc_t) solaris_cpu[curcpu].cpu_dtrace_caller; + register_t sp, ra, pc; + + if (intrpc != 0) + pcstack[depth++] = (pc_t) intrpc; + + aframes++; + + sp = (register_t)(intptr_t)__builtin_frame_address(0); + ra = (register_t)(intptr_t)__builtin_return_address(0); + + __asm __volatile( + "jal 99f\n" + "nop\n" + "99:\n" + "move %0, $31\n" /* get ra */ + "move $31, %1\n" /* restore ra */ + : "=r" (pc) + : "r" (ra)); + + while (depth < pcstack_limit) { + + callpc = pc; + + if (aframes > 0) { + aframes--; + if ((aframes == 0) && (caller != 0)) { + pcstack[depth++] = caller; + } + } + else { + pcstack[depth++] = callpc; + } + + if (next_frame(&pc, &sp, NULL, NULL) < 0) + break; + } + + for (; depth < pcstack_limit; depth++) { + pcstack[depth] = 0; + } } void