Halt-And-Catch-Fire macro
This commit is contained in:
parent
2da088f031
commit
9e2483d78e
@ -14,6 +14,8 @@ void kmain()
|
|||||||
debug_ok("This thing worked well!\n");
|
debug_ok("This thing worked well!\n");
|
||||||
debug_warning("Careful!\n");
|
debug_warning("Careful!\n");
|
||||||
debug_error("Something went wrong!\n");
|
debug_error("Something went wrong!\n");
|
||||||
|
|
||||||
|
PANIC("Reached end of kernel main function\n");
|
||||||
for(;;);
|
for(;;);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,3 +22,17 @@ void debug_printf(char *fmt, ...);
|
|||||||
void debug_puts(char *s);
|
void debug_puts(char *s);
|
||||||
void debug_putsn(char *s, size_t n);
|
void debug_putsn(char *s, size_t n);
|
||||||
void debug_putch(char c);
|
void debug_putch(char c);
|
||||||
|
|
||||||
|
#define S(x) #x
|
||||||
|
#define S_(x) S(x)
|
||||||
|
#define S__LINE__ S_(__LINE__)
|
||||||
|
#define PANIC(...) \
|
||||||
|
do{ \
|
||||||
|
debug("\n\nKernel panic!\n%s:%d\n", __FILE__, __LINE__); \
|
||||||
|
debug(__VA_ARGS__); \
|
||||||
|
volatile int _override = 0; \
|
||||||
|
while(1){ \
|
||||||
|
asm("panic_breakpoint_" S__LINE__ ":"); \
|
||||||
|
if(_override) break; \
|
||||||
|
} \
|
||||||
|
}while(0)
|
||||||
|
@ -11,6 +11,24 @@ target remote :1234
|
|||||||
set height 0
|
set height 0
|
||||||
set width 0
|
set width 0
|
||||||
|
|
||||||
|
# The PANIC() macro - defined in src/kernel/include/debug.h - creates
|
||||||
|
# a label of the form panic_breakpoint_xxx, where xxx is a number.
|
||||||
|
# Unfortunately, gdb can set breakpoints on FUNCTIONS based on regex, but
|
||||||
|
# not on LABELS.
|
||||||
|
# The following piece of python code runs objdump to extract all panic_breakpoint
|
||||||
|
# labels, and set breakpoints for each.
|
||||||
|
python
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
dump = subprocess.Popen(("objdump", "-t", os.environ['BUILDROOT'] + "sysroot/kernel"), stdout=subprocess.PIPE)
|
||||||
|
lines = subprocess.check_output(('grep', 'panic_breakpoint'), stdin=dump.stdout)
|
||||||
|
dump.wait()
|
||||||
|
for line in lines.split('\n'):
|
||||||
|
name = line.split(' ')[-1]
|
||||||
|
if name:
|
||||||
|
gdb.execute('b ' + name, to_string=True)
|
||||||
|
end
|
||||||
|
|
||||||
define q
|
define q
|
||||||
monitor quit
|
monitor quit
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user