示例#1
0
        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();
        }
示例#2
0
            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;
                        }
                    }
                }
            }
示例#3
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);
   }
 }
示例#5
0
        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();
        }
示例#6
0
        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);
                }
            }
        }
示例#7
0
    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();
    }