- Fix KdpSetCommonSTate to clear breakpoints.

- Allow KdpReadVirtualMemory to read SharedUserData since it's now readable.
- Allow it to read user-mode pointers as well, just not null-pointers.
- Fix KdpReportExceptionStateChange by implementing DumpTraceData. Now the crash in ndis.sys gets caught.
- Next up: implement breakpoints so that stepping out works.

svn path=/trunk/; revision=25997
This commit is contained in:
Alex Ionescu 2007-03-05 03:23:58 +00:00
parent e707b70756
commit 5e5311f4ae
3 changed files with 38 additions and 17 deletions

View file

@ -221,6 +221,13 @@ KdpDeleteBreakpoint(
IN ULONG BpEntry IN ULONG BpEntry
); );
BOOLEAN
NTAPI
KdpDeleteBreakpointRange(
IN PVOID Base,
IN PVOID Limit
);
// //
// Global KD Data // Global KD Data
// //
@ -262,3 +269,5 @@ extern BOOLEAN KdpOweBreakpoint;
extern BOOLEAN BreakpointsSuspended; extern BOOLEAN BreakpointsSuspended;
extern ULONG KdpNumInternalBreakpoints; extern ULONG KdpNumInternalBreakpoints;
extern ULONG KdpCurrentSymbolStart, KdpCurrentSymbolEnd; extern ULONG KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
extern ULONG TraceDataBuffer[40];
extern ULONG TraceDataBufferPosition;

View file

@ -14,6 +14,21 @@
/* PRIVATE FUNCTIONS *********************************************************/ /* PRIVATE FUNCTIONS *********************************************************/
VOID
NTAPI
DumpTraceData(IN PSTRING TraceData)
{
/* Update the buffer */
TraceDataBuffer[0] = TraceDataBufferPosition;
/* Setup the trace data */
TraceData->Length = TraceDataBufferPosition * sizeof(ULONG);
TraceData->Buffer = (PCHAR)TraceDataBuffer;
/* Reset the buffer location */
TraceDataBufferPosition = 1;
}
VOID VOID
NTAPI NTAPI
KdpGetStateChange(IN PDBGKD_MANIPULATE_STATE64 State, KdpGetStateChange(IN PDBGKD_MANIPULATE_STATE64 State,
@ -87,13 +102,10 @@ KdpSetCommonState(IN ULONG NewState,
WaitStateChange->ControlReport.InstructionCount = InstructionCount; WaitStateChange->ControlReport.InstructionCount = InstructionCount;
/* Clear all the breakpoints in this region */ /* Clear all the breakpoints in this region */
HadBreakpoints = FALSE; HadBreakpoints =
#if 0 KdpDeleteBreakpointRange((PVOID)(LONG_PTR)WaitStateChange->ProgramCounter,
KdpDeleteBreakpointRange((PVOID)WaitStateChange->ProgramCounter, (PVOID)((ULONG)WaitStateChange->ProgramCounter +
(PVOID)(WaitStateChange->ProgramCounter + WaitStateChange->ControlReport.InstructionCount - 1));
WaitStateChange->ControlReport.
InstructionCount - 1));
#endif
if (HadBreakpoints) if (HadBreakpoints)
{ {
/* Copy the instruction stream again, this time without breakpoints */ /* Copy the instruction stream again, this time without breakpoints */
@ -190,12 +202,7 @@ KdpReadVirtualMemory(IN PDBGKD_MANIPULATE_STATE64 State,
} }
#endif #endif
if ((ULONG_PTR)State->u.ReadMemory.TargetBaseAddress < KSEG0_BASE) if (!State->u.ReadMemory.TargetBaseAddress)
{
Length = 0;
Status = STATUS_UNSUCCESSFUL;
}
else if ((ULONG_PTR)State->u.ReadMemory.TargetBaseAddress >= (ULONG_PTR)SharedUserData)
{ {
Length = 0; Length = 0;
Status = STATUS_UNSUCCESSFUL; Status = STATUS_UNSUCCESSFUL;
@ -900,6 +907,9 @@ KdpReportExceptionStateChange(IN PEXCEPTION_RECORD ExceptionRecord,
Header.Length = sizeof(DBGKD_WAIT_STATE_CHANGE64); Header.Length = sizeof(DBGKD_WAIT_STATE_CHANGE64);
Header.Buffer = (PCHAR)&WaitStateChange; Header.Buffer = (PCHAR)&WaitStateChange;
/* Setup the trace data */
DumpTraceData(&Data);
/* Send State Change packet and wait for a reply */ /* Send State Change packet and wait for a reply */
Status = KdpSendWaitContinue(PACKET_TYPE_KD_STATE_CHANGE64, Status = KdpSendWaitContinue(PACKET_TYPE_KD_STATE_CHANGE64,
&Header, &Header,
@ -971,13 +981,9 @@ KdpSwitchProcessor(IN PEXCEPTION_RECORD ExceptionRecord,
KdSave(FALSE); KdSave(FALSE);
/* Report a state change */ /* Report a state change */
#if 0
Status = KdpReportExceptionStateChange(ExceptionRecord, Status = KdpReportExceptionStateChange(ExceptionRecord,
ContextRecord, ContextRecord,
SecondChanceException); SecondChanceException);
#else
Status = FALSE;
#endif
/* Restore the port data and return */ /* Restore the port data and return */
KdRestore(FALSE); KdRestore(FALSE);

View file

@ -55,6 +55,12 @@ ULONG KdpNumInternalBreakpoints;
ULONG KdpCurrentSymbolStart, KdpCurrentSymbolEnd; ULONG KdpCurrentSymbolStart, KdpCurrentSymbolEnd;
//
// Tracepoint Data
//
ULONG TraceDataBuffer[40];
ULONG TraceDataBufferPosition = 1;
// //
// Time Slip Support // Time Slip Support
// //