Make debug.h non-idempotent, like <assert.h>.
[pintos-anon] / src / lib / debug.c
1 #include "debug.h"
2 #include <stdarg.h>
3 #include "interrupt.h"
4 #include "lib.h"
5
6 void
7 panic (const char *format, ...)
8 {
9   va_list args;
10
11   intr_disable ();
12
13   va_start (args, format);
14   vprintk (format, args);
15   printk ("\n");
16   va_end (args);
17
18   backtrace ();
19
20   for (;;);
21 }
22
23 void
24 backtrace (void) 
25 {
26   void **frame;
27   
28   printk ("Call stack:");
29   for (frame = __builtin_frame_address (0);
30        frame != NULL && frame[0] != NULL;
31        frame = frame[0]) 
32     printk (" %p", frame[1]);
33   printk (".\n");
34 }