commit ac2cdfadf44c Author: Conrad Meyer Date: Thu Apr 9 17:24:36 2020 +0000 In ddb, have printf(9) respect db pager, interrupt This shows up especially for 'show mount foo', as the db_show routine invokes vn_printf(), which uses printf() instead of db_printf() (it is also used at runtime). This is a long-standing nuisance as the vnode lists for a mount may be extremely long. The branch for 'kdb_active' is already present, so this is probably not a performance pessimization of printf(9) outside of ddb mode. diff --git a/sys/ddb/db_output.c b/sys/ddb/db_output.c index bfc240267dee..89f9c46f8b96 100644 --- a/sys/ddb/db_output.c +++ b/sys/ddb/db_output.c @@ -83,7 +83,6 @@ 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_putc(int c); static void db_puts(const char *str); static void db_putchar(int c, void *arg); static void db_pager(void); @@ -153,7 +157,7 @@ db_putchar(int c, void *arg) } } -static void +void db_putc(int c) { @@ -161,7 +167,11 @@ db_putc(int c) * If not in the debugger or the user requests it, output data to * both the console and the message buffer. */ - if (!kdb_active || ddb_use_printf) { + /* + * This is pointless in kdb_active, as putchar will bypass msgbuf and + * only cnputc(). + */ + if (!kdb_active && ddb_use_printf) { printf("%c", c); if (!kdb_active) return; diff --git a/sys/ddb/db_output.h b/sys/ddb/db_output.h index e64608bd66ad..713dd7f38f4a 100644 --- a/sys/ddb/db_output.h +++ b/sys/ddb/db_output.h @@ -46,4 +46,6 @@ void db_end_line(int); void db_force_whitespace(void); int db_print_position(void); +void db_putc(int c); + #endif /* !_DDB_DB_OUTPUT_H_ */ diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index ed5abb68b8c0..6b28dcb355fd 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$"); #ifdef DDB #include +#include #endif /* @@ -562,8 +565,13 @@ putchar(int c, void *arg) /* Don't use the tty code after a panic or while in ddb. */ if (kdb_active) { - if (c != '\0') + if (c != '\0') { +#ifdef DDB + db_putc(c); +#else cnputc(c); +#endif + } return; }