- Implement KdpSetContext.

- Fix KdpReport, it was totally out of whack.

svn path=/branches/alex-kd-branch/; revision=25853
This commit is contained in:
Alex Ionescu 2007-02-20 03:45:11 +00:00
parent 3006d54080
commit bf616180df
3 changed files with 103 additions and 63 deletions

View file

@ -121,9 +121,6 @@ KdpGetVersion(IN PDBGKD_MANIPULATE_STATE64 State)
&KdpContext); &KdpContext);
} }
BOOLEAN VirtCalled = FALSE;
VOID VOID
NTAPI NTAPI
KdpReadVirtualMemory(IN PDBGKD_MANIPULATE_STATE64 State, KdpReadVirtualMemory(IN PDBGKD_MANIPULATE_STATE64 State,
@ -326,6 +323,54 @@ KdpGetContext(IN PDBGKD_MANIPULATE_STATE64 State,
&KdpContext); &KdpContext);
} }
VOID
NTAPI
KdpSetContext(IN PDBGKD_MANIPULATE_STATE64 State,
IN PSTRING Data,
IN PCONTEXT Context)
{
STRING Header;
PVOID ControlStart;
/* Setup the header */
Header.Length = sizeof(DBGKD_MANIPULATE_STATE64);
Header.Buffer = (PCHAR)State;
ASSERT(Data->Length == 0);
/* Make sure that this is a valid request */
if (State->Processor < KeNumberProcessors)
{
/* Check if the request is for this CPU */
if (State->Processor == KeGetCurrentPrcb()->Number)
{
/* We're just copying our own context */
ControlStart = Context;
}
else
{
/* SMP not yet handled */
ControlStart = NULL;
while (TRUE);
}
/* Copy the memory */
RtlCopyMemory(ControlStart, Data->Buffer, sizeof(CONTEXT));
/* Finish up */
State->ReturnStatus = STATUS_SUCCESS;
}
else
{
/* Invalid request */
State->ReturnStatus = STATUS_UNSUCCESSFUL;
}
/* Send the reply */
KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
&Header,
Data,
&KdpContext);
}
KCONTINUE_STATUS KCONTINUE_STATUS
NTAPI NTAPI
@ -377,7 +422,6 @@ SendPacket:
/* Read virtual memory */ /* Read virtual memory */
KdpReadVirtualMemory(&ManipulateState, &Data, Context); KdpReadVirtualMemory(&ManipulateState, &Data, Context);
VirtCalled = TRUE;
break; break;
case DbgKdWriteVirtualMemoryApi: case DbgKdWriteVirtualMemoryApi:
@ -389,15 +433,14 @@ SendPacket:
case DbgKdGetContextApi: case DbgKdGetContextApi:
/* FIXME: TODO */ /* Get the current context */
KdpGetContext(&ManipulateState, &Data, Context); KdpGetContext(&ManipulateState, &Data, Context);
break; break;
case DbgKdSetContextApi: case DbgKdSetContextApi:
/* FIXME: TODO */ /* Set a new context */
Ke386SetCr2(DbgKdSetContextApi); KdpSetContext(&ManipulateState, &Data, Context);
while (TRUE);
break; break;
case DbgKdWriteBreakPointApi: case DbgKdWriteBreakPointApi:

View file

@ -248,6 +248,7 @@ KdInitSystem(IN ULONG BootPhase,
/* Check for incoming breakin and break on symbol load if we have it*/ /* Check for incoming breakin and break on symbol load if we have it*/
KdBreakAfterSymbolLoad = KdPollBreakIn(); KdBreakAfterSymbolLoad = KdPollBreakIn();
while (TRUE);
} }
else else
{ {

View file

@ -25,32 +25,31 @@ KdpReport(IN PKTRAP_FRAME TrapFrame,
{ {
BOOLEAN Entered, Status; BOOLEAN Entered, Status;
PKPRCB Prcb; PKPRCB Prcb;
while (TRUE); NTSTATUS ExceptionCode = ExceptionRecord->ExceptionCode;
/* /* Check if this is INT1 or 3, or if we're forced to handle it */
* Only go ahead with this if this is an INT3 or an INT1, or if the global if ((ExceptionCode == STATUS_BREAKPOINT) ||
* flag forces us to call up the debugger on exception, or if this is a (ExceptionCode == STATUS_SINGLE_STEP) ||
* second chance exception which means it hasn't been handled by now. //(ExceptionCode == STATUS_ASSERTION_FAILURE) ||
*/ (NtGlobalFlag & FLG_STOP_ON_EXCEPTION))
if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) ||
(ExceptionRecord->ExceptionCode == STATUS_SINGLE_STEP) ||
(NtGlobalFlag & FLG_STOP_ON_EXCEPTION) ||
(SecondChanceException))
{ {
/* /* Check if we can't really handle this */
* Also, unless this is a second chance exception, then do not call up if ((SecondChanceException) ||
* the debugger if the debug port is disconnected or the exception code (ExceptionCode == STATUS_PORT_DISCONNECTED) ||
* indicates success. (NT_SUCCESS(ExceptionCode)))
*/
if (!(SecondChanceException) &&
((ExceptionRecord->ExceptionCode == STATUS_PORT_DISCONNECTED) ||
(NT_SUCCESS(ExceptionRecord->ExceptionCode))))
{ {
/* Return false to hide the exception */ /* Return false to have someone else take care of the exception */
return FALSE;
}
}
else if (SecondChanceException)
{
/* We won't bother unless this is second chance */
return FALSE; return FALSE;
} }
/* Enter the debugger */ /* Enter the debugger */
while (TRUE);
Entered = KdEnterDebugger(TrapFrame, ExceptionFrame); Entered = KdEnterDebugger(TrapFrame, ExceptionFrame);
/* /*
@ -70,6 +69,7 @@ KdpReport(IN PKTRAP_FRAME TrapFrame,
ContextFrame, ContextFrame,
SecondChanceException); SecondChanceException);
#else #else
while (TRUE);
Status = FALSE; Status = FALSE;
#endif #endif
@ -83,10 +83,6 @@ KdpReport(IN PKTRAP_FRAME TrapFrame,
KdExitDebugger(Entered); KdExitDebugger(Entered);
KdpControlCPressed = FALSE; KdpControlCPressed = FALSE;
return Status; return Status;
}
/* Fail if we got here */
return FALSE;
} }
BOOLEAN BOOLEAN