mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[NTOS:KD] Merge KdpReportExceptionStateChange() with kd64 version
This commit is contained in:
parent
baa47fa5e0
commit
0c76bbfe98
5 changed files with 75 additions and 61 deletions
|
@ -281,10 +281,6 @@ NTAPI
|
|||
KdpReportExceptionStateChange(
|
||||
IN PEXCEPTION_RECORD ExceptionRecord,
|
||||
IN OUT PCONTEXT Context,
|
||||
#ifndef _WINKD_
|
||||
IN PKTRAP_FRAME TrapFrame,
|
||||
IN KPROCESSOR_MODE PreviousMode,
|
||||
#endif
|
||||
IN BOOLEAN SecondChanceException
|
||||
);
|
||||
|
||||
|
|
|
@ -43,6 +43,12 @@ volatile ULONG KdbDmesgTotalWritten = 0;
|
|||
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
|
||||
|
@ -560,6 +566,50 @@ KdSendPacket(
|
|||
#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;
|
||||
}
|
||||
|
@ -586,8 +636,32 @@ KdReceivePacket(
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,52 +17,6 @@ VOID NTAPI PspDumpThreads(BOOLEAN SystemThreads);
|
|||
|
||||
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
|
||||
|
|
|
@ -1725,7 +1725,6 @@ KdpReportCommandStringStateChange(IN PSTRING NameString,
|
|||
} while (Status == ContinueProcessorReselected);
|
||||
}
|
||||
|
||||
#ifdef _WINKD_
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
KdpReportExceptionStateChange(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||
|
@ -1780,7 +1779,6 @@ KdpReportExceptionStateChange(IN PEXCEPTION_RECORD ExceptionRecord,
|
|||
/* Return */
|
||||
return Status;
|
||||
}
|
||||
#endif
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
|
@ -1844,10 +1842,6 @@ KdpSwitchProcessor(IN PEXCEPTION_RECORD ExceptionRecord,
|
|||
/* Report a state change */
|
||||
Status = KdpReportExceptionStateChange(ExceptionRecord,
|
||||
ContextRecord,
|
||||
#ifndef _WINKD_
|
||||
NULL,
|
||||
KernelMode,
|
||||
#endif
|
||||
SecondChanceException);
|
||||
|
||||
/* Restore the port data and return */
|
||||
|
|
|
@ -116,10 +116,6 @@ KdpReport(IN PKTRAP_FRAME TrapFrame,
|
|||
Handled = KdpReportExceptionStateChange(ExceptionRecord,
|
||||
&Prcb->ProcessorState.
|
||||
ContextFrame,
|
||||
#ifndef _WINKD_
|
||||
TrapFrame,
|
||||
PreviousMode,
|
||||
#endif
|
||||
SecondChanceException);
|
||||
|
||||
/* Now restore the processor state, manually again. */
|
||||
|
|
Loading…
Reference in a new issue