git: 0f906b30e6fa - main - i386: print all GPRs, PSL, and CR3 on double fault

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 24 Aug 2022 19:25:15 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=0f906b30e6fa5bed3c8468a6cab3847cf6909936

commit 0f906b30e6fa5bed3c8468a6cab3847cf6909936
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-08-18 04:16:09 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-08-24 19:12:30 +0000

    i386: print all GPRs, PSL, and CR3 on double fault
    
    Also compactify the printfs, and remove comment about 'two prints'.
    Their arguments are on same page, so one fault implies another.
    
    Reviewed by:    jhb
    Tested by:      pho
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D36302
---
 sys/i386/i386/trap.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c
index 578aa0ad49d9..8765bebfd5b9 100644
--- a/sys/i386/i386/trap.c
+++ b/sys/i386/i386/trap.c
@@ -988,18 +988,26 @@ trap_user_dtrace(struct trapframe *frame, int (**hookp)(struct trapframe *))
 void
 dblfault_handler(void)
 {
+	struct i386tss *t;
+
 #ifdef KDTRACE_HOOKS
 	if (dtrace_doubletrap_func != NULL)
 		(*dtrace_doubletrap_func)();
 #endif
 	printf("\nFatal double fault:\n");
-	printf("eip = 0x%x\n", PCPU_GET(common_tssp)->tss_eip);
-	printf("esp = 0x%x\n", PCPU_GET(common_tssp)->tss_esp);
-	printf("ebp = 0x%x\n", PCPU_GET(common_tssp)->tss_ebp);
+	t = PCPU_GET(common_tssp);
+	printf(
+	    "eip = %#08x esp = %#08x ebp = %#08x eax = %#08x\n"
+	    "edx = %#08x ecx = %#08x edi = %#08x esi = %#08x\n"
+	    "psl = %#08x cs  = %#08x ss  = %#08x ds  = %#08x\n"
+	    "es  = %#08x fs  = %#08x gs  = %#08x cr3 = %#08x\n",
+	    t->tss_eip, t->tss_esp, t->tss_ebp, t->tss_eax,
+	    t->tss_edx, t->tss_ecx, t->tss_edi, t->tss_esi,
+	    t->tss_eflags, t->tss_cs, t->tss_ss, t->tss_ds,
+	    t->tss_es, t->tss_fs, t->tss_gs, t->tss_cr3);
 #ifdef SMP
-	/* two separate prints in case of a trap on an unmapped page */
-	printf("cpuid = %d; ", PCPU_GET(cpuid));
-	printf("apic id = %02x\n", PCPU_GET(apic_id));
+	printf("cpuid = %d; apic id = %02x\n", PCPU_GET(cpuid),
+	    PCPU_GET(apic_id));
 #endif
 	panic("double fault");
 }