Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Feb 2012 02:35:03 GMT
From:      Oleksandr Tymoshenko <gonzo@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 207064 for review
Message-ID:  <201202290235.q1T2Z3rP048843@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



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