If db_onpanic is unset and DDB is compiled in, panic() now calls

db_stack_trace_print(__builtin_frame_address(0),...), to printf() the
stack trace to the message bufffer and console. Idea from SunOS/Solaris.
Useful when dumping fails.
This commit is contained in:
jhawk 2000-05-26 20:25:57 +00:00
parent b2bc655ba8
commit 1fe6e4844f
2 changed files with 34 additions and 7 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: panic.9,v 1.7 1999/03/06 22:09:29 mycroft Exp $
.\" $NetBSD: panic.9,v 1.8 2000/05/26 20:25:57 jhawk Exp $
.\"
.\" Copyright (c) 1996 Michael Graff.
.\" All rights reserved.
@ -29,7 +29,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd August 11, 1995
.Dd May 26, 2000
.Dt PANIC 9
.Os
.Sh NAME
@ -53,11 +53,25 @@ is a
style format string which is printed to the console and saved in the
variable
.Va panicstr
for later retrival via core dump inspection.
for later retrieval via core dump inspection.
.Pp
If a kernel debugger is installed, control is passed to it after the
message is printed.
Otherwise an attempt is made to save an image of system memory on the
message is printed. If the kernel debugger is
.Xr ddb 4 ,
control is only passed if the value of the
.Em ddb.onpanic
.Xr sysctl 3
is
.Dq 1 ,
otherwise, a
.Xr ddb 4 -specific
function is used to print the kernel stack trace, and then control returns
to
.Fn panic .
.Pp
If control remains in
.Fn panic ,
an attempt is made to save an image of system memory on the
dump device that was configured at the time the kernel was compiled.
.Pp
If during the process of handling the panic,
@ -70,5 +84,9 @@ The
.Fn panic
function does not return.
.Sh SEE ALSO
.Xr sysctl 3 ,
.Xr ddb 4 ,
.Xr ipkdb 4 ,
.Xr options 4 ,
.Xr savecore 8
.Xr savecore 8 ,
.Xr sysctl 8

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_prf.c,v 1.71 2000/05/25 21:32:41 jhawk Exp $ */
/* $NetBSD: subr_prf.c,v 1.72 2000/05/26 20:25:57 jhawk Exp $ */
/*-
* Copyright (c) 1986, 1988, 1991, 1993
@ -63,6 +63,9 @@
#ifdef DDB
#include <ddb/ddbvar.h>
#include <machine/db_machdep.h>
#include <ddb/db_command.h>
#include <ddb/db_interface.h>
#endif
#ifdef IPKDB
@ -214,6 +217,12 @@ panic(fmt, va_alist)
#ifdef DDB
if (db_onpanic)
Debugger();
else {
printf("Begin traceback...\n");
db_stack_trace_print((db_expr_t)__builtin_frame_address(0),
TRUE, 65535, "", printf);
printf("End traceback...\n");
}
#endif
cpu_reboot(bootopt, NULL);
}