Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 May 2003 14:53:01 +0100
From:      Ian Dowse <iedowse@maths.tcd.ie>
To:        Nate Lawson <nate@root.org>
Cc:        arch@freebsd.org
Subject:   Re: backtrace() not printing to kernel log 
Message-ID:  <200305181453.aa61367@salmon.maths.tcd.ie>
In-Reply-To: Your message of "Sat, 17 May 2003 23:04:54 PDT." <20030517230020.B87908@root.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <20030517230020.B87908@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
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200305181453.aa61367>