20 const char *message, ...)
31 printf (
"Kernel PANIC at %s:%d in %s(): ",
file, line,
function);
41 printf (
"Kernel PANIC recursion at %s:%d in %s().\n",
42 file, line,
function);
58 void *retaddr =
NULL, **frame =
NULL;
59 const char *status =
"UNKNOWN";
78 printf (
"Call stack of thread `%s' (status %s):", t->
name, status);
82 frame = __builtin_frame_address (1);
83 retaddr = __builtin_return_address (0);
101 printf (
" thread was never scheduled.\n");
105 frame = (
void **) saved_frame->
ebp;
106 retaddr = (
void *) saved_frame->
eip;
110 for (; (
uintptr_t) frame >= 0x1000 && frame[0] !=
NULL; frame = frame[0])
void debug_backtrace(void)
Prints the call stack, that is, a list of addresses, one in each of the functions we are nested withi...
#define UNUSED
GCC lets us add "attributes" to functions, function parameters, etc.
enum intr_level intr_disable(void)
Disables interrupts and returns the previous interrupt status.
enum intr_level intr_set_level(enum intr_level level)
Enables or disables interrupts as specified by LEVEL and returns the previous interrupt status.
intr_level
Interrupts on or off?
void console_panic(void)
Notifies the console that a kernel panic is underway, which warns it to avoid trying to take the cons...
int vprintf(const char *format, va_list args)
The standard vprintf() function, which is like printf() but uses a va_list.
void debug_panic(const char *file, int line, const char *function, const char *message,...)
Halts the OS, printing the source file name, line number, and function name, plus a user-specific mes...
void debug_backtrace_all(void)
Prints call stack of all threads.
static void print_stacktrace(struct thread *t, void *aux UNUSED)
Print call stack of a thread.
int printf(const char *format,...)
Writes formatted output to the console.
void serial_flush(void)
Flushes anything in the serial buffer out the port in polling mode.
void shutdown(void)
Shuts down the machine in the way configured by shutdown_configure().
#define va_start(LIST, ARG)
__builtin_va_list va_list
GCC has <stdarg.h> functionality as built-ins, so all we need is to use it.
switch_thread()'s stack frame.
void(* eip)(void)
16: Return address.
uint32_t ebp
8: Saved ebp.
A kernel thread or user process.
uint8_t * stack
Saved stack pointer.
char name[16]
Name (for debugging purposes).
enum thread_status status
Thread state.
struct thread * thread_current(void)
Returns the running thread.
void thread_foreach(thread_action_func *func, void *aux)
Invoke function 'func' on all threads, passing along 'aux'.
@ THREAD_BLOCKED
Waiting for an event to trigger.
@ THREAD_RUNNING
Running thread.
@ THREAD_READY
Not running but ready to run.
#define PGSIZE
Bytes in a page.