https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a8662c73a59f3d9a416e89...
commit a8662c73a59f3d9a416e890108427f0ad8760b8a Author: Hervé Poussineau hpoussin@reactos.org AuthorDate: Sun Mar 8 17:52:19 2020 +0100 Commit: Hervé Poussineau hpoussin@reactos.org CommitDate: Mon Nov 16 08:55:03 2020 +0100
[NTOS:KD] Merge KdpTrap() with kd64 version --- ntoskrnl/kd/kdmain.c | 160 +++++++++++------------------------------------- ntoskrnl/kd64/kdprint.c | 19 ------ ntoskrnl/kd64/kdtrap.c | 13 +++- 3 files changed, 47 insertions(+), 145 deletions(-)
diff --git a/ntoskrnl/kd/kdmain.c b/ntoskrnl/kd/kdmain.c index f6edda85b6f..53df4366fdb 100644 --- a/ntoskrnl/kd/kdmain.c +++ b/ntoskrnl/kd/kdmain.c @@ -11,38 +11,6 @@ #define NDEBUG #include <debug.h>
-// -// Retrieves the ComponentId and Level for BREAKPOINT_PRINT -// and OutputString and OutputStringLength for BREAKPOINT_PROMPT. -// -#if defined(_X86_) - -// -// EBX/EDI on x86 -// -#define KdpGetParameterThree(Context) ((Context)->Ebx) -#define KdpGetParameterFour(Context) ((Context)->Edi) - -#elif defined(_AMD64_) - -// -// R8/R9 on AMD64 -// -#define KdpGetParameterThree(Context) ((Context)->R8) -#define KdpGetParameterFour(Context) ((Context)->R9) - -#elif defined(_ARM_) - -// -// R3/R4 on ARM -// -#define KdpGetParameterThree(Context) ((Context)->R3) -#define KdpGetParameterFour(Context) ((Context)->R4) - -#else -#error Unsupported Architecture -#endif - /* VARIABLES ***************************************************************/
VOID NTAPI PspDumpThreads(BOOLEAN SystemThreads); @@ -52,109 +20,53 @@ extern ANSI_STRING KdpLogFileName;
/* PRIVATE FUNCTIONS *********************************************************/
-BOOLEAN +VOID NTAPI -KdpTrap(IN PKTRAP_FRAME TrapFrame, - IN PKEXCEPTION_FRAME ExceptionFrame, - IN PEXCEPTION_RECORD ExceptionRecord, - IN PCONTEXT Context, - IN KPROCESSOR_MODE PreviousMode, - IN BOOLEAN SecondChance) +KdpReportCommandStringStateChange(IN PSTRING NameString, + IN PSTRING CommandString, + IN OUT PCONTEXT Context) { - KD_CONTINUE_TYPE Return = kdHandleException; - ULONG ExceptionCommand = ExceptionRecord->ExceptionInformation[0]; - - /* Check if this was a breakpoint due to DbgPrint or Load/UnloadSymbols */ - if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) && - (ExceptionRecord->NumberParameters > 0) && - ((ExceptionCommand == BREAKPOINT_LOAD_SYMBOLS) || - (ExceptionCommand == BREAKPOINT_UNLOAD_SYMBOLS) || - (ExceptionCommand == BREAKPOINT_COMMAND_STRING) || - (ExceptionCommand == BREAKPOINT_PRINT) || - (ExceptionCommand == BREAKPOINT_PROMPT))) - { - /* Check if this is a debug print */ - if (ExceptionCommand == BREAKPOINT_PRINT) - { - /* Call KDBG */ - NTSTATUS ReturnStatus; - BOOLEAN Handled; - ReturnStatus = KdpPrint((ULONG)KdpGetParameterThree(Context), - (ULONG)KdpGetParameterFour(Context), - (PCHAR)ExceptionRecord->ExceptionInformation[1], - (USHORT)ExceptionRecord->ExceptionInformation[2], - PreviousMode, - TrapFrame, - ExceptionFrame, - &Handled); - - /* Update the return value for the caller */ - KeSetContextReturnRegister(Context, ReturnStatus); - } -#ifdef KDBG - else if (ExceptionCommand == BREAKPOINT_LOAD_SYMBOLS) - { - PKD_SYMBOLS_INFO SymbolsInfo; - KD_SYMBOLS_INFO CapturedSymbolsInfo; - PLDR_DATA_TABLE_ENTRY LdrEntry; +}
- SymbolsInfo = (PKD_SYMBOLS_INFO)ExceptionRecord->ExceptionInformation[2]; - if (PreviousMode != KernelMode) - { - _SEH2_TRY - { - ProbeForRead(SymbolsInfo, - sizeof(*SymbolsInfo), - 1); - KdpMoveMemory(&CapturedSymbolsInfo, - SymbolsInfo, - sizeof(*SymbolsInfo)); - SymbolsInfo = &CapturedSymbolsInfo; - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - SymbolsInfo = NULL; - } - _SEH2_END; - } +VOID +NTAPI +KdpReportLoadSymbolsStateChange(IN PSTRING PathName, + IN PKD_SYMBOLS_INFO SymbolInfo, + IN BOOLEAN Unload, + IN OUT PCONTEXT Context) +{ +#ifdef KDBG + PKD_SYMBOLS_INFO SymbolsInfo = SymbolInfo; + PLDR_DATA_TABLE_ENTRY LdrEntry;
- if (SymbolsInfo != NULL) - { - /* Load symbols. Currently implemented only for KDBG! */ - if (KdbpSymFindModule(SymbolsInfo->BaseOfDll, NULL, -1, &LdrEntry)) - { - KdbSymProcessSymbols(LdrEntry); - } - } - } - else if (ExceptionCommand == BREAKPOINT_PROMPT) + if (SymbolsInfo != NULL && !Unload) + { + /* Load symbols. Currently implemented only for KDBG! */ + if (KdbpSymFindModule(SymbolsInfo->BaseOfDll, NULL, -1, &LdrEntry)) { - /* Call KDBG */ - ULONG ReturnLength; - ReturnLength = KdpPrompt((PCHAR)ExceptionRecord->ExceptionInformation[1], - (USHORT)ExceptionRecord->ExceptionInformation[2], - (PCHAR)KdpGetParameterThree(Context), - (USHORT)KdpGetParameterFour(Context), - PreviousMode, - TrapFrame, - ExceptionFrame); - - /* Update the return value for the caller */ - KeSetContextReturnRegister(Context, ReturnLength); + KdbSymProcessSymbols(LdrEntry); } + } #endif +}
- /* This we can handle: simply bump the Program Counter */ - KeSetContextPc(Context, KeGetContextPc(Context) + KD_BREAKPOINT_SIZE); - return TRUE; - } +BOOLEAN +NTAPI +KdpReport(IN PKTRAP_FRAME TrapFrame, + IN PKEXCEPTION_FRAME ExceptionFrame, + IN PEXCEPTION_RECORD ExceptionRecord, + IN PCONTEXT ContextRecord, + IN KPROCESSOR_MODE PreviousMode, + IN BOOLEAN SecondChanceException) +{ + KD_CONTINUE_TYPE Return = kdHandleException;
#ifdef KDBG /* Check if this is an assertion failure */ if (ExceptionRecord->ExceptionCode == STATUS_ASSERTION_FAILURE) { /* Bump EIP to the instruction following the int 2C */ - Context->Eip += 2; + ContextRecord->Eip += 2; } #endif
@@ -165,15 +77,15 @@ KdpTrap(IN PKTRAP_FRAME TrapFrame, /* Call KDBG if available */ Return = KdbEnterDebuggerException(ExceptionRecord, PreviousMode, - Context, + ContextRecord, TrapFrame, - !SecondChance); + !SecondChanceException); #else /* not KDBG */ if (WrapperInitRoutine) { /* Call GDB */ Return = WrapperTable.KdpExceptionRoutine(ExceptionRecord, - Context, + ContextRecord, TrapFrame); }
diff --git a/ntoskrnl/kd64/kdprint.c b/ntoskrnl/kd64/kdprint.c index 1d9caa87cea..9932798fbde 100644 --- a/ntoskrnl/kd64/kdprint.c +++ b/ntoskrnl/kd64/kdprint.c @@ -130,8 +130,6 @@ KdpPromptString( return FALSE; }
-#ifdef _WINKD_ - VOID NTAPI KdpCommandString(IN PSTRING NameString, @@ -212,23 +210,6 @@ KdpSymbol(IN PSTRING DllPath, KdExitDebugger(Enable); }
-#else - -extern -BOOLEAN -NTAPI -KdpPrintString( - _In_ PSTRING Output); - -extern -BOOLEAN -NTAPI -KdpPromptString( - _In_ PSTRING PromptString, - _In_ PSTRING ResponseString); - -#endif // _WINKD_ - USHORT NTAPI KdpPrompt( diff --git a/ntoskrnl/kd64/kdtrap.c b/ntoskrnl/kd64/kdtrap.c index 7cb266b70d1..42a04faa460 100644 --- a/ntoskrnl/kd64/kdtrap.c +++ b/ntoskrnl/kd64/kdtrap.c @@ -47,7 +47,16 @@
/* FUNCTIONS *****************************************************************/
-#ifdef _WINKD_ +#ifndef _WINKD_ +BOOLEAN +NTAPI +KdpReport(IN PKTRAP_FRAME TrapFrame, + IN PKEXCEPTION_FRAME ExceptionFrame, + IN PEXCEPTION_RECORD ExceptionRecord, + IN PCONTEXT ContextRecord, + IN KPROCESSOR_MODE PreviousMode, + IN BOOLEAN SecondChanceException); +#else BOOLEAN NTAPI KdpReport(IN PKTRAP_FRAME TrapFrame, @@ -130,6 +139,7 @@ KdpReport(IN PKTRAP_FRAME TrapFrame, KdpControlCPressed = FALSE; return Handled; } +#endif
BOOLEAN NTAPI @@ -261,7 +271,6 @@ KdpTrap(IN PKTRAP_FRAME TrapFrame, /* Return TRUE or FALSE to caller */ return Handled; } -#endif
BOOLEAN NTAPI