win-pvdrivers

changeset 936:373c6b36220c

change dbgprint to only print timestamps following a newline
author James Harper <james.harper@bendigoit.com.au>
date Mon Jun 20 23:31:04 2011 +1000 (2011-06-20)
parents 99023e044544
children a631c9e93095
files xenpci/xenpci_dbgprint.c
line diff
     1.1 --- a/xenpci/xenpci_dbgprint.c	Mon Jun 20 23:16:14 2011 +1000
     1.2 +++ b/xenpci/xenpci_dbgprint.c	Mon Jun 20 23:31:04 2011 +1000
     1.3 @@ -65,6 +65,8 @@ extern PVOID Int2dHandlerOld;
     1.4  static BOOLEAN debug_port_enabled = FALSE;
     1.5  static volatile LONG debug_print_lock = 0;
     1.6  
     1.7 +static BOOLEAN last_newline = TRUE;
     1.8 +
     1.9  /* This appears to be called with interrupts disabled already, so no need to go to HIGH_LEVEL or anything like that */
    1.10  static void XenDbgPrint(PCHAR string, ULONG length)
    1.11  {
    1.12 @@ -75,19 +77,25 @@ static void XenDbgPrint(PCHAR string, UL
    1.13  
    1.14    while(InterlockedCompareExchange(&debug_print_lock, 1, 0) == 1)
    1.15      KeStallExecutionProcessor(1);
    1.16 -  
    1.17 -  KeQuerySystemTime(&current_time);
    1.18 -  current_time.QuadPart /= 10000; /* convert to ms */
    1.19 -  for (j = 1000000000000000000L; j >= 1; j /= 10)
    1.20 -    if (current_time.QuadPart / j)
    1.21 -      break;
    1.22 -  for (; j >= 1; j /= 10)
    1.23 -    WRITE_PORT_UCHAR(XEN_IOPORT_LOG, '0' + (UCHAR)((current_time.QuadPart / j) % 10));
    1.24 -  WRITE_PORT_UCHAR(XEN_IOPORT_LOG, ':');
    1.25 -  WRITE_PORT_UCHAR(XEN_IOPORT_LOG, ' ');
    1.26 -      
    1.27 +
    1.28    for (i = 0; i < length; i++)
    1.29 +  {
    1.30 +    /* only write a timestamp if the last character was a newline */
    1.31 +    if (last_newline)
    1.32 +    {
    1.33 +      KeQuerySystemTime(&current_time);
    1.34 +      current_time.QuadPart /= 10000; /* convert to ms */
    1.35 +      for (j = 1000000000000000000L; j >= 1; j /= 10)
    1.36 +        if (current_time.QuadPart / j)
    1.37 +          break;
    1.38 +      for (; j >= 1; j /= 10)
    1.39 +        WRITE_PORT_UCHAR(XEN_IOPORT_LOG, '0' + (UCHAR)((current_time.QuadPart / j) % 10));
    1.40 +      WRITE_PORT_UCHAR(XEN_IOPORT_LOG, ':');
    1.41 +      WRITE_PORT_UCHAR(XEN_IOPORT_LOG, ' ');
    1.42 +    }
    1.43      WRITE_PORT_UCHAR(XEN_IOPORT_LOG, string[i]);
    1.44 +    last_newline = (string[i] == '\n');
    1.45 +  }
    1.46    /* release the lock */
    1.47    InterlockedExchange(&debug_print_lock, 0);
    1.48  }