volatile BOOLEAN KdbpIsInDmesgMode = FALSE;
static KSPIN_LOCK KdpDmesgLogSpinLock;
+static ULONG KdbgNextApiNumber = DbgKdContinueApi;
+static CONTEXT KdbgContext;
+static EXCEPTION_RECORD64 KdbgExceptionRecord;
+static BOOLEAN KdbgFirstChanceException;
+static NTSTATUS KdbgContinueStatus = STATUS_SUCCESS;
+
/* LOCKING FUNCTIONS *********************************************************/
KIRQL
#endif
return;
}
+ else if (WaitStateChange->NewState == DbgKdExceptionStateChange)
+ {
+ KdbgNextApiNumber = DbgKdGetContextApi;
+ KdbgExceptionRecord = WaitStateChange->u.Exception.ExceptionRecord;
+ KdbgFirstChanceException = WaitStateChange->u.Exception.FirstChance;
+ return;
+ }
+ }
+ else if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE)
+ {
+ PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer;
+ if (ManipulateState->ApiNumber == DbgKdGetContextApi)
+ {
+ KD_CONTINUE_TYPE Result;
+
+#ifdef KDBG
+ /* Check if this is an assertion failure */
+ if (KdbgExceptionRecord.ExceptionCode == STATUS_ASSERTION_FAILURE)
+ {
+ /* Bump EIP to the instruction following the int 2C */
+ KdbgContext.Eip += 2;
+ }
+
+ Result = KdbEnterDebuggerException(&KdbgExceptionRecord,
+ KernelMode, // FIXME
+ &KdbgContext,
+ KdbgFirstChanceException);
+#else
+ /* We'll manually dump the stack for the user... */
+ KeRosDumpStackFrames(NULL, 0);
+ Result = kdHandleException;
+#endif
+ if (Result != kdHandleException)
+ KdbgContinueStatus = STATUS_SUCCESS;
+ else
+ KdbgContinueStatus = STATUS_UNSUCCESSFUL;
+ KdbgNextApiNumber = DbgKdSetContextApi;
+ return;
+ }
+ else if (ManipulateState->ApiNumber == DbgKdSetContextApi)
+ {
+ KdbgNextApiNumber = DbgKdContinueApi;
+ return;
+ }
}
UNIMPLEMENTED;
}
if (PacketType == PACKET_TYPE_KD_STATE_MANIPULATE)
{
PDBGKD_MANIPULATE_STATE64 ManipulateState = (PDBGKD_MANIPULATE_STATE64)MessageHeader->Buffer;
+ RtlZeroMemory(MessageHeader->Buffer, MessageHeader->MaximumLength);
+ if (KdbgNextApiNumber == DbgKdGetContextApi)
+ {
+ ManipulateState->ApiNumber = DbgKdGetContextApi;
+ MessageData->Length = 0;
+ MessageData->Buffer = (PCHAR)&KdbgContext;
+ return KdPacketReceived;
+ }
+ else if (KdbgNextApiNumber == DbgKdSetContextApi)
+ {
+ ManipulateState->ApiNumber = DbgKdSetContextApi;
+ MessageData->Length = sizeof(KdbgContext);
+ MessageData->Buffer = (PCHAR)&KdbgContext;
+ return KdPacketReceived;
+ }
+ else if (KdbgNextApiNumber != DbgKdContinueApi)
+ {
+ UNIMPLEMENTED;
+ }
ManipulateState->ApiNumber = DbgKdContinueApi;
- ManipulateState->u.Continue.ContinueStatus = STATUS_SUCCESS;
+ ManipulateState->u.Continue.ContinueStatus = KdbgContinueStatus;
+
+ /* Prepare for next time */
+ KdbgNextApiNumber = DbgKdContinueApi;
+ KdbgContinueStatus = STATUS_SUCCESS;
+
return KdPacketReceived;
}
extern ANSI_STRING KdpLogFileName;
-/* PRIVATE FUNCTIONS *********************************************************/
-
-BOOLEAN
-NTAPI
-KdpReportExceptionStateChange(IN PEXCEPTION_RECORD ExceptionRecord,
- IN OUT PCONTEXT ContextRecord,
- IN PKTRAP_FRAME TrapFrame,
- IN KPROCESSOR_MODE PreviousMode,
- IN BOOLEAN SecondChanceException)
-{
- KD_CONTINUE_TYPE Return = kdHandleException;
-#ifdef KDBG
- EXCEPTION_RECORD64 ExceptionRecord64;
-
- /* Check if this is an assertion failure */
- if (ExceptionRecord->ExceptionCode == STATUS_ASSERTION_FAILURE)
- {
- /* Bump EIP to the instruction following the int 2C */
- ContextRecord->Eip += 2;
- }
-
- ExceptionRecord32To64((PEXCEPTION_RECORD32)ExceptionRecord,
- &ExceptionRecord64);
-#endif
-
- /* Get out of here if the Debugger isn't connected */
- if (KdDebuggerNotPresent) return FALSE;
-
-#ifdef KDBG
- /* Call KDBG if available */
- Return = KdbEnterDebuggerException(&ExceptionRecord64,
- PreviousMode,
- ContextRecord,
- !SecondChanceException);
-#else /* not KDBG */
- /* We'll manually dump the stack for the user... */
- KeRosDumpStackFrames(NULL, 0);
-#endif /* not KDBG */
-
- /* Debugger didn't handle it, please handle! */
- if (Return == kdHandleException) return FALSE;
-
- /* Debugger handled it */
- return TRUE;
-}
-
/* PUBLIC FUNCTIONS *********************************************************/
static PCHAR