dprintf: Print to stdout as well as serial ports
authorMatt Fleming <matt.fleming@linux.intel.com>
Tue, 8 Mar 2011 13:47:32 +0000 (13:47 +0000)
committerMatt Fleming <matt.fleming@linux.intel.com>
Tue, 8 Mar 2011 19:08:40 +0000 (19:08 +0000)
The intention here is to make dprintf the de-facto function for
printing all debugging information. As such, it's useful to print to
the serial ports and stdout so that developers are not required to
hook up a serial port to view output.

Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
com32/lib/vdprintf.c

index d74f278..76da012 100644 (file)
@@ -49,13 +49,13 @@ static void debug_putc(char c)
 
 void vdprintf(const char *format, va_list ap)
 {
-    int rv;
+    int rv, _rv;
     char buffer[BUFFER_SIZE];
     char *p;
     static bool debug_init = false;
     static bool debug_ok   = false;
 
-    rv = vsnprintf(buffer, BUFFER_SIZE, format, ap);
+    _rv = rv = vsnprintf(buffer, BUFFER_SIZE, format, ap);
 
     if (rv < 0)
        return;
@@ -113,4 +113,6 @@ void vdprintf(const char *format, va_list ap)
     p = buffer;
     while (rv--)
        debug_putc(*p++);
+
+    _fwrite(buffer, _rv, stdout);
 }