+ for ( ; frame_index < maxAddrs; frame_index++)
+ bt[frame_index] = (void *) 0;
+#elif __x86_64__
+#define SANE_x86_64_FRAME_SIZE (kernel_stack_size >> 1)
+ vm_offset_t stackptr, stackptr_prev, raddr;
+ unsigned frame_index = 0;
+/* Obtain current frame pointer */
+
+ __asm__ volatile("movq %%rbp, %0" : "=m" (stackptr));
+
+ if (!x86_64_validate_stackptr(stackptr))
+ goto pad;
+
+ raddr = *((vm_offset_t *) (stackptr + x86_64_RETURN_OFFSET));
+
+ if (!x86_64_validate_raddr(raddr))
+ goto pad;
+
+ bt[frame_index++] = (void *) raddr;
+
+ for ( ; frame_index < maxAddrs; frame_index++) {
+ stackptr_prev = stackptr;
+ stackptr = *((vm_offset_t *) stackptr_prev);
+
+ if (!x86_64_validate_stackptr(stackptr))
+ break;
+ /* Stack grows downwards */
+ if (stackptr < stackptr_prev)
+ break;
+
+ if ((stackptr - stackptr_prev) > SANE_x86_64_FRAME_SIZE)
+ break;
+
+ raddr = *((vm_offset_t *) (stackptr + x86_64_RETURN_OFFSET));
+
+ if (!x86_64_validate_raddr(raddr))
+ break;
+
+ bt[frame_index] = (void *) raddr;
+ }
+pad:
+ frame = frame_index;
+