void IFunctionTracer.OnExitBreakpointHit(DkmRuntimeBreakpoint bp, DkmThread thread, bool hasException) { FunctionTraceEntryDataItem traceDataItem = bp.GetDataItem <FunctionTraceEntryDataItem>(); if (OnFunctionExited != null) { DkmStackWalkFrame frame = thread.GetTopStackWalkFrame(bp.RuntimeInstance); StackFrameAnalyzer exitAnalyzer = null; if (traceDataItem != null) { DkmSystemInformationFlags systemInformationFlags = frame.ModuleInstance.Process.SystemInformation.Flags; bool isTarget64Bit = systemInformationFlags.HasFlag(DkmSystemInformationFlags.Is64Bit); int pointerSize = (isTarget64Bit) ? 8 : 4; exitAnalyzer = new CachedFrameAnalyzer( frameAnalyzer.Parameters, traceDataItem.EntryArgumentValues, pointerSize); } OnFunctionExited(frame, exitAnalyzer); } // Since this was a one-shot breakpoint, it is unconditionally closed. bp.Close(); }
void IDkmRuntimeMonitorBreakpointHandler.DisableRuntimeBreakpoint(DkmRuntimeBreakpoint runtimeBreakpoint) { var breakpointData = runtimeBreakpoint.GetDataItem <NullcBreakpointDataItem>(); if (breakpointData != null) { var processData = DebugHelpers.GetOrCreateDataItem <NullcRemoteProcessDataItem>(runtimeBreakpoint.Process); var address = breakpointData.instructionAddress.CPUInstructionPart.InstructionPointer; runtimeBreakpoint.Process.InvisibleWriteMemory(breakpointData.instructionAddress.CPUInstructionPart.InstructionPointer, breakpointData.prevValue); // Skip internal breakpoints used in stepper if (runtimeBreakpoint.SourceId != DebugHelpers.NullcStepperBreakpointSourceId) { if (processData.activeBreakpointLocations.Contains(address)) { processData.activeBreakpointLocations.Remove(address); } // If we were planning to restore the breakpoint, forget about it if (processData.lastHitBreakpointLocation == address) { processData.lastHitBreakpointLocation = 0; } } } }
public void AddBreakpoint(DkmRuntimeBreakpoint bp) { var loc = bp.GetDataItem <SourceLocation>(); if (!_breakpoints.TryGetValue(loc, out List <DkmRuntimeBreakpoint> bpsAtLoc)) { _breakpoints[loc] = bpsAtLoc = new List <DkmRuntimeBreakpoint>(); } bpsAtLoc.Add(bp); WriteBreakpoints(); }
public void OnRuntimeBreakpointReceived( DkmRuntimeBreakpoint bp, DkmThread thread, bool hasException, DkmEventDescriptorS eventDescriptor) { FunctionTraceDataItem traceDataItem = bp.GetDataItem<FunctionTraceDataItem>(); if (traceDataItem != null && traceDataItem.Tracer != null) { if (bp.SourceId == Guids.Source.FunctionTraceEnter) traceDataItem.Tracer.OnEntryBreakpointHit(bp, thread, hasException); else if (bp.SourceId == Guids.Source.FunctionTraceExit) traceDataItem.Tracer.OnExitBreakpointHit(bp, thread, hasException); } }
public void RemoveBreakpoint(DkmRuntimeBreakpoint bp) { var loc = bp.GetDataItem <SourceLocation>(); if (!_breakpoints.TryGetValue(loc, out List <DkmRuntimeBreakpoint> bpsAtLoc)) { return; } if (!bpsAtLoc.Remove(bp)) { return; } if (bpsAtLoc.Count == 0) { _breakpoints.Remove(loc); } WriteBreakpoints(); }
public void OnRuntimeBreakpointReceived( DkmRuntimeBreakpoint bp, DkmThread thread, bool hasException, DkmEventDescriptorS eventDescriptor) { FunctionTraceDataItem traceDataItem = bp.GetDataItem <FunctionTraceDataItem>(); if (traceDataItem != null && traceDataItem.Tracer != null) { if (bp.SourceId == Guids.Source.FunctionTraceEnter) { traceDataItem.Tracer.OnEntryBreakpointHit(bp, thread, hasException); } else if (bp.SourceId == Guids.Source.FunctionTraceExit) { traceDataItem.Tracer.OnExitBreakpointHit(bp, thread, hasException); } } }
void IFunctionTracer.OnExitBreakpointHit(DkmRuntimeBreakpoint bp, DkmThread thread, bool hasException) { FunctionTraceEntryDataItem traceDataItem = bp.GetDataItem<FunctionTraceEntryDataItem>(); if (OnFunctionExited != null) { DkmStackWalkFrame frame = thread.GetTopStackWalkFrame(bp.RuntimeInstance); StackFrameAnalyzer exitAnalyzer = null; if (traceDataItem != null) { DkmSystemInformationFlags systemInformationFlags = frame.ModuleInstance.Process.SystemInformation.Flags; bool isTarget64Bit = systemInformationFlags.HasFlag(DkmSystemInformationFlags.Is64Bit); int pointerSize = (isTarget64Bit) ? 8 : 4; exitAnalyzer = new CachedFrameAnalyzer( frameAnalyzer.Parameters, traceDataItem.EntryArgumentValues, pointerSize); } OnFunctionExited(frame, exitAnalyzer); } // Since this was a one-shot breakpoint, it is unconditionally closed. bp.Close(); }