From f025f685e965ac9ee1cd35ff3636c8554d9939d2 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Sat, 1 Oct 2016 13:25:22 +0200 Subject: kern: Improve assertions and panics. * kern/assert.h (Assert): Add function argument. (assert): Supply function argument. * kern/debug.c (Assert): Add function argument. Unify message format. (panic): Rename to 'Panic', add location information. * kern/debug.h (panic): Rename, and add a macro version that supplies the location. * linux/dev/include/linux/kernel.h: Use the new panic macro. --- kern/debug.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'kern/debug.c') diff --git a/kern/debug.c b/kern/debug.c index 0d01b84f..78c55f81 100644 --- a/kern/debug.c +++ b/kern/debug.c @@ -51,16 +51,16 @@ do_cnputc(char c, vm_offset_t offset) } void -Assert(const char *exp, const char *file, int line) +Assert(const char *exp, const char *file, int line, const char *fun) { #if NCPUS > 1 simple_lock(&Assert_print_lock); - printf("{%d} Assertion failed: file \"%s\", line %d\n", - cpu_number(), file, line); + printf("{cpu%d} %s:%d: %s: Assertion `%s' failed.", + cpu_number(), file, line, fun, exp); simple_unlock(&Assert_print_lock); #else - printf("Assertion `%s' failed in file \"%s\", line %d\n", - exp, file, line); + printf("%s:%d: %s: Assertion `%s' failed.", + file, line, fun, exp); #endif Debugger("assertion failure"); @@ -136,7 +136,7 @@ extern boolean_t reboot_on_panic; /*VARARGS1*/ void -panic(const char *s, ...) +Panic(const char *file, int line, const char *fun, const char *s, ...) { va_list listp; @@ -155,11 +155,11 @@ panic(const char *s, ...) paniccpu = cpu_number(); } simple_unlock(&panic_lock); - printf("panic"); + printf("panic "); #if NCPUS > 1 - printf("(cpu %U)", paniccpu); + printf("{cpu%d} ", paniccpu); #endif - printf(": "); + printf("%s:%d: %s: ",file, line, fun); va_start(listp, s); _doprnt(s, listp, do_cnputc, 16, 0); va_end(listp); -- cgit v1.2.3