summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2011-04-03 16:46:20 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2011-04-03 16:46:20 +0000
commitb6940314d6366671b87422f51857ee576975d151 (patch)
treed7f8d83c895522ea3bb23cb0168d4a30f0f5544e /sys
parent7c7725bd092134301df528c00b4a45f5c652622e (diff)
Allow kernel printfs to go to console if in ddb instead of being redirected
to xconsole. ok deraadt@ guenther@
Diffstat (limited to 'sys')
-rw-r--r--sys/ddb/db_trap.c5
-rw-r--r--sys/ddb/db_var.h4
-rw-r--r--sys/kern/subr_prf.c17
3 files changed, 20 insertions, 6 deletions
diff --git a/sys/ddb/db_trap.c b/sys/ddb/db_trap.c
index 96eeb2ab3fc..01b15fe7519 100644
--- a/sys/ddb/db_trap.c
+++ b/sys/ddb/db_trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_trap.c,v 1.15 2010/11/27 19:57:23 miod Exp $ */
+/* $OpenBSD: db_trap.c,v 1.16 2011/04/03 16:46:19 drahn Exp $ */
/* $NetBSD: db_trap.c,v 1.9 1996/02/05 01:57:18 christos Exp $ */
/*
@@ -48,6 +48,7 @@
#include <ddb/db_sym.h>
#include <ddb/db_extern.h>
#include <ddb/db_interface.h>
+#include <ddb/db_var.h>
void
db_trap(int type, int code)
@@ -55,6 +56,7 @@ db_trap(int type, int code)
boolean_t bkpt;
boolean_t watchpt;
+ db_is_active = 1;
bkpt = IS_BREAKPOINT_TRAP(type, code);
watchpt = IS_WATCHPOINT_TRAP(type, code);
@@ -97,4 +99,5 @@ db_trap(int type, int code)
}
db_restart_at_pc(DDB_REGS, watchpt);
+ db_is_active = 0;
}
diff --git a/sys/ddb/db_var.h b/sys/ddb/db_var.h
index c4a555df117..b9aef32aa10 100644
--- a/sys/ddb/db_var.h
+++ b/sys/ddb/db_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_var.h,v 1.10 2008/11/08 01:14:51 mpf Exp $ */
+/* $OpenBSD: db_var.h,v 1.11 2011/04/03 16:46:19 drahn Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff. All rights reserved.
@@ -65,10 +65,10 @@ extern int db_max_line;
extern int db_panic;
extern int db_console;
extern int db_log;
+extern int db_is_active;
int ddb_sysctl(int *, u_int, void *, size_t *, void *, size_t,
struct proc *);
#endif
#endif /* _DDB_DB_VAR_H_ */
-
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index 30e7dcef6be..7459266b1b3 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_prf.c,v 1.75 2010/07/26 01:56:27 guenther Exp $ */
+/* $OpenBSD: subr_prf.c,v 1.76 2011/04/03 16:46:19 drahn Exp $ */
/* $NetBSD: subr_prf.c,v 1.45 1997/10/24 18:14:25 chuck Exp $ */
/*-
@@ -123,6 +123,11 @@ int db_console = 1;
#else
int db_console = 0;
#endif
+
+/*
+ * flag to indicate if we are currently in ddb (on some processor)
+ */
+int db_is_active;
#endif
/*
@@ -324,10 +329,16 @@ void
kputchar(int c, int flags, struct tty *tp)
{
extern int msgbufmapped;
+ int ddb_active = 0;
+
+#ifdef DDB
+ ddb_active = db_is_active;
+#endif
if (panicstr)
constty = NULL;
- if ((flags & TOCONS) && tp == NULL && constty) {
+
+ if ((flags & TOCONS) && tp == NULL && constty && !ddb_active) {
tp = constty;
flags |= TOTTY;
}
@@ -337,7 +348,7 @@ kputchar(int c, int flags, struct tty *tp)
if ((flags & TOLOG) &&
c != '\0' && c != '\r' && c != 0177 && msgbufmapped)
msgbuf_putchar(c);
- if ((flags & TOCONS) && constty == NULL && c != '\0')
+ if ((flags & TOCONS) && (constty == NULL || ddb_active) && c != '\0')
(*v_putc)(c);
#ifdef DDB
if (flags & TODDB)