X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flib%2Fdebug.c;h=4f0f5f303cf933dab61c1b1e6f723d7ed7b8bb6b;hb=5c57af78c2bf3834ade817ade0acc35a160ac0b6;hp=2082eedd5714824894f56cb6225c91d8008fc935;hpb=f2f8875638593bd5365cfd6a5ba7c9578e52322f;p=pintos-anon diff --git a/src/lib/debug.c b/src/lib/debug.c index 2082eed..4f0f5f3 100644 --- a/src/lib/debug.c +++ b/src/lib/debug.c @@ -5,7 +5,9 @@ #include #include #ifdef KERNEL +#include "threads/init.h" #include "threads/interrupt.h" +#include "devices/serial.h" #else #include #endif @@ -60,8 +62,9 @@ debug_message (const char *file, int line, const char *function, } } -/* Halts the OS, printing the source file name, line number, and - function name, plus a user-specific message. */ +/* Halts the OS or user program, printing the source file name, + line number, and function name, plus a user-specific + message. */ void debug_panic (const char *file, int line, const char *function, const char *message, ...) @@ -72,7 +75,12 @@ debug_panic (const char *file, int line, const char *function, intr_disable (); #endif - printf ("PANIC at %s:%d in %s(): ", file, line, function); +#ifdef KERNEL + printf ("Kernel PANIC at %s:%d in %s(): ", file, line, function); +#else + printf ("User process panic at %s:%d in %s(): ", file, line, function); +#endif + va_start (args, message); vprintf (message, args); printf ("\n"); @@ -80,7 +88,14 @@ debug_panic (const char *file, int line, const char *function, debug_backtrace (); + printf ("The `backtrace' program can make call stacks useful.\n" + "Read \"Backtraces\" in the \"Debugging Tools\" chapter\n" + "of the Pintos documentation for more information.\n"); + #ifdef KERNEL + serial_flush (); + if (power_off_when_done) + power_off (); for (;;); #else exit (1);