-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpanic.c
More file actions
60 lines (51 loc) · 1.17 KB
/
panic.c
File metadata and controls
60 lines (51 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <inc/lib.h>
char *argv0;
/*
* Panic is called on unresolvable fatal errors.
* It prints "panic: <message>", then causes a breakpoint exception,
* which causes JOS to enter the JOS kernel monitor.
*/
void
_panic(const char *file, int line, const char *fmt,...)
{
va_list ap;
va_start(ap, fmt);
// Print the panic message
if (argv0)
cprintf("%s: ", argv0);
cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
vcprintf(fmt, ap);
cprintf("\n");
// Cause a breakpoint exception
while (1)
asm volatile("int3");
}
#define ERROR 1
#define FINISHED 2
#define IN 3
#define OUT 4
#define WATCH 5
static const char * const dbg_infos[10] =
{
NULL,
"ERROR",
"FINISHED",
"IN",
"OUT",
"WATCH",
"PANIC"
};
void
_sunusdbg(int on,int act,const char *func, const char *file, int line, const char *fmt, ...)
{
va_list ap;
if(on)
{
cprintf("SUNUS : %s %d %s %s\n",file,line,func,dbg_infos[act]);
va_start(ap, fmt);
vcprintf(fmt, ap);
cprintf("\n");
if(act == 6)
panic("stop!\n");
}
}