* more re-work
[mascara-docs.git] / i386 / junos / ucla / src / lab5 / lib / panic.c
blob7e9183003c24cfc50df276827b8a34f7e2ec5deb
1 #include <inc/lib.h>
3 const char *argv0;
5 /*
6 * Panic is called on unresolvable fatal errors.
7 * It prints "panic: <message>", then causes a breakpoint exception,
8 * which causes JOS to enter the JOS kernel monitor.
9 */
10 void
11 _panic(const char *file, int line, const char *fmt, ...)
13 va_list ap;
15 va_start(ap, fmt);
17 // Print the panic message
18 if (argv0)
19 cprintf("%s: ", argv0);
20 cprintf("[%08x] user panic in %s at %s:%d: ",
21 sys_getenvid(), binaryname, file, line);
22 vcprintf(fmt, ap);
23 cprintf("\n");
25 // Cause a breakpoint exception
26 while (1)
27 asm volatile("int3");