]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/startup64.c
xnu-2050.7.9.tar.gz
[apple/xnu.git] / osfmk / i386 / startup64.c
index c85bf1955e8a9e5fa2df96fa9854670e128af1a3..b4f69f74143b69b21cf1ad83796a8794c122323f 100644 (file)
@@ -188,6 +188,7 @@ cpu_IA32e_disable(cpu_data_t *cdp)
 #endif
 
 #if DEBUG
+extern void dump_regs64(void);
 extern void dump_gdt(void *);
 extern void dump_ldt(void *);
 extern void dump_idt(void *);
@@ -264,11 +265,7 @@ dump_frame64(x86_saved_state64_t *sp)
                kprintf("%p: 0x%016llx\n", ip, *ip);
 
        kprintf("sp->isf.trapno: 0x%08x\n", sp->isf.trapno);
-#ifdef __i386__
-       kprintf("sp->isf.trapfn: 0x%08x\n", sp->isf.trapfn);
-#else
        kprintf("sp->isf.trapfn: 0x%016llx\n", sp->isf.trapfn);
-#endif
        kprintf("sp->isf.err:    0x%016llx\n", sp->isf.err);
        kprintf("sp->isf.rip:    0x%016llx\n", sp->isf.rip);
        kprintf("sp->isf.cs:     0x%016llx\n", sp->isf.cs);
@@ -353,4 +350,49 @@ dump_tss(void *tssp)
                kprintf("%p: 0x%08x\n", ip+0, *(ip+0));
        }
 }
+
+#if defined(__x86_64__)
+void dump_regs64(void)
+{
+
+#define SNAP_REG(reg)                                          \
+       uint64_t        reg;                                    \
+       __asm__ volatile("mov %%" #reg ", %0" : "=m" (reg))
+
+#define KPRINT_REG(reg)                                                \
+       kprintf("%3s: %p\n", #reg, (void *) reg)
+
+       SNAP_REG(rsp);
+       SNAP_REG(rbp);
+       SNAP_REG(rax);
+       SNAP_REG(rbx);
+       SNAP_REG(rcx);
+       SNAP_REG(rdx);
+       SNAP_REG(rsi);
+       SNAP_REG(rdi);
+       SNAP_REG(r8);
+       SNAP_REG(r9);
+       SNAP_REG(r10);
+       SNAP_REG(r11);
+       SNAP_REG(r12);
+       SNAP_REG(r13);
+       SNAP_REG(r14);
+
+       KPRINT_REG(rsp);
+       KPRINT_REG(rbp);
+       KPRINT_REG(rax);
+       KPRINT_REG(rbx);
+       KPRINT_REG(rcx);
+       KPRINT_REG(rdx);
+       KPRINT_REG(rsi);
+       KPRINT_REG(rdi);
+       KPRINT_REG(r8);
+       KPRINT_REG(r9);
+       KPRINT_REG(r10);
+       KPRINT_REG(r11);
+       KPRINT_REG(r12);
+       KPRINT_REG(r13);
+       KPRINT_REG(r14);
+}
+#endif /* __x86_64__ */
 #endif /* DEBUG */