reactos/ntoskrnl/dbg
diff -u -r1.20 -r1.21
--- print.c 21 Aug 2004 15:34:32 -0000 1.20
+++ print.c 10 Dec 2004 14:58:25 -0000 1.21
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: print.c,v 1.20 2004/08/21 15:34:32 tamlin Exp $
+/* $Id: print.c,v 1.21 2004/12/10 14:58:25 blight Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -61,6 +61,13 @@
ANSI_STRING DebugString;
CHAR Buffer[1024];
va_list ap;
+#ifdef SERIALIZE_DBGPRINT
+ LONG MyTableIndex;
+ static LONG Lock = 0;
+ static LONG TableWriteIndex = 0, TableReadIndex = 0;
+ static PCHAR MessageTable[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+# define MESSAGETABLE_SIZE (sizeof (MessageTable) / sizeof (MessageTable[0]))
+#endif /* SERIALIZE_DBGPRINT */
/* init ansi string */
DebugString.Buffer = Buffer;
@@ -70,7 +77,62 @@
DebugString.Length = _vsnprintf (Buffer, sizeof( Buffer ), Format, ap);
va_end (ap);
- KdpPrintString (&DebugString);
+#ifdef SERIALIZE_DBGPRINT
+ /* check if we are already running */
+ if (InterlockedCompareExchange(&Lock, 1, 0) == 1)
+ {
+ PCHAR Dup;
+ Dup = ExAllocatePool(NonPagedPool, DebugString.Length + 1);
+ memcpy(Dup, DebugString.Buffer, DebugString.Length);
+ Dup[DebugString.Length] = '\0';
+
+ MyTableIndex = InterlockedIncrement(&TableWriteIndex) - 1;
+ InterlockedCompareExchange(&TableWriteIndex, 0, MESSAGETABLE_SIZE);
+ MyTableIndex %= MESSAGETABLE_SIZE;
+
+ if (MessageTable[MyTableIndex] != NULL) /* table is full */
+ {
+ DebugString.Buffer = "CRITICAL ERROR: DbgPrint Table is FULL!";
+ DebugString.Length = 39;
+ KdpPrintString(&DebugString);
+ for (;;);
+ }
+ else
+ {
+ /*DebugString.Buffer = "���";
+ DebugString.Length = 3;
+ KdpPrintString(&DebugString);*/
+ MessageTable[MyTableIndex] = Dup;
+ }
+ }
+ else
+ {
+#endif /* SERIALIZE_DBGPRINT */
+ KdpPrintString (&DebugString);
+#ifdef SERIALIZE_DBGPRINT
+ MyTableIndex = TableReadIndex;
+ while (MessageTable[MyTableIndex] != NULL)
+ {
+ /*DebugString.Buffer = "$$$";
+ DebugString.Length = 3;
+ KdpPrintString(&DebugString);*/
+
+ DebugString.Buffer = MessageTable[MyTableIndex];
+ MessageTable[MyTableIndex] = NULL;
+ DebugString.Length = strlen(DebugString.Buffer);
+ DebugString.MaximumLength = DebugString.Length + 1;
+
+ KdpPrintString(&DebugString);
+ ExFreePool(DebugString.Buffer);
+
+ MyTableIndex = InterlockedIncrement(&TableReadIndex);
+ InterlockedCompareExchange(&TableReadIndex, 0, MESSAGETABLE_SIZE);
+ MyTableIndex %= MESSAGETABLE_SIZE;
+ }
+ InterlockedDecrement(&Lock);
+ }
+# undef MESSAGETABLE_SIZE
+#endif /* SERIALIZE_DBGPRINT */
return (ULONG)DebugString.Length;
}
reactos/ntoskrnl/include
diff -u -r1.2 -r1.3
--- config.h 28 Nov 2004 22:07:19 -0000 1.2
+++ config.h 10 Dec 2004 14:58:26 -0000 1.3
@@ -1,6 +1,20 @@
#ifndef __INCLUDE_NTOSKRNL_CONFIG_H
#define __INCLUDE_NTOSKRNL_CONFIG_H
+/********** dbg/print.c **********/
+
+/* Enable serialization of debug messages printed with DbgPrint
+ *
+ * If this is enabled DbgPrint will queue messages if another thread is already
+ * printing a message, and immediately returns. The other thread will print
+ * queued messages before it returns.
+ * It could happen that some messages are lost if the processor is halted before
+ * the message queue was flushed.
+ */
+#undef SERIALIZE_DBGPRINT
+
+/********** mm/ppool.c **********/
+
/* Enable strict checking of the nonpaged pool on every allocation */
#undef ENABLE_VALIDATE_POOL