diff options
author | njl <njl@FreeBSD.org> | 2004-01-28 06:51:18 +0000 |
---|---|---|
committer | njl <njl@FreeBSD.org> | 2004-01-28 06:51:18 +0000 |
commit | c079b3068c86d9c0051a4057de06efaf341ee510 (patch) | |
tree | 8cfed3d51b8320d581bbf1a0b43910937b94bc4d | |
parent | 034e0282493413a54d49da685e44d8714951f548 (diff) | |
download | FreeBSD-src-c079b3068c86d9c0051a4057de06efaf341ee510.zip FreeBSD-src-c079b3068c86d9c0051a4057de06efaf341ee510.tar.gz |
If not in the debugger or if the user requests it with the
debug.ddb_use_printf sysctl, output kernel debugger data to both the
console and kernel message buffer via printf. This fixes the case where
backtrace() went directly to the console and should help debugging greatly.
Thanks to Ian Dowse for the work, minor edits or any bugs are by myself.
Submitted by: iedowse
-rw-r--r-- | sys/ddb/db_output.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/sys/ddb/db_output.c b/sys/ddb/db_output.c index 2fa8554..464d9162 100644 --- a/sys/ddb/db_output.c +++ b/sys/ddb/db_output.c @@ -38,6 +38,8 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> #include <sys/cons.h> +#include <sys/kernel.h> +#include <sys/sysctl.h> #include <machine/stdarg.h> @@ -66,8 +68,11 @@ static int db_newlines; /* # lines this page */ static int db_maxlines = -1; /* max lines per page */ static db_page_calloutfcn_t *db_page_callout = NULL; static void *db_page_callout_arg = NULL; +static int ddb_use_printf = 0; +SYSCTL_INT(_debug, OID_AUTO, ddb_use_printf, CTLFLAG_RW, &ddb_use_printf, 0, + "use printf for all ddb output"); -static void db_putchar(int c, void *arg); +static void db_putchar(int c, void *arg); /* * Force pending whitespace. @@ -103,6 +108,27 @@ db_putchar(c, arg) void * arg; { + /* + * If not in the debugger or the user requests it, output data to + * both the console and the message buffer. + */ + if (!db_active || ddb_use_printf) { + printf("%c", c); + if (!db_active) + return; + if (c == '\r' || c == '\n') + db_check_interrupt(); + if (c == '\n' && db_maxlines > 0 && db_page_callout != NULL) { + db_newlines++; + if (db_newlines >= db_maxlines) { + db_maxlines = -1; + db_page_callout(db_page_callout_arg); + } + } + return; + } + + /* Otherwise, output data directly to the console. */ if (c > ' ' && c <= '~') { /* * Printing character. |