private int SetState(enum_BP_STATE state) { if (_state == enum_BP_STATE.BPS_ENABLED) { if (state == enum_BP_STATE.BPS_DISABLED || state == enum_BP_STATE.BPS_DELETED) { if (DebugBreakpoint != null) { DebugBreakpoint.BreakpointHit -= DebugBreakpoint_BreakpointHit; if (Engine.IsConnected) { if (Engine.IsProgramDestroyed) { // If engine is shutting down, do not wait for the delete eval to complete, to avoid // blocking debugger detach if a long-running operation is in progress. This way the // engine can just report successful detach right away, and breakpoints are deleted // later, but as soon as it's actually possible. DebugBreakpoint.DeleteAsync() .SilenceException <MessageTransportException>() .DoNotWait(); } else { TaskExtensions.RunSynchronouslyOnUIThread(ct => DebugBreakpoint.DeleteAsync(ct)); } } } } } else { if (state == enum_BP_STATE.BPS_ENABLED) { if (Engine.IsProgramDestroyed) { // Do not allow enabling breakpoints when engine is shutting down. return(VSConstants.E_ABORT); } DebugBreakpoint = TaskExtensions.RunSynchronouslyOnUIThread(ct => Engine.Tracer.CreateBreakpointAsync(Location, ct)); DebugBreakpoint.BreakpointHit += DebugBreakpoint_BreakpointHit; } } _state = state; return(VSConstants.S_OK); }
private int SetState(enum_BP_STATE state) { if (_state == enum_BP_STATE.BPS_ENABLED) { if (state == enum_BP_STATE.BPS_DISABLED || state == enum_BP_STATE.BPS_DELETED) { if (DebugBreakpoint != null) { DebugBreakpoint.BreakpointHit -= DebugBreakpoint_BreakpointHit; if (Engine.IsConnected) { if (Engine.IsProgramDestroyed) { // If engine is shutting down, do not wait for the delete eval to complete, to avoid // blocking debugger detach if a long-running operation is in progress. This way the // engine can just report successful detach right away, and breakpoints are deleted // later, but as soon as it's actually possible. DebugBreakpoint.DeleteAsync().DoNotWait(); } else { TaskExtensions.RunSynchronouslyOnUIThread(ct => DebugBreakpoint.DeleteAsync(ct)); } } } } } else { if (state == enum_BP_STATE.BPS_ENABLED) { if (Engine.IsProgramDestroyed) { // Do not allow enabling breakpoints when engine is shutting down. return VSConstants.E_ABORT; } DebugBreakpoint = TaskExtensions.RunSynchronouslyOnUIThread(ct => Engine.Tracer.CreateBreakpointAsync(Location, ct)); DebugBreakpoint.BreakpointHit += DebugBreakpoint_BreakpointHit; } } _state = state; return VSConstants.S_OK; }
public BreakpointHitDetector(IRBreakpoint bp) { Breakpoint = bp; Breakpoint.BreakpointHit += Breakpoint_BreakpointHit; }