diff options
author | Poul-Henning Kamp <phk@FreeBSD.org> | 2003-01-04 20:54:58 +0000 |
---|---|---|
committer | Poul-Henning Kamp <phk@FreeBSD.org> | 2003-01-04 20:54:58 +0000 |
commit | 3c3871e5e6e218053dc1b1fe1d48ac32560feef7 (patch) | |
tree | 03615131ce3e84045e995356032ffae0ee90cabe /sys/kern/kern_shutdown.c | |
parent | 646e95fe69280e0fb8a169e44c3dfda7e511355e (diff) |
Introduce the
void backtrace(void);
function which will print a backtrace if DDB is in the kernel and an
explanation if not.
This is useful for recording backtraces in non-fatal circumstances and
does not require pollution with DDB #includes in the files where it
is used.
It would of course be nice to have a non-DDB dependent version too,
but since the meat of a backtrace is MD it is probably not worth it.
Notes
Notes:
svn path=/head/; revision=108682
Diffstat (limited to 'sys/kern/kern_shutdown.c')
-rw-r--r-- | sys/kern/kern_shutdown.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index 1867b8a5d10a..d63ece6a411e 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -438,6 +438,20 @@ shutdown_reset(void *junk, int howto) /* NOTREACHED */ /* assuming reset worked */ } +/* + * Print a backtrace if we can. + */ + +void +backtrace(void) +{ +#ifdef DDB + db_print_backtrace(); +#else + printf("Sorry, need DDB option to print backtrace"); +#endif +} + #ifdef SMP static u_int panic_cpu = NOCPU; #endif |