8 #include "threads/init.h"
9 #include "threads/interrupt.h"
10 #include "devices/serial.h"
15 /* Halts the OS or user program, printing the source file name,
16 line number, and function name, plus a user-specific
19 debug_panic (const char *file, int line, const char *function,
20 const char *message, ...)
29 printf ("Kernel PANIC at %s:%d in %s(): ", file, line, function);
31 printf ("User process panic at %s:%d in %s(): ", file, line, function);
34 va_start (args, message);
35 vprintf (message, args);
41 printf ("The `backtrace' program can make call stacks useful.\n"
42 "Read \"Backtraces\" in the \"Debugging Tools\" chapter\n"
43 "of the Pintos documentation for more information.\n");
47 if (power_off_when_done)
55 /* Prints the call stack, that is, a list of addresses, one in
56 each of the functions we are nested within. gdb or addr2line
57 may be applied to kernel.o to translate these into file names,
58 line numbers, and function names. */
60 debug_backtrace (void)
64 printf ("Call stack:");
65 for (frame = __builtin_frame_address (0);
66 frame != NULL && frame[0] != NULL;
68 printf (" %p", frame[1]);