From c079b3068c86d9c0051a4057de06efaf341ee510 Mon Sep 17 00:00:00 2001 From: njl Date: Wed, 28 Jan 2004 06:51:18 +0000 Subject: 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 --- sys/ddb/db_output.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'sys/ddb') 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 #include #include +#include +#include #include @@ -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. -- cgit v1.1