Implement ddb setting that allows all ddb output to be teed into the
kernel message buffer/log. Its off by default and can be switched on in the kernel configuration on build time, be set as a variable in ddb and be set using sysctl. This adds the sysctl value ddb.tee_msgbuf = 0 by default. The functionality is especially added and aimed for developers who are not blessed with a serial console and wish to keep all their ddb output in the log. Specifying /l as a modifier to some selected commands will also put the output in the log but not all commands provide one nor has the same meaning for all commands. This feature could in the future also be implemented as an ddb command but that could lead to more bloat allthough maybe easier for non developpers to use when mailing their backtraces from kernel crashes.
This commit is contained in:
parent
1b492809a0
commit
22f1132820
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: ddb.4,v 1.78 2004/03/02 20:57:45 jdc Exp $
|
||||
.\" $NetBSD: ddb.4,v 1.79 2004/09/29 23:54:11 reinoud Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1997 - 2003 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
@ -80,6 +80,12 @@ To disable entering
|
||||
.Ic ddb
|
||||
upon kernel panic:
|
||||
.Cd options DDB_ONPANIC=0
|
||||
.Pp
|
||||
To enable teeing all
|
||||
.\" XXX: hack; .Nm automatically introduces newline in SYNOPSIS
|
||||
.Ic ddb
|
||||
output to the kernel msgbuf:
|
||||
.Cd options DDB_TEE_MSGBUF=1
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
is the in-kernel debugger.
|
||||
@ -1116,6 +1122,23 @@ will be initialized to off.
|
||||
Input and output radix.
|
||||
.It Va tabstops
|
||||
Tab stop width.
|
||||
.It Va tee_msgbuf
|
||||
If explictly set to non zero (zero is the default) all
|
||||
.Nm
|
||||
output will not only be displayed on screen but
|
||||
also be fed to the msgbuf.
|
||||
The default of the variable can be set using the kernel configuration option
|
||||
.D1 Cd options DDB_TEE_MSGBUF=1
|
||||
wich will initialise
|
||||
.Va tee_msgbuf
|
||||
to be 1.
|
||||
This option is especially handy for poor souls
|
||||
who don't have a serial console but want to recall
|
||||
.Nm
|
||||
output from a crash investigation.
|
||||
This option is more generic than the /l command modifier possible for
|
||||
selected commands as discussed above to log the output. Mixing both /l
|
||||
and this setting can give double loggings.
|
||||
.\" .It Va work Ns Sy xx
|
||||
.\" Temporary work variable.
|
||||
.\" .Sq Sy xx
|
||||
|
@ -1,4 +1,4 @@
|
||||
$NetBSD: TODO,v 1.14 2004/09/28 23:02:58 reinoud Exp $
|
||||
$NetBSD: TODO,v 1.15 2004/09/29 23:54:11 reinoud Exp $
|
||||
|
||||
In rough order.
|
||||
|
||||
@ -116,6 +116,6 @@ done Numbers starting with [a-f] should work, but symbols
|
||||
Unfortunately, in ILP32 mode, ddb will only display the low 32-bits
|
||||
of any expression, including registers...
|
||||
|
||||
WIP Add support for duplicating all output to the message buffer for
|
||||
done Add support for duplicating all ddb output to the message buffer for
|
||||
those unlucky souls that don't have a serial console.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: db_variables.c,v 1.31 2004/05/25 04:31:48 atatat Exp $ */
|
||||
/* $NetBSD: db_variables.c,v 1.32 2004/09/29 23:54:11 reinoud Exp $ */
|
||||
|
||||
/*
|
||||
* Mach Operating System
|
||||
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_variables.c,v 1.31 2004/05/25 04:31:48 atatat Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_variables.c,v 1.32 2004/09/29 23:54:11 reinoud Exp $");
|
||||
|
||||
#include "opt_ddbparam.h"
|
||||
|
||||
@ -65,6 +65,15 @@ int db_onpanic = DDB_ONPANIC;
|
||||
#endif
|
||||
int db_fromconsole = DDB_FROMCONSOLE;
|
||||
|
||||
/*
|
||||
* Output DDB output to the message buffer?
|
||||
*/
|
||||
#ifndef DDB_TEE_MSGBUF
|
||||
#define DDB_TEE_MSGBUF 0
|
||||
#endif
|
||||
int db_tee_msgbuf = DDB_TEE_MSGBUF;
|
||||
|
||||
|
||||
static int db_rw_internal_variable(const struct db_variable *, db_expr_t *,
|
||||
int);
|
||||
static int db_find_variable(const struct db_variable **);
|
||||
@ -78,6 +87,7 @@ const struct db_variable db_vars[] = {
|
||||
{ "lines", (void *)&db_max_line, db_rw_internal_variable },
|
||||
{ "onpanic", (void *)&db_onpanic, db_rw_internal_variable },
|
||||
{ "fromconsole", (void *)&db_fromconsole, db_rw_internal_variable },
|
||||
{ "tee_msgbuf", (void *)&db_tee_msgbuf, db_rw_internal_variable },
|
||||
};
|
||||
const struct db_variable * const db_evars = db_vars + sizeof(db_vars)/sizeof(db_vars[0]);
|
||||
|
||||
@ -150,6 +160,12 @@ SYSCTL_SETUP(sysctl_ddb_setup, "sysctl ddb subtree setup")
|
||||
"console"),
|
||||
NULL, 0, &db_fromconsole, 0,
|
||||
CTL_DDB, DDBCTL_FROMCONSOLE, CTL_EOL);
|
||||
sysctl_createv(clog, 0, NULL, NULL,
|
||||
CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
|
||||
CTLTYPE_INT, "tee_msgbuf",
|
||||
SYSCTL_DESCR("Whether to tee ddb output to the msgbuf"),
|
||||
NULL, 0, &db_tee_msgbuf, 0,
|
||||
CTL_DDB, CTL_CREATE, CTL_EOL);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ddbvar.h,v 1.6 2003/12/04 19:38:23 atatat Exp $ */
|
||||
/* $NetBSD: ddbvar.h,v 1.7 2004/09/29 23:54:11 reinoud Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
|
||||
@ -45,6 +45,7 @@
|
||||
|
||||
extern int db_onpanic;
|
||||
extern int db_fromconsole;
|
||||
extern int db_tee_msgbuf;
|
||||
|
||||
int read_symtab_from_file(struct proc *,struct vnode *,const char *);
|
||||
#endif /* !_DDBVAR_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: subr_prf.c,v 1.94 2004/03/23 13:22:04 junyoung Exp $ */
|
||||
/* $NetBSD: subr_prf.c,v 1.95 2004/09/29 23:54:11 reinoud Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1986, 1988, 1991, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.94 2004/03/23 13:22:04 junyoung Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.95 2004/09/29 23:54:11 reinoud Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_ipkdb.h"
|
||||
@ -545,6 +545,12 @@ db_printf(const char *fmt, ...)
|
||||
va_start(ap, fmt);
|
||||
kprintf(fmt, TODDB, NULL, NULL, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (db_tee_msgbuf) {
|
||||
va_start(ap, fmt);
|
||||
kprintf(fmt, TOLOG, NULL, NULL, ap);
|
||||
va_end(ap);
|
||||
};
|
||||
}
|
||||
|
||||
void
|
||||
@ -555,6 +561,8 @@ db_vprintf(fmt, ap)
|
||||
|
||||
/* No mutex needed; DDB pauses all processors. */
|
||||
kprintf(fmt, TODDB, NULL, NULL, ap);
|
||||
if (db_tee_msgbuf)
|
||||
kprintf(fmt, TOLOG, NULL, NULL, ap);
|
||||
}
|
||||
|
||||
#endif /* DDB */
|
||||
|
Loading…
Reference in New Issue
Block a user