MCPcopy Create free account
hub / github.com/HelenOS/helenos / panic_common

Function panic_common

kernel/generic/src/debug/panic.c:47–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45#define BANNER_RIGHT "<######"
46
47void panic_common(panic_category_t cat, istate_t *istate, int access,
48 uintptr_t address, const char *fmt, ...)
49{
50 console_override = true;
51
52 printf("\n%s Kernel panic ", BANNER_LEFT);
53 if (CPU)
54 printf("on cpu%u ", CPU->id);
55 printf("due to ");
56
57 va_list args;
58 va_start(args, fmt);
59 if (cat == PANIC_ASSERT) {
60 printf("a failed assertion: %s\n", BANNER_RIGHT);
61 vprintf(fmt, args);
62 printf("\n");
63 } else if (cat == PANIC_BADTRAP) {
64 printf("bad trap %" PRIuPTR ". %s\n", address,
65 BANNER_RIGHT);
66 if (fmt) {
67 vprintf(fmt, args);
68 printf("\n");
69 }
70 } else if (cat == PANIC_MEMTRAP) {
71 printf("a bad memory access while ");
72 if (access == PF_ACCESS_READ)
73 printf("loading from");
74 else if (access == PF_ACCESS_WRITE)
75 printf("storing to");
76 else if (access == PF_ACCESS_EXEC)
77 printf("branching to");
78 else
79 printf("referencing");
80 printf(" address %p. %s\n", (void *) address,
81 BANNER_RIGHT);
82 if (fmt) {
83 vprintf(fmt, args);
84 printf("\n");
85 }
86 } else {
87 printf("the following reason: %s\n",
88 BANNER_RIGHT);
89 vprintf(fmt, args);
90 printf("\n");
91 }
92 va_end(args);
93
94 printf("\n");
95
96 printf("CURRENT=%p: ", CURRENT);
97 if (CURRENT != NULL) {
98 printf("pe=%" PRIuPTR " thread=%p task=%p cpu=%p as=%p"
99 " magic=%#" PRIx32 "\n", CURRENT->preemption,
100 CURRENT->thread, CURRENT->task, CURRENT->cpu, CURRENT->as, CURRENT->magic);
101
102 if (CURRENT->thread != NULL)
103 printf("thread=\"%s\"\n", CURRENT->thread->name);
104

Callers

nothing calls this directly

Calls 5

stack_traceFunction · 0.85
haltFunction · 0.85
printfFunction · 0.50
vprintfFunction · 0.50
istate_decodeFunction · 0.50

Tested by

no test coverage detected