Hi, Someone, somewhere (perhaps on bugs@?) said they would like to see something useful when typing show panic on a page fault'd kernel. That struck very close to home so I went ahead and did it.
The following diff shows the uvm_fault and the first trace entry in an attempt to mimic a real show panic. The uvm_fault entry is extra. Currently I only wrote support for amd64 but I can add support for other architectures if you guys like it. Thoughts? Paul Index: arch/amd64/amd64/trap.c =================================================================== RCS file: /cvs/src/sys/arch/amd64/amd64/trap.c,v retrieving revision 1.62 diff -u -p -u -p -r1.62 trap.c --- arch/amd64/amd64/trap.c 14 Oct 2017 04:44:43 -0000 1.62 +++ arch/amd64/amd64/trap.c 4 Nov 2017 15:15:47 -0000 @@ -380,12 +380,16 @@ faultcommon: } if (type == T_PAGEFLT) { + static char faultbuf[512]; if (pcb->pcb_onfault != 0) { KERNEL_UNLOCK(); goto copyfault; } - printf("uvm_fault(%p, 0x%lx, 0, %d) -> %x\n", + snprintf(faultbuf, sizeof faultbuf, + "uvm_fault(%p, 0x%lx, 0, %d) -> %x", map, fa, ftype, error); + printf("%s\n", faultbuf); + faultstr = faultbuf; goto we_re_toast; } Index: ddb/db_command.c =================================================================== RCS file: /cvs/src/sys/ddb/db_command.c,v retrieving revision 1.79 diff -u -p -u -p -r1.79 db_command.c --- ddb/db_command.c 19 Oct 2017 16:58:05 -0000 1.79 +++ ddb/db_command.c 4 Nov 2017 15:15:48 -0000 @@ -51,6 +51,7 @@ #include <ddb/db_watch.h> #include <ddb/db_run.h> #include <ddb/db_sym.h> +#include <ddb/db_var.h> #include <ddb/db_variables.h> #include <ddb/db_interface.h> #include <ddb/db_extern.h> @@ -500,6 +501,11 @@ db_show_panic_cmd(db_expr_t addr, int ha { if (panicstr) db_printf("%s\n", panicstr); + else if (faultstr) { + db_printf("kernel page fault\n"); + db_printf("%s\n", faultstr); + db_stack_trace_print(addr, have_addr, 1, modif, db_printf); + } else db_printf("the kernel did not panic\n"); /* yet */ } Index: kern/subr_prf.c =================================================================== RCS file: /cvs/src/sys/kern/subr_prf.c,v retrieving revision 1.91 diff -u -p -u -p -r1.91 subr_prf.c --- kern/subr_prf.c 30 Apr 2017 16:45:46 -0000 1.91 +++ kern/subr_prf.c 4 Nov 2017 15:15:48 -0000 @@ -100,6 +100,7 @@ struct mutex kprintf_mutex = extern int log_open; /* subr_log: is /dev/klog open? */ const char *panicstr; /* arg to first call to panic (used as a flag to indicate that panic has already been called). */ +const char *faultstr; /* page fault string */ #ifdef DDB /* * Enter ddb on panic. Index: sys/systm.h =================================================================== RCS file: /cvs/src/sys/sys/systm.h,v retrieving revision 1.133 diff -u -p -u -p -r1.133 systm.h --- sys/systm.h 11 Aug 2017 21:24:20 -0000 1.133 +++ sys/systm.h 4 Nov 2017 15:15:49 -0000 @@ -72,6 +72,7 @@ */ extern int securelevel; /* system security level */ extern const char *panicstr; /* panic message */ +extern const char *faultstr; /* fault message */ extern const char version[]; /* system version */ extern const char copyright[]; /* system copyright */ extern const char ostype[];