https://git.reactos.org/?p=reactos.git;a=commitdiff;h=66dea86d68da1ec77934beb579df2a13417c7ff1

commit 66dea86d68da1ec77934beb579df2a13417c7ff1
Author:     Jérôme Gardou <[email protected]>
AuthorDate: Fri Jun 18 18:14:51 2021 +0200
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Tue Jun 29 11:49:20 2021 +0200

    [NTOS:KDBG] Use internal KdpDPrintf instead of DbgPrint
    
    DbgPrint is implemented through a breakpoint, and then KD tries to 
recursively
    lock its own spinlock. Call a lower level routine instead.
---
 ntoskrnl/kdbg/i386/i386-dis.c |  4 ++--
 ntoskrnl/kdbg/kdb_cli.c       | 31 ++++++++++++++++---------------
 ntoskrnl/kdbg/kdb_expr.c      | 38 +++++++++++++++++++-------------------
 ntoskrnl/kdbg/kdb_symbols.c   |  4 ++--
 4 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/ntoskrnl/kdbg/i386/i386-dis.c b/ntoskrnl/kdbg/i386/i386-dis.c
index f129d61e9b0..4b8a0d1ec3b 100644
--- a/ntoskrnl/kdbg/i386/i386-dis.c
+++ b/ntoskrnl/kdbg/i386/i386-dis.c
@@ -51,7 +51,7 @@ KdbpPrintDisasm(void* Ignored, const char* fmt, ...)
 
   va_start(ap, fmt);
   ret = vsprintf(buffer, fmt, ap);
-  DbgPrint("%s", buffer);
+  KdpDprintf("%s", buffer);
   va_end(ap);
   return(ret);
 }
@@ -80,7 +80,7 @@ KdbpPrintAddressInCode(unsigned int Addr, struct 
disassemble_info * Ignored)
 {
     if (!KdbSymPrintAddress((void*)Addr, NULL))
     {
-      DbgPrint("<%08x>", Addr);
+      KdpDprintf("<%08x>", Addr);
     }
 }
 
