]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Load the stack in stack_save and stack_save_td. This uses the generalised
authorandrew <andrew@FreeBSD.org>
Fri, 31 Jul 2015 15:32:32 +0000 (15:32 +0000)
committerandrew <andrew@FreeBSD.org>
Fri, 31 Jul 2015 15:32:32 +0000 (15:32 +0000)
unwind_frame function to read each stack frame until either the pc or stack
are no longer withing the kernel's address space.

Obtained from: ABT Systems Ltd
Sponsored by: The FreeBSD Foundation

sys/arm64/arm64/stack_machdep.c
sys/conf/files.arm64

index 7449eaa2199e856f47278c42d6595db522bb0b8a..72a9ab9e92b6f0205f8f59beae41cf18fb1fec04 100644 (file)
@@ -40,21 +40,49 @@ __FBSDID("$FreeBSD$");
 #include <machine/pcb.h>
 #include <machine/stack.h>
 
+static void
+stack_capture(struct stack *st, struct unwind_state *frame)
+{
+
+       stack_zero(st);
+       while (1) {
+               unwind_frame(frame);
+               if (!INKERNEL((vm_offset_t)frame->fp) ||
+                    !INKERNEL((vm_offset_t)frame->pc))
+                       break;
+               if (stack_put(st, frame->pc) == -1)
+                       break;
+       }
+}
+
 void
 stack_save_td(struct stack *st, struct thread *td)
 {
+       struct unwind_state frame;
 
        if (TD_IS_SWAPPED(td))
                panic("stack_save_td: swapped");
        if (TD_IS_RUNNING(td))
                panic("stack_save_td: running");
 
-       stack_zero(st); /* ARM64TODO */
+       frame.sp = td->td_pcb->pcb_sp;
+       frame.fp = td->td_pcb->pcb_x[29];
+       frame.pc = td->td_pcb->pcb_x[30];
+
+       stack_capture(st, &frame);
 }
 
 void
 stack_save(struct stack *st)
 {
+       struct unwind_state frame;
+       uint64_t sp;
+
+       __asm __volatile("mov %0, sp" : "=&r" (sp));
+
+       frame.sp = sp;
+       frame.fp = (uint64_t)__builtin_frame_address(0);
+       frame.pc = (uint64_t)stack_save;
 
-       stack_zero(st); /* ARM64TODO */
+       stack_capture(st, &frame);
 }
index a26d95acb67a46aa46aa06fa0f433eac8d74712a..6a8c9661a6a450eb1a8771ca014c5ac1004266a1 100644 (file)
@@ -40,14 +40,14 @@ arm64/arm64/mp_machdep.c    optional        smp
 arm64/arm64/nexus.c            standard
 arm64/arm64/pic_if.m           standard
 arm64/arm64/pmap.c             standard
-arm64/arm64/stack_machdep.c    standard
+arm64/arm64/stack_machdep.c    optional        ddb | stack
 arm64/arm64/support.S          standard
 arm64/arm64/swtch.S            standard
 arm64/arm64/sys_machdep.c      standard
 arm64/arm64/trap.c             standard
 arm64/arm64/uio_machdep.c      standard
 arm64/arm64/uma_machdep.c      standard
-arm64/arm64/unwind.c           optional        ddb | kdtrace_hooks
+arm64/arm64/unwind.c           optional        ddb | kdtrace_hooks | stack
 arm64/arm64/vfp.c              standard
 arm64/arm64/vm_machdep.c       standard
 crypto/blowfish/bf_enc.c       optional        crypto | ipsec