PERFORCE change 207064 for review
Oleksandr Tymoshenko
gonzo at FreeBSD.org
Wed Feb 29 02:35:04 UTC 2012
http://p4web.freebsd.org/@@207064?ac=10
Change 207064 by gonzo at 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
More information about the p4-projects
mailing list