[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.
This commit is contained in:
Jérôme Gardou 2021-06-18 18:14:51 +02:00 committed by Jérôme Gardou
parent 813d9cd2cc
commit 66dea86d68
4 changed files with 39 additions and 38 deletions

View file

@ -51,7 +51,7 @@ KdbpPrintDisasm(void* Ignored, const char* fmt, ...)
va_start(ap, fmt); va_start(ap, fmt);
ret = vsprintf(buffer, fmt, ap); ret = vsprintf(buffer, fmt, ap);
DbgPrint("%s", buffer); KdpDprintf("%s", buffer);
va_end(ap); va_end(ap);
return(ret); return(ret);
} }
@ -80,7 +80,7 @@ KdbpPrintAddressInCode(unsigned int Addr, struct disassemble_info * Ignored)
{ {
if (!KdbSymPrintAddress((void*)Addr, NULL)) if (!KdbSymPrintAddress((void*)Addr, NULL))
{ {
DbgPrint("<%08x>", Addr); KdpDprintf("<%08x>", Addr);
} }
} }

View file

@ -2710,6 +2710,7 @@ KdbpCmdHelp(
* \note Doesn't correctly handle \\t and terminal escape sequences when calculating the * \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. * number of lines required to print a single line from the Buffer in the terminal.
* Prints maximum 4096 chars, because of its buffer size. * Prints maximum 4096 chars, because of its buffer size.
* Uses KdpDPrintf internally (NOT DbgPrint!). Callers must already hold the debugger lock.
*/ */
VOID VOID
KdbpPrint( KdbpPrint(
@ -2735,11 +2736,11 @@ KdbpPrint(
/* Initialize the terminal */ /* Initialize the terminal */
if (!TerminalInitialized) if (!TerminalInitialized)
{ {
DbgPrint("\x1b[7h"); /* Enable linewrap */ KdpDprintf("\x1b[7h"); /* Enable linewrap */
/* Query terminal type */ /* Query terminal type */
/*DbgPrint("\x1b[Z");*/ /*DbgPrint("\x1b[Z");*/
DbgPrint("\x05"); KdpDprintf("\x05");
TerminalInitialized = TRUE; TerminalInitialized = TRUE;
Length = 0; Length = 0;
@ -2770,7 +2771,7 @@ KdbpPrint(
/* Try to query number of rows from terminal. A reply looks like "\x1b[8;24;80t" */ /* Try to query number of rows from terminal. A reply looks like "\x1b[8;24;80t" */
TerminalReportsSize = FALSE; TerminalReportsSize = FALSE;
KeStallExecutionProcessor(100000); KeStallExecutionProcessor(100000);
DbgPrint("\x1b[18t"); KdpDprintf("\x1b[18t");
c = KdbpTryGetCharSerial(5000); c = KdbpTryGetCharSerial(5000);
if (c == KEY_ESC) if (c == KEY_ESC)
@ -2855,9 +2856,9 @@ KdbpPrint(
KdbRepeatLastCommand = FALSE; KdbRepeatLastCommand = FALSE;
if (KdbNumberOfColsPrinted > 0) 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. */ RowsPrintedByTerminal++; /* added by Mna. */
if (KdbDebugState & KD_DEBUG_KDSERIAL) if (KdbDebugState & KD_DEBUG_KDSERIAL)
@ -2876,7 +2877,7 @@ KdbpPrint(
c = KdbpTryGetCharKeyboard(&ScanCode, 5); c = KdbpTryGetCharKeyboard(&ScanCode, 5);
} }
DbgPrint("\n"); KdpDprintf("\n");
if (c == 'q') if (c == 'q')
{ {
KdbOutputAborted = TRUE; KdbOutputAborted = TRUE;
@ -2917,7 +2918,7 @@ KdbpPrint(
} }
} }
DbgPrint("%s", p); KdpDprintf("%s", p);
if (c != '\0') if (c != '\0')
p[i + 1] = c; p[i + 1] = c;
@ -3052,11 +3053,11 @@ KdbpPager(
/* Initialize the terminal */ /* Initialize the terminal */
if (!TerminalInitialized) if (!TerminalInitialized)
{ {
DbgPrint("\x1b[7h"); /* Enable linewrap */ KdpDprintf("\x1b[7h"); /* Enable linewrap */
/* Query terminal type */ /* Query terminal type */
/*DbgPrint("\x1b[Z");*/ /*DbgPrint("\x1b[Z");*/
DbgPrint("\x05"); KdpDprintf("\x05");
TerminalInitialized = TRUE; TerminalInitialized = TRUE;
Length = 0; Length = 0;
@ -3087,7 +3088,7 @@ KdbpPager(
/* Try to query number of rows from terminal. A reply looks like "\x1b[8;24;80t" */ /* Try to query number of rows from terminal. A reply looks like "\x1b[8;24;80t" */
TerminalReportsSize = FALSE; TerminalReportsSize = FALSE;
KeStallExecutionProcessor(100000); KeStallExecutionProcessor(100000);
DbgPrint("\x1b[18t"); KdpDprintf("\x1b[18t");
c = KdbpTryGetCharSerial(5000); c = KdbpTryGetCharSerial(5000);
if (c == KEY_ESC) if (c == KEY_ESC)
@ -3148,7 +3149,7 @@ KdbpPager(
{ {
if ( p > Buffer+BufLength) 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; return;
} }
i = strcspn(p, "\n"); i = strcspn(p, "\n");
@ -3178,9 +3179,9 @@ KdbpPager(
KdbRepeatLastCommand = FALSE; KdbRepeatLastCommand = FALSE;
if (KdbNumberOfColsPrinted > 0) 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++; RowsPrintedByTerminal++;
if (KdbDebugState & KD_DEBUG_KDSERIAL) if (KdbDebugState & KD_DEBUG_KDSERIAL)
@ -3200,7 +3201,7 @@ KdbpPager(
} }
//DbgPrint("\n"); //Consize version: don't show pressed key //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') if (c == 'q')
{ {
@ -3264,7 +3265,7 @@ KdbpPager(
} }
// The main printing of the current line: // The main printing of the current line:
DbgPrint(p); KdpDprintf(p);
// restore not null char with saved: // restore not null char with saved:
if (c != '\0') if (c != '\0')

View file

@ -253,7 +253,7 @@ RpnpDumpStack(
ULONG ul; ULONG ul;
ASSERT(Stack); ASSERT(Stack);
DbgPrint("\nStack size: %ld\n", Stack->Sp); KdpDprintf("\nStack size: %ld\n", Stack->Sp);
for (ul = 0; ul < Stack->Sp; ul++) for (ul = 0; ul < Stack->Sp; ul++)
{ {
@ -261,60 +261,60 @@ RpnpDumpStack(
switch (Op->Type) switch (Op->Type)
{ {
case RpnOpNop: case RpnOpNop:
DbgPrint("NOP,"); KdpDprintf("NOP,");
break; break;
case RpnOpImmediate: case RpnOpImmediate:
DbgPrint("0x%I64x,", Op->Data.Immediate); KdpDprintf("0x%I64x,", Op->Data.Immediate);
break; break;
case RpnOpBinaryOperator: case RpnOpBinaryOperator:
if (Op->Data.BinaryOperator == RpnBinaryOperatorAdd) if (Op->Data.BinaryOperator == RpnBinaryOperatorAdd)
DbgPrint("+,"); KdpDprintf("+,");
else if (Op->Data.BinaryOperator == RpnBinaryOperatorSub) else if (Op->Data.BinaryOperator == RpnBinaryOperatorSub)
DbgPrint("-,"); KdpDprintf("-,");
else if (Op->Data.BinaryOperator == RpnBinaryOperatorMul) else if (Op->Data.BinaryOperator == RpnBinaryOperatorMul)
DbgPrint("*,"); KdpDprintf("*,");
else if (Op->Data.BinaryOperator == RpnBinaryOperatorDiv) else if (Op->Data.BinaryOperator == RpnBinaryOperatorDiv)
DbgPrint("/,"); KdpDprintf("/,");
else if (Op->Data.BinaryOperator == RpnBinaryOperatorMod) else if (Op->Data.BinaryOperator == RpnBinaryOperatorMod)
DbgPrint("%%,"); KdpDprintf("%%,");
else if (Op->Data.BinaryOperator == RpnBinaryOperatorEquals) else if (Op->Data.BinaryOperator == RpnBinaryOperatorEquals)
DbgPrint("==,"); KdpDprintf("==,");
else if (Op->Data.BinaryOperator == RpnBinaryOperatorNotEquals) else if (Op->Data.BinaryOperator == RpnBinaryOperatorNotEquals)
DbgPrint("!=,"); KdpDprintf("!=,");
else if (Op->Data.BinaryOperator == RpnBinaryOperatorLessThan) else if (Op->Data.BinaryOperator == RpnBinaryOperatorLessThan)
DbgPrint("<,"); KdpDprintf("<,");
else if (Op->Data.BinaryOperator == RpnBinaryOperatorLessThanOrEquals) else if (Op->Data.BinaryOperator == RpnBinaryOperatorLessThanOrEquals)
DbgPrint("<=,"); KdpDprintf("<=,");
else if (Op->Data.BinaryOperator == RpnBinaryOperatorGreaterThan) else if (Op->Data.BinaryOperator == RpnBinaryOperatorGreaterThan)
DbgPrint(">,"); KdpDprintf(">,");
else if (Op->Data.BinaryOperator == RpnBinaryOperatorGreaterThanOrEquals) else if (Op->Data.BinaryOperator == RpnBinaryOperatorGreaterThanOrEquals)
DbgPrint(">=,"); KdpDprintf(">=,");
else else
DbgPrint("UNKNOWN OP,"); KdpDprintf("UNKNOWN OP,");
break; break;
case RpnOpRegister: case RpnOpRegister:
DbgPrint("%s,", RegisterToTrapFrame[Op->Data.Register].Name); KdpDprintf("%s,", RegisterToTrapFrame[Op->Data.Register].Name);
break; break;
case RpnOpDereference: case RpnOpDereference:
DbgPrint("[%s],", KdpDprintf("[%s],",
(Op->Data.DerefMemorySize == 1) ? ("byte") : (Op->Data.DerefMemorySize == 1) ? ("byte") :
((Op->Data.DerefMemorySize == 2) ? ("word") : ((Op->Data.DerefMemorySize == 2) ? ("word") :
((Op->Data.DerefMemorySize == 4) ? ("dword") : ("qword")))); ((Op->Data.DerefMemorySize == 4) ? ("dword") : ("qword"))));
break; break;
default: default:
DbgPrint("\nUnsupported Type: %d\n", Op->Type); KdpDprintf("\nUnsupported Type: %d\n", Op->Type);
ul = Stack->Sp; ul = Stack->Sp;
break; break;
} }
} }
DbgPrint("\n"); KdpDprintf("\n");
} }
/*!\brief Clears the given RPN stack. /*!\brief Clears the given RPN stack.

View file

@ -180,12 +180,12 @@ KdbSymPrintAddress(
FunctionName); FunctionName);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
DbgPrint("<%s:%x (%s:%d (%s))>", KdpDprintf("<%s:%x (%s:%d (%s))>",
ModuleNameAnsi, RelativeAddress, FileName, LineNumber, FunctionName); ModuleNameAnsi, RelativeAddress, FileName, LineNumber, FunctionName);
} }
else else
{ {
DbgPrint("<%s:%x>", ModuleNameAnsi, RelativeAddress); KdpDprintf("<%s:%x>", ModuleNameAnsi, RelativeAddress);
} }
return TRUE; return TRUE;