From owner-freebsd-arch@FreeBSD.ORG Sun May 18 06:53:04 2003 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6007137B401 for ; Sun, 18 May 2003 06:53:04 -0700 (PDT) Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by mx1.FreeBSD.org (Postfix) with SMTP id 1885A43FBD for ; Sun, 18 May 2003 06:53:03 -0700 (PDT) (envelope-from iedowse@maths.tcd.ie) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 18 May 2003 14:53:02 +0100 (BST) To: Nate Lawson In-Reply-To: Your message of "Sat, 17 May 2003 23:04:54 PDT." <20030517230020.B87908@root.org> Date: Sun, 18 May 2003 14:53:01 +0100 From: Ian Dowse Message-ID: <200305181453.aa61367@salmon.maths.tcd.ie> cc: arch@freebsd.org Subject: Re: backtrace() not printing to kernel log X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 May 2003 13:53:04 -0000 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 } /*