* same with xv6
[mascara-docs.git] / i386 / ucla / src / lab4 / lib / panic.c
blobd5c8c44957efccd7f109dc79fb4a5ca03c3378c8
2 #include <inc/lib.h>
4 char *argv0;
6 /*
7 * Panic is called on unresolvable fatal errors.
8 * It prints "panic: <message>", then causes a breakpoint exception,
9 * which causes JOS to enter the JOS kernel monitor.
11 void
12 _panic(const char *file, int line, const char *fmt, ...)
14 va_list ap;
16 va_start(ap, fmt);
18 // Print the panic message
19 if (argv0)
20 cprintf("%s: ", argv0);
21 cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
22 vcprintf(fmt, ap);
23 cprintf("\n");
25 // Cause a breakpoint exception
26 while (1)
27 asm volatile("int3");