diff --git a/ntoskrnl/kdbg/kdb_cli.c b/ntoskrnl/kdbg/kdb_cli.c
index ac43b48c5e1..228bebffd4d 100644
--- a/ntoskrnl/kdbg/kdb_cli.c
+++ b/ntoskrnl/kdbg/kdb_cli.c
@@ -2710,6 +2710,7 @@ KdbpCmdHelp(
  * \note Doesn't correctly handle \\t and terminal escape sequences when 
calculating the
  *       number of lines required to print a single line from the Buffer in 
the terminal.
  *       Prints maximum 4096 chars, because of its buffer size.
+ *       Uses KdpDPrintf internally (NOT DbgPrint!). Callers must already hold 
the debugger lock.
  */
 VOID
 KdbpPrint(
@@ -2735,11 +2736,11 @@ KdbpPrint(
     /* Initialize the terminal */
     if (!TerminalInitialized)
     {
-        DbgPrint("\x1b[7h");      /* Enable linewrap */
+        KdpDprintf("\x1b[7h");      /* Enable linewrap */
 
         /* Query terminal type */
         /*DbgPrint("\x1b[Z");*/
-        DbgPrint("\x05");
+        KdpDprintf("\x05");
 
         TerminalInitialized = TRUE;
         Length = 0;
@@ -2770,7 +2771,7 @@ KdbpPrint(
             /* Try to query number of rows from terminal. A reply looks like 
"\x1b[8;24;80t" */
             TerminalReportsSize = FALSE;
             KeStallExecutionProcessor(100000);
-            DbgPrint("\x1b[18t");
+            KdpDprintf("\x1b[18t");
             c = KdbpTryGetCharSerial(5000);
 
             if (c == KEY_ESC)
@@ -2855,9 +2856,9 @@ KdbpPrint(
             KdbRepeatLastCommand = FALSE;
 
             if (KdbNumberOfColsPrinted > 0)
-                DbgPrint("\n");
+                KdpDprintf("\n");
 
-            DbgPrint("--- Press q to abort, any other key to continue ---");
+            KdpDprintf("--- Press q to abort, any other key to continue ---");
             RowsPrintedByTerminal++; /* added by Mna. */
 
             if (KdbDebugState & KD_DEBUG_KDSERIAL)
@@ -2876,7 +2877,7 @@ KdbpPrint(
                     c = KdbpTryGetCharKeyboard(&ScanCode, 5);
             }
 
-            DbgPrint("\n");
+            KdpDprintf("\n");
             if (c == 'q')
             {
                 KdbOutputAborted = TRUE;
@@ -2917,7 +2918,7 @@ KdbpPrint(
             }
         }
 
-        DbgPrint("%s", p);
+        KdpDprintf("%s", p);
 
         if (c != '\0')
             p[i + 1] = c;
@@ -3052,11 +3053,11 @@ KdbpPager(
     /* Initialize the terminal */
     if (!TerminalInitialized)
     {
-        DbgPrint("\x1b[7h");      /* Enable linewrap */
+        KdpDprintf("\x1b[7h");      /* Enable linewrap */
 
         /* Query terminal type */
         /*DbgPrint("\x1b[Z");*/
-        DbgPrint("\x05");
+        KdpDprintf("\x05");
 
         TerminalInitialized = TRUE;
         Length = 0;
@@ -3087,7 +3088,7 @@ KdbpPager(
             /* Try to query number of rows from terminal. A reply looks like 
"\x1b[8;24;80t" */
             TerminalReportsSize = FALSE;
             KeStallExecutionProcessor(100000);
-            DbgPrint("\x1b[18t");
+            KdpDprintf("\x1b[18t");
             c = KdbpTryGetCharSerial(5000);
 
             if (c == KEY_ESC)
@@ -3148,7 +3149,7 @@ KdbpPager(
     {
         if ( p > Buffer+BufLength)
         {
-          DbgPrint("Dmesg: error, p > Buffer+BufLength,d=%d", p - 
(Buffer+BufLength));
+          KdpDprintf("Dmesg: error, p > Buffer+BufLength,d=%d", p - 
(Buffer+BufLength));
           return;
         }
         i = strcspn(p, "\n");
@@ -3178,9 +3179,9 @@ KdbpPager(
             KdbRepeatLastCommand = FALSE;
 
             if (KdbNumberOfColsPrinted > 0)
-                DbgPrint("\n");
+                KdpDprintf("\n");
 
-            DbgPrint("--- Press q to abort, e/End,h/Home,u/PgUp, other 
key/PgDn ---");
+            KdpDprintf("--- Press q to abort, e/End,h/Home,u/PgUp, other 
key/PgDn ---");
             RowsPrintedByTerminal++;
 
             if (KdbDebugState & KD_DEBUG_KDSERIAL)
@@ -3200,7 +3201,7 @@ KdbpPager(
             }
 
             //DbgPrint("\n"); //Consize version: don't show pressed key
-            DbgPrint(" '%c'/scan=%04x\n", c, ScanCode); // Shows pressed key
+            KdpDprintf(" '%c'/scan=%04x\n", c, ScanCode); // Shows pressed key
 
             if (c == 'q')
             {
@@ -3264,7 +3265,7 @@ KdbpPager(
         }
 
         // The main printing of the current line:
-        DbgPrint(p);
+        KdpDprintf(p);
 
         // restore not null char with saved:
         if (c != '\0')
diff --git a/ntoskrnl/kdbg/kdb_expr.c b/ntoskrnl/kdbg/kdb_expr.c
index 69a57d8e8ae..348d71286c3 100644
--- a/ntoskrnl/kdbg/kdb_expr.c
+++ b/ntoskrnl/kdbg/kdb_expr.c
@@ -253,7 +253,7 @@ RpnpDumpStack(
     ULONG ul;
 
     ASSERT(Stack);
-    DbgPrint("\nStack size: %ld\n", Stack->Sp);
+    KdpDprintf("\nStack size: %ld\n", Stack->Sp);
 
     for (ul = 0; ul < Stack->Sp; ul++)
     {
@@ -261,60 +261,60 @@ RpnpDumpStack(
         switch (Op->Type)
         {
             case RpnOpNop:
-                DbgPrint("NOP,");
+                KdpDprintf("NOP,");
                 break;
 
             case RpnOpImmediate:
-                DbgPrint("0x%I64x,", Op->Data.Immediate);
+                KdpDprintf("0x%I64x,", Op->Data.Immediate);
                 break;
 
             case RpnOpBinaryOperator:
                 if (Op->Data.BinaryOperator == RpnBinaryOperatorAdd)
-                    DbgPrint("+,");
+                    KdpDprintf("+,");
                 else if (Op->Data.BinaryOperator == RpnBinaryOperatorSub)
-                    DbgPrint("-,");
+                    KdpDprintf("-,");
                 else if (Op->Data.BinaryOperator == RpnBinaryOperatorMul)
-                    DbgPrint("*,");
+                    KdpDprintf("*,");
                 else if (Op->Data.BinaryOperator == RpnBinaryOperatorDiv)
-                    DbgPrint("/,");
+                    KdpDprintf("/,");
                 else if (Op->Data.BinaryOperator == RpnBinaryOperatorMod)
-                    DbgPrint("%%,");
+                    KdpDprintf("%%,");
                 else if (Op->Data.BinaryOperator == RpnBinaryOperatorEquals)
-                    DbgPrint("==,");
+                    KdpDprintf("==,");
                 else if (Op->Data.BinaryOperator == RpnBinaryOperatorNotEquals)
-                    DbgPrint("!=,");
+                    KdpDprintf("!=,");
                 else if (Op->Data.BinaryOperator == RpnBinaryOperatorLessThan)
-                    DbgPrint("<,");
+                    KdpDprintf("<,");
                 else if (Op->Data.BinaryOperator == 
RpnBinaryOperatorLessThanOrEquals)
-                    DbgPrint("<=,");
+                    KdpDprintf("<=,");
                 else if (Op->Data.BinaryOperator == 
RpnBinaryOperatorGreaterThan)
-                    DbgPrint(">,");
+                    KdpDprintf(">,");
                 else if (Op->Data.BinaryOperator == 
RpnBinaryOperatorGreaterThanOrEquals)
-                    DbgPrint(">=,");
+                    KdpDprintf(">=,");
                 else
-                    DbgPrint("UNKNOWN OP,");
+                    KdpDprintf("UNKNOWN OP,");
 
                 break;
 
             case RpnOpRegister:
-                DbgPrint("%s,", RegisterToTrapFrame[Op->Data.Register].Name);
+                KdpDprintf("%s,", RegisterToTrapFrame[Op->Data.Register].Name);
                 break;
 
             case RpnOpDereference:
-                DbgPrint("[%s],",
+                KdpDprintf("[%s],",
                     (Op->Data.DerefMemorySize == 1) ? ("byte") :
                     ((Op->Data.DerefMemorySize == 2) ? ("word") :
                     ((Op->Data.DerefMemorySize == 4) ? ("dword") : 
("qword"))));
                 break;
 
             default:
-                DbgPrint("\nUnsupported Type: %d\n", Op->Type);
+                KdpDprintf("\nUnsupported Type: %d\n", Op->Type);
                 ul = Stack->Sp;
                 break;
         }
     }
 
-    DbgPrint("\n");
+    KdpDprintf("\n");
 }
 
 /*!\brief Clears the given RPN stack.
diff --git a/ntoskrnl/kdbg/kdb_symbols.c b/ntoskrnl/kdbg/kdb_symbols.c
index 299c93bd213..e3673e8db6d 100644
--- a/ntoskrnl/kdbg/kdb_symbols.c
+++ b/ntoskrnl/kdbg/kdb_symbols.c
@@ -180,12 +180,12 @@ KdbSymPrintAddress(
                                          FunctionName);
     if (NT_SUCCESS(Status))
     {
-        DbgPrint("<%s:%x (%s:%d (%s))>",
+        KdpDprintf("<%s:%x (%s:%d (%s))>",
             ModuleNameAnsi, RelativeAddress, FileName, LineNumber, 
FunctionName);
     }
     else
     {
-        DbgPrint("<%s:%x>", ModuleNameAnsi, RelativeAddress);
+        KdpDprintf("<%s:%x>", ModuleNameAnsi, RelativeAddress);
     }
 
     return TRUE;

Reply via email to