/// <summary> /// Creates an entry and remotely enables the breakpoint in the debug stub. /// </summary> /// <param name="aBBP"> The bound breakpoint to add. </param> /// <returns> Breakpoint ID Number. </returns> public int RemoteAdd(AD7BoundBreakpoint aBBP) { // Call GDB to set a breakpoint based on filename and line no. in aBBP uint GDB_ID = 0; uint GDB_LinePos = 0; string GDB_Filename = ""; string GDB_address = ""; bool ret = false; if (aBBP.m_bpLocationType == (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE) { ret = m_engine.eDispatcher.setBreakpoint(aBBP.m_filename, aBBP.m_line, out GDB_ID, out GDB_LinePos, out GDB_Filename, out GDB_address); } else if (aBBP.m_bpLocationType == (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FUNC_OFFSET) { ret = m_engine.eDispatcher.setBreakpoint(aBBP.m_func, out GDB_ID, out GDB_LinePos, out GDB_Filename, out GDB_address); } if (ret) { m_activeBPs.Add(aBBP); aBBP.GDB_ID = GDB_ID; aBBP.GDB_FileName = GDB_Filename; aBBP.GDB_LinePos = GDB_LinePos; aBBP.GDB_Address = GDB_address; } return((int)GDB_ID); }
/// <summary> /// Called by bound breakpoints when they are being deleted. /// </summary> /// <param name="boundBreakpoint"> A bound breakpoint. </param> public void OnBoundBreakpointDeleted(AD7BoundBreakpoint boundBreakpoint) { lock (m_boundBreakpoints) { m_boundBreakpoints.Remove(boundBreakpoint); } }
/// <summary> /// Engines notify the debugger that a breakpoint has bound through the breakpoint bound event. /// </summary> /// <param name="objBoundBreakpoint"> The bounded breakpoint. </param> /// <param name="address"> 0. </param> public void OnBreakpointBound(object objBoundBreakpoint, uint address) { AD7BoundBreakpoint boundBreakpoint = (AD7BoundBreakpoint)objBoundBreakpoint; IDebugPendingBreakpoint2 pendingBreakpoint; ((IDebugBoundBreakpoint2)boundBreakpoint).GetPendingBreakpoint(out pendingBreakpoint); AD7BreakpointBoundEvent eventObject = new AD7BreakpointBoundEvent((AD7PendingBreakpoint)pendingBreakpoint, boundBreakpoint); Send(eventObject, AD7BreakpointBoundEvent.IID, null); }
/// <summary> /// Bind this breakpoint. (http://msdn.microsoft.com/en-ca/library/bb145901.aspx) /// </summary> /// <returns> If successful, returns S_OK; otherwise, returns an error code. </returns> int IDebugPendingBreakpoint2.Bind() { try { if (CanBind()) { AD7BoundBreakpoint xBBP = null; // Visual Studio returns a start position that is one less than it actually is xBBP = new AD7BoundBreakpoint(m_engine, m_bpRequestInfo, this); if (VSNDK.Package.ControlDebugEngine.isDebugEngineRunning == false) { return(VSConstants.S_FALSE); } if ((xBBP == null) || (xBBP.GDB_ID == 0)) { return(VSConstants.S_FALSE); } // Set the enabled state of the bound breakpoint based on the pending breakpoint's enabled state ((IDebugBoundBreakpoint2)xBBP).Enable(Convert.ToInt32(m_enabled)); m_boundBreakpoints.Add(xBBP); return(VSConstants.S_OK); } else { // The breakpoint could not be bound. This may occur for many reasons such as an invalid location, an invalid // expression, etc... The VSNDK debug engine does not support this, but a real world engine will want to send an // instance of IDebugBreakpointErrorEvent2 to the UI and return a valid instance of IDebugErrorBreakpoint2 from // IDebugPendingBreakpoint2::EnumErrorBreakpoints. The debugger will then display information about why the // breakpoint did not bind to the user. return(VSConstants.S_FALSE); } } catch (Exception e) { return(EngineUtils.UnexpectedException(e)); } }
/// <summary> /// Constructor. /// </summary> /// <param name="pendingBreakpoint"> The AD7PendingBreakpoint object that represents the pending breakpoint being bound. </param> /// <param name="boundBreakpoint"> The AD7BoundBreakpoint object that represents the breakpoint being bound. </param> public AD7BreakpointBoundEvent(AD7PendingBreakpoint pendingBreakpoint, AD7BoundBreakpoint boundBreakpoint) { m_pendingBreakpoint = pendingBreakpoint; m_boundBreakpoint = boundBreakpoint; }
/// <summary> /// Called by bound breakpoints when they are being deleted. /// </summary> /// <param name="boundBreakpoint"> A bound breakpoint. </param> public void OnBoundBreakpointDeleted(AD7BoundBreakpoint boundBreakpoint) { lock (m_boundBreakpoints) { m_boundBreakpoints.Remove(boundBreakpoint); } }
/// <summary> /// Bind this breakpoint. (http://msdn.microsoft.com/en-ca/library/bb145901.aspx) /// </summary> /// <returns> If successful, returns S_OK; otherwise, returns an error code. </returns> int IDebugPendingBreakpoint2.Bind() { try { if (CanBind()) { AD7BoundBreakpoint xBBP = null; // Visual Studio returns a start position that is one less than it actually is xBBP = new AD7BoundBreakpoint(m_engine, m_bpRequestInfo, this); if (VSNDK.Package.ControlDebugEngine.isDebugEngineRunning == false) { return VSConstants.S_FALSE; } if ((xBBP == null) || (xBBP.GDB_ID == 0)) { return VSConstants.S_FALSE; } // Set the enabled state of the bound breakpoint based on the pending breakpoint's enabled state ((IDebugBoundBreakpoint2)xBBP).Enable(Convert.ToInt32(m_enabled)); m_boundBreakpoints.Add(xBBP); return VSConstants.S_OK; } else { // The breakpoint could not be bound. This may occur for many reasons such as an invalid location, an invalid // expression, etc... The VSNDK debug engine does not support this, but a real world engine will want to send an // instance of IDebugBreakpointErrorEvent2 to the UI and return a valid instance of IDebugErrorBreakpoint2 from // IDebugPendingBreakpoint2::EnumErrorBreakpoints. The debugger will then display information about why the // breakpoint did not bind to the user. return VSConstants.S_FALSE; } } catch (Exception e) { return EngineUtils.UnexpectedException(e); } }
/// <summary> /// Enable bound breakpoint. /// </summary> /// <param name="aBBP"> The Bound breakpoint to enable. </param> public void RemoteEnable(AD7BoundBreakpoint aBBP) { m_engine.eDispatcher.enableBreakpoint(aBBP.GDB_ID, true); }
/// <summary> /// Remove the associated bound breakpoint. /// </summary> /// <param name="aBBP"> The breakpoint to remove. </param> public void RemoteDelete(AD7BoundBreakpoint aBBP) { m_activeBPs.Remove(aBBP); m_engine.eDispatcher.deleteBreakpoint(aBBP.GDB_ID); }
/// <summary> /// Creates an entry and remotely enables the breakpoint in the debug stub. /// </summary> /// <param name="aBBP"> The bound breakpoint to add. </param> /// <returns> Breakpoint ID Number. </returns> public int RemoteAdd(AD7BoundBreakpoint aBBP) { // Call GDB to set a breakpoint based on filename and line no. in aBBP uint GDB_ID = 0; uint GDB_LinePos = 0; string GDB_Filename = ""; string GDB_address = ""; bool ret = false; if (aBBP.m_bpLocationType == (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE) { ret = m_engine.eDispatcher.setBreakpoint(aBBP.m_filename, aBBP.m_line, out GDB_ID, out GDB_LinePos, out GDB_Filename, out GDB_address); } else if (aBBP.m_bpLocationType == (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FUNC_OFFSET) { ret = m_engine.eDispatcher.setBreakpoint(aBBP.m_func, out GDB_ID, out GDB_LinePos, out GDB_Filename, out GDB_address); } if (ret) { m_activeBPs.Add(aBBP); aBBP.GDB_ID = GDB_ID; aBBP.GDB_FileName = GDB_Filename; aBBP.GDB_LinePos = GDB_LinePos; aBBP.GDB_Address = GDB_address; } return (int)GDB_ID; }
public AD7BreakpointBoundEvent(AD7PendingBreakpoint pendingBreakpoint, AD7BoundBreakpoint boundBreakpoint) { m_pendingBreakpoint = pendingBreakpoint; m_boundBreakpoint = boundBreakpoint; }
// Reset current hit count public bool resetHitCount(AD7BoundBreakpoint bbp, bool resetCondition) { // Declare local Variables uint GDB_LinePos = 0; string GDB_Filename = ""; string GDB_address = ""; uint GDB_ID = bbp.GDB_ID; deleteBreakpoint(GDB_ID); bool ret = false; if (bbp.m_bpLocationType == (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE) { ret = setBreakpoint(bbp.m_filename, bbp.m_fullPath, bbp.m_line, out GDB_ID, out GDB_LinePos, out GDB_Filename, out GDB_address); } else if (bbp.m_bpLocationType == (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FUNC_OFFSET) { ret = setBreakpoint(bbp.m_func, out GDB_ID, out GDB_LinePos, out GDB_Filename, out GDB_address); } if (ret) { bbp.GDB_ID = GDB_ID; bbp.m_hitCount = 0; bbp.SetPassCount(bbp.m_bpPassCount); if (resetCondition) bbp.SetCondition(bbp.m_bpCondition); return true; } return false; }
public void releaseBreakpoint(AD7BoundBreakpoint bbp, bool hit, bool cond) { lock (m_releaseBreakpoint) { if (hit && cond) { bbp.m_blockedPassCount = false; bbp.m_blockedConditional = false; } else if (hit) { bbp.m_blockedPassCount = false; } else if (cond) { bbp.m_blockedConditional = false; } } }
public bool lockedBreakpoint(AD7BoundBreakpoint bbp, bool hit, bool cond) { lock (m_lockBreakpoint) { if (hit && cond) { if ((!bbp.m_blockedPassCount) && (!bbp.m_blockedConditional)) { bbp.m_blockedPassCount = true; bbp.m_blockedConditional = true; return true; } } else if (hit) { if (!bbp.m_blockedPassCount) { bbp.m_blockedPassCount = true; return true; } } else if (cond) { if (!bbp.m_blockedConditional) { bbp.m_blockedConditional = true; return true; } } return false; } }
/// <summary> /// Remove the associated bound breakpoint. /// </summary> /// <param name="aBBP"> The breakpoint to remove. </param> public void RemoteDelete(AD7BoundBreakpoint aBBP) { m_activeBPs.Remove(aBBP); m_engine.eDispatcher.deleteBreakpoint(aBBP.GDB_ID); }
/// <summary> /// Disable bound breakpoint. /// </summary> /// <param name="aBBP"> The Bound breakpoint to disable. </param> public void RemoteDisable(AD7BoundBreakpoint aBBP) { m_engine.eDispatcher.enableBreakpoint(aBBP.GDB_ID, false); }