Implement kernel debugger entry point
Some checks failed
Builds / ExectOS (amd64, debug) (push) Failing after 29s
Builds / ExectOS (i686, debug) (push) Failing after 27s
Builds / ExectOS (amd64, release) (push) Failing after 44s
Builds / ExectOS (i686, release) (push) Failing after 41s

This commit is contained in:
2026-06-07 02:04:27 +02:00
parent 678a0f4f48
commit 4256a312ae
3 changed files with 84 additions and 0 deletions

View File

@@ -25,6 +25,13 @@ namespace KD
public:
STATIC XTAPI BOOLEAN DebuggerActive(VOID);
STATIC XTAPI VOID EnterDebugger(IN PKTRAP_FRAME TrapFrame);
STATIC XTAPI KCONTINUE_STATUS SwitchCpu(VOID);
private:
STATIC XTAPI BOOLEAN ProcessCpuStateChange(IN PEXCEPTION_RECORD ExceptionRecord,
IN OUT PCONTEXT Context,
IN BOOLEAN SecondChanceException);
};
}

View File

@@ -22,3 +22,79 @@ KD::Debugger::DebuggerActive(VOID)
{
return Active;
}
/**
* Serves as the primary entry point for the interactive kernel debugger.
*
* @param TrapFrame
* Supplies a pointer to the processor's trap frame captured at the moment the breakpoint or exception occurred.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTAPI
VOID
KD::Debugger::EnterDebugger(IN PKTRAP_FRAME TrapFrame)
{
/* Mark the debugger as active */
Active = TRUE;
/* Print debug message and enter an infinite loop */
DebugPrint(L"\n\n*** KDebugger Entered at RIP 0x%.16llX ***\n", TrapFrame->Rip);
for(;;);
/* Mark the debugger as inactive */
Active = FALSE;
}
/**
* Processes a processor state change and acts as the primary event loop for the debugger.
*
* @param ExceptionRecord
* Supplies a pointer to the exception record that triggered the state change.
*
* @param Context
* Supplies a pointer to the processor's context frame.
*
* @param SecondChance
* Supplies a boolean value indicating whether this is a second-chance exception.
*
* @return This routine returns TRUE if the exception was handled by the debugger, or FALSE otherwise.
*
* @since XT 1.0
*/
XTAPI
BOOLEAN
KD::Debugger::ProcessCpuStateChange(IN PEXCEPTION_RECORD ExceptionRecord,
IN OUT PCONTEXT Context,
IN BOOLEAN SecondChance)
{
return FALSE;
}
/**
* Transfers active control to a previously frozen processor.
*
* @return This routine returns a value indicating how execution should proceed after the debugging session concludes.
*
* @since XT 1.0
*/
XTAPI
KCONTINUE_STATUS
KD::Debugger::SwitchCpu(VOID)
{
EXCEPTION_RECORD ExceptionRecord;
PKPROCESSOR_CONTROL_BLOCK Prcb;
/* Get processor control block */
Prcb = KE::Processor::GetCurrentProcessorControlBlock();
/* Construct an exception record */
ExceptionRecord.ExceptionAddress = (PVOID)&Prcb->ProcessorState.ContextFrame.Rip;
ExceptionRecord.ExceptionCode = STATUS_WAKE_SYSTEM_DEBUGGER;
ExceptionRecord.ExceptionRecord = &ExceptionRecord;
/* Pass the synthetic exception and the processor context to the debugger */
return (KCONTINUE_STATUS)ProcessCpuStateChange(&ExceptionRecord, &Prcb->ProcessorState.ContextFrame, FALSE);
}