X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flib%2Fdebug.c;h=6d75e7a34c47bf25332d5a9cc24ac9cc153c217b;hb=f0ad7eb8b43516c7a2999fd217ec85d954dfc791;hp=2388a2daa3f23c7773c21094122b13c17c413610;hpb=6c24be470e7190a8888c8be707c2bc7d0290d204;p=pintos-anon diff --git a/src/lib/debug.c b/src/lib/debug.c index 2388a2d..6d75e7a 100644 --- a/src/lib/debug.c +++ b/src/lib/debug.c @@ -5,6 +5,7 @@ #include #include #ifdef KERNEL +#include "threads/init.h" #include "threads/interrupt.h" #include "devices/serial.h" #else @@ -61,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, ...) @@ -73,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"); @@ -83,6 +90,8 @@ debug_panic (const char *file, int line, const char *function, #ifdef KERNEL serial_flush (); + if (power_off_when_done) + power_off (); for (;;); #else exit (1);