backtrace() not printing to kernel log

Ian Dowse iedowse at maths.tcd.ie
Sun May 18 06:53:04 PDT 2003


In message <20030517230020.B87908 at root.org>, Nate Lawson writes:
>I've found an annoyance when tracking down a new LoR.  Since
>db_print_backtrace() uses db_printf() instead of printf(), the backtrace
>doesn't make it to the kernel buffer but is printed directly to the
>console.

Below is the simple workaround patch I use. However, this introduces
many further problems, because printf is not safe to use at arbitrary
times due to the fact that it can call into the tty code, and has
other reentrancy problems. You can probably find more details in
mails from bde in the archives.

Mainly based on Bruce's comments and suggestions, I have been putting
together a patch that tries to improve the usability of printf by
making the message buffer code more reentrant, and using another
message buffer for passing text to the tty subsystem via a timeout
handler. The patch is at an early stage and not very pleasant in
a few areas, but if you're interested, see:

	http://www.maths.tcd.ie/~iedowse/FreeBSD/msgbuf.diff

Ian

Index: db_output.c
===================================================================
RCS file: /dump/FreeBSD-CVS/src/sys/ddb/db_output.c,v
retrieving revision 1.27
diff -u -r1.27 db_output.c
--- db_output.c	20 Mar 2002 05:14:28 -0000	1.27
+++ db_output.c	12 Mar 2003 22:09:28 -0000
@@ -98,6 +98,11 @@
 	int	c;		/* character to output */
 	void *	arg;
 {
+#if 1
+	printf("%c", c);
+	if (c == '\r' || c == '\n')
+	    db_check_interrupt();
+#else
 	if (c > ' ' && c <= '~') {
 	    /*
 	     * Printing character.
@@ -136,6 +141,7 @@
 	    cnputc(c);
 	}
 	/* other characters are assumed non-printing */
+#endif
 }
 
 /*



More information about the freebsd-arch mailing list