Author: ion
Date: Tue Feb 20 06:45:11 2007
New Revision: 25853
URL: http://svn.reactos.org/svn/reactos?rev=25853&view=rev
Log:
- Implement KdpSetContext.
- Fix KdpReport, it was totally out of whack.
Modified:
branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdapi.c
branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdinit.c
branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdtrap.c
Modified: branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdapi.c
URL: http://svn.reactos.org/svn/reactos/branches/alex-kd-branch/reactos/ntoskrnl…
==============================================================================
--- branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdapi.c (original)
+++ branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdapi.c Tue Feb 20 06:45:11 2007
@@ -120,9 +120,6 @@
NULL,
&KdpContext);
}
-
-
-BOOLEAN VirtCalled = FALSE;
VOID
NTAPI
@@ -326,6 +323,54 @@
&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
NTAPI
@@ -377,7 +422,6 @@
/* Read virtual memory */
KdpReadVirtualMemory(&ManipulateState, &Data, Context);
- VirtCalled = TRUE;
break;
case DbgKdWriteVirtualMemoryApi:
@@ -389,15 +433,14 @@
case DbgKdGetContextApi:
- /* FIXME: TODO */
+ /* Get the current context */
KdpGetContext(&ManipulateState, &Data, Context);
break;
case DbgKdSetContextApi:
- /* FIXME: TODO */
- Ke386SetCr2(DbgKdSetContextApi);
- while (TRUE);
+ /* Set a new context */
+ KdpSetContext(&ManipulateState, &Data, Context);
break;
case DbgKdWriteBreakPointApi:
Modified: branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdinit.c
URL: http://svn.reactos.org/svn/reactos/branches/alex-kd-branch/reactos/ntoskrnl…
==============================================================================
--- branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdinit.c (original)
+++ branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdinit.c Tue Feb 20 06:45:11 2007
@@ -248,6 +248,7 @@
/* Check for incoming breakin and break on symbol load if we have it*/
KdBreakAfterSymbolLoad = KdPollBreakIn();
+ while (TRUE);
}
else
{
Modified: branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdtrap.c
URL: http://svn.reactos.org/svn/reactos/branches/alex-kd-branch/reactos/ntoskrnl…
==============================================================================
--- branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdtrap.c (original)
+++ branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdtrap.c Tue Feb 20 06:45:11 2007
@@ -25,68 +25,64 @@
{
BOOLEAN Entered, Status;
PKPRCB Prcb;
- while (TRUE);
-
- /*
- * Only go ahead with this if this is an INT3 or an INT1, or if the global
- * flag forces us to call up the debugger on exception, or if this is a
- * second chance exception which means it hasn't been handled by now.
- */
- if ((ExceptionRecord->ExceptionCode == STATUS_BREAKPOINT) ||
- (ExceptionRecord->ExceptionCode == STATUS_SINGLE_STEP) ||
- (NtGlobalFlag & FLG_STOP_ON_EXCEPTION) ||
- (SecondChanceException))
- {
- /*
- * Also, unless this is a second chance exception, then do not call up
- * the debugger if the debug port is disconnected or the exception code
- * indicates success.
- */
- if (!(SecondChanceException) &&
- ((ExceptionRecord->ExceptionCode == STATUS_PORT_DISCONNECTED) ||
- (NT_SUCCESS(ExceptionRecord->ExceptionCode))))
+ NTSTATUS ExceptionCode = ExceptionRecord->ExceptionCode;
+
+ /* Check if this is INT1 or 3, or if we're forced to handle it */
+ if ((ExceptionCode == STATUS_BREAKPOINT) ||
+ (ExceptionCode == STATUS_SINGLE_STEP) ||
+ //(ExceptionCode == STATUS_ASSERTION_FAILURE) ||
+ (NtGlobalFlag & FLG_STOP_ON_EXCEPTION))
+ {
+ /* Check if we can't really handle this */
+ if ((SecondChanceException) ||
+ (ExceptionCode == STATUS_PORT_DISCONNECTED) ||
+ (NT_SUCCESS(ExceptionCode)))
{
- /* Return false to hide the exception */
+ /* Return false to have someone else take care of the exception */
return FALSE;
}
-
- /* Enter the debugger */
- Entered = KdEnterDebugger(TrapFrame, ExceptionFrame);
-
- /*
- * Get the KPRCB and save the CPU Control State manually instead of
- * using KiSaveProcessorState, since we already have a valid CONTEXT.
- */
- Prcb = KeGetCurrentPrcb();
- KiSaveProcessorControlState(&Prcb->ProcessorState);
- RtlCopyMemory(&Prcb->ProcessorState.ContextFrame,
- ContextRecord,
- sizeof(CONTEXT));
-
- /* Report the new state */
+ }
+ else if (SecondChanceException)
+ {
+ /* We won't bother unless this is second chance */
+ return FALSE;
+ }
+
+ /* Enter the debugger */
+ while (TRUE);
+ Entered = KdEnterDebugger(TrapFrame, ExceptionFrame);
+
+ /*
+ * Get the KPRCB and save the CPU Control State manually instead of
+ * using KiSaveProcessorState, since we already have a valid CONTEXT.
+ */
+ Prcb = KeGetCurrentPrcb();
+ KiSaveProcessorControlState(&Prcb->ProcessorState);
+ RtlCopyMemory(&Prcb->ProcessorState.ContextFrame,
+ ContextRecord,
+ sizeof(CONTEXT));
+
+ /* Report the new state */
#if 0
- Status = KdpReportExceptionStateChange(ExceptionRecord,
- &Prcb->ProcessorState.
- ContextFrame,
- SecondChanceException);
+ Status = KdpReportExceptionStateChange(ExceptionRecord,
+ &Prcb->ProcessorState.
+ ContextFrame,
+ SecondChanceException);
#else
- Status = FALSE;
+ while (TRUE);
+ Status = FALSE;
#endif
- /* Now restore the processor state, manually again. */
- RtlCopyMemory(ContextRecord,
- &Prcb->ProcessorState.ContextFrame,
- sizeof(CONTEXT));
- KiRestoreProcessorControlState(&Prcb->ProcessorState);
-
- /* Exit the debugger and clear the CTRL-C state */
- KdExitDebugger(Entered);
- KdpControlCPressed = FALSE;
- return Status;
- }
-
- /* Fail if we got here */
- return FALSE;
+ /* Now restore the processor state, manually again. */
+ RtlCopyMemory(ContextRecord,
+ &Prcb->ProcessorState.ContextFrame,
+ sizeof(CONTEXT));
+ KiRestoreProcessorControlState(&Prcb->ProcessorState);
+
+ /* Exit the debugger and clear the CTRL-C state */
+ KdExitDebugger(Entered);
+ KdpControlCPressed = FALSE;
+ return Status;
}
BOOLEAN