backtrace() and the console log (was Re: cvs commit: src/sys/alpha...)

Ian Dowse iedowse at maths.tcd.ie
Tue Jan 20 17:48:24 PST 2004


In message <20040120144505.ccsc4kog4c88sgww at www.sweetdreamsracing.biz>, Kenneth
 Culver writes:
>Quoting Nate Lawson <nate at root.org>:
>> * Fix backtrace() so the output goes to the console log.  Right now, we
>> get output that needs to be hand-transcribed or use a serial console.
>
>This is also very useful for when FreeBSD crashes when X is running. If X is
>running, the only option is a serial console, as you can't see the crash to
>transcribe it otherwise, and most people don't have the spare computer to use
>as a serial console.

I've been using the following patch for a while to get backtrace()
to output to the kernel message buffer. Sending all ddb output via
printf might be undesirable for some cases, but I guess having it
configurable with a `debug.ddb_use_printf' sysctl that defaults to
the old behaviour would be ok?

Ian


Index: db_output.c
===================================================================
RCS file: /dump/FreeBSD-CVS/src/sys/ddb/db_output.c,v
retrieving revision 1.29
diff -u -r1.29 db_output.c
--- db_output.c	31 Jul 2003 17:27:52 -0000	1.29
+++ db_output.c	7 Sep 2003 18:50:30 -0000
@@ -103,6 +103,18 @@
 	void *	arg;
 {
 
+#if 1
+	printf("%c", c);
+	if (c == '\r' || c == '\n')
+	    db_check_interrupt();
+	if (c == '\n' && db_maxlines > 0 && db_page_callout != NULL) {
+	    db_newlines++;
+	    if (db_newlines >= db_maxlines) {
+		db_maxlines = -1;
+		db_page_callout(db_page_callout_arg);
+	    }
+	}
+#else
 	if (c > ' ' && c <= '~') {
 	    /*
 	     * Printing character.
@@ -148,6 +160,7 @@
 	    cnputc(c);
 	}
 	/* other characters are assumed non-printing */
+#endif
 }
 
 /*


More information about the cvs-src mailing list