/// <summary> /// AD7BoundBreakpoint constructor for file/line breaks. /// </summary> /// <param name="engine"> AD7 Engine. </param> /// <param name="bpReqInfo"> Contains the information required to implement a breakpoint. </param> /// <param name="pendingBreakpoint"> Associated pending breakpoint. </param> public AD7BoundBreakpoint(AD7Engine engine, BP_REQUEST_INFO bpReqInfo, AD7PendingBreakpoint pendingBreakpoint) { if (bpReqInfo.bpLocation.bpLocationType == (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE) { string documentName; // Get Decument Position and File Name IDebugDocumentPosition2 docPosition = (IDebugDocumentPosition2)(Marshal.GetObjectForIUnknown(bpReqInfo.bpLocation.unionmember2)); docPosition.GetFileName(out documentName); // Need to shorten the path we send to GDB. StringBuilder shortPath = new StringBuilder(1024); GetShortPathName(documentName, shortPath, shortPath.Capacity); // Get the location in the document that the breakpoint is in. TEXT_POSITION[] startPosition = new TEXT_POSITION[1]; TEXT_POSITION[] endPosition = new TEXT_POSITION[1]; docPosition.GetRange(startPosition, endPosition); m_engine = engine; m_bpLocationType = (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE; m_filename = shortPath.ToString(); m_line = startPosition[0].dwLine + 1; m_pendingBreakpoint = pendingBreakpoint; m_enabled = true; m_deleted = false; m_hitCount = 0; m_remoteID = m_engine.BPMgr.RemoteAdd(this); } else if (bpReqInfo.bpLocation.bpLocationType == (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FUNC_OFFSET) { string func; IDebugFunctionPosition2 funcPosition = (IDebugFunctionPosition2)(Marshal.GetObjectForIUnknown(bpReqInfo.bpLocation.unionmember2)); funcPosition.GetFunctionName(out func); m_engine = engine; m_func = func; m_enabled = true; m_deleted = false; m_hitCount = 0; m_bpLocationType = (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FUNC_OFFSET; m_pendingBreakpoint = pendingBreakpoint; m_remoteID = m_engine.BPMgr.RemoteAdd(this); } // if ((m_remoteID == 0) && (VSNDK.AddIn.VSNDKAddIn.isDebugEngineRunning == false)) if (m_remoteID == 0) { return; } // Set the hit count and condition if (bpReqInfo.bpPassCount.stylePassCount != enum_BP_PASSCOUNT_STYLE.BP_PASSCOUNT_NONE) SetPassCount(bpReqInfo.bpPassCount); if (bpReqInfo.bpCondition.styleCondition != enum_BP_COND_STYLE.BP_COND_NONE) SetCondition(bpReqInfo.bpCondition); // Get the Line Position sent back from GDB TEXT_POSITION tpos = new TEXT_POSITION(); tpos.dwLine = m_GDB_linePos - 1; uint xAddress = UInt32.Parse(m_GDB_Address.Substring(2), System.Globalization.NumberStyles.HexNumber); AD7MemoryAddress codeContext = new AD7MemoryAddress(m_engine, xAddress); AD7DocumentContext documentContext = new AD7DocumentContext(m_GDB_filename, tpos, tpos, codeContext); m_breakpointResolution = new AD7BreakpointResolution(m_engine, xAddress, documentContext); m_engine.Callback.OnBreakpointBound(this, 0); }
/// <summary> /// Constructor. /// </summary> /// <param name="engine"> AD7 Engine. </param> /// <param name="address"> GDB Address. </param> /// <param name="documentContext"> The document context to the debugger. A document context represents a location within a /// source file. </param> public AD7BreakpointResolution(AD7Engine engine, uint address, AD7DocumentContext documentContext) { m_engine = engine; m_address = address; m_documentContext = documentContext; }
/// <summary> /// Called by the SDM to indicate that a synchronous debug event, previously sent by the DE to the SDM, /// was received and processed. The only event the VSNDK Debug Engine sends in this fashion is Program Destroy. /// It responds to that event by shutting down the engine. (http://msdn.microsoft.com/en-us/library/bb160915.aspx) /// </summary> /// <param name="eventObject"> Represents the previously sent synchronous event from which the debugger should now continue. </param> /// <returns> If successful, returns S_OK; otherwise, returns an error code. </returns> int IDebugEngine2.ContinueFromSynchronousEvent(IDebugEvent2 eventObject) { try { if (eventObject is AD7ProgramDestroyEvent) { resetStackFrames(); m_process.Detach(); m_process = null; m_program.Detach(); m_program = null; m_engineCallback = null; m_breakpointManager = null; m_docContext = null; m_eventDispatcher = null; m_module = null; m_progNode = null; m_programGUID = Guid.Empty; m_threads = null; GC.Collect(); } else { Debug.Fail("Unknown synchronous event"); } } catch (Exception e) { return EngineUtils.UnexpectedException(e); } if (m_eventDispatcher != null) m_eventDispatcher.continueExecution(); return VSConstants.S_OK; }
// Gets the document context for this stack frame. The debugger will call this when the current stack frame is changed // and will use it to open the correct source document for this stack frame. int IDebugStackFrame2.GetDocumentContext(out IDebugDocumentContext2 docContext) { this.m_engine.cleanEvaluatedThreads(); docContext = null; try { if (m_hasSource) { // Assume all lines begin and end at the beginning of the line. TEXT_POSITION begTp = new TEXT_POSITION(); begTp.dwColumn = 0; begTp.dwLine = m_lineNum - 1; TEXT_POSITION endTp = new TEXT_POSITION(); endTp.dwColumn = 0; endTp.dwLine = m_lineNum - 1; docContext = new AD7DocumentContext(m_documentName, begTp, endTp, null); return VSConstants.S_OK; } } catch (Exception e) { return EngineUtils.UnexpectedException(e); } return VSConstants.S_FALSE; }
/// <summary> /// AD7BoundBreakpoint constructor for file/line breaks. /// </summary> /// <param name="engine"> AD7 Engine. </param> /// <param name="bpReqInfo"> Contains the information required to implement a breakpoint. </param> /// <param name="pendingBreakpoint"> Associated pending breakpoint. </param> public AD7BoundBreakpoint(AD7Engine engine, BP_REQUEST_INFO bpReqInfo, AD7PendingBreakpoint pendingBreakpoint) { if (bpReqInfo.bpLocation.bpLocationType == (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE) { string documentName; // Get Decument Position and File Name IDebugDocumentPosition2 docPosition = (IDebugDocumentPosition2)(Marshal.GetObjectForIUnknown(bpReqInfo.bpLocation.unionmember2)); docPosition.GetFileName(out documentName); // Need to shorten the path we send to GDB. StringBuilder shortPath = new StringBuilder(1024); GetShortPathName(documentName, shortPath, shortPath.Capacity); // Get the location in the document that the breakpoint is in. TEXT_POSITION[] startPosition = new TEXT_POSITION[1]; TEXT_POSITION[] endPosition = new TEXT_POSITION[1]; docPosition.GetRange(startPosition, endPosition); m_engine = engine; m_bpLocationType = (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FILE_LINE; m_filename = shortPath.ToString(); m_line = startPosition[0].dwLine + 1; m_pendingBreakpoint = pendingBreakpoint; m_enabled = true; m_deleted = false; m_hitCount = 0; m_remoteID = m_engine.BPMgr.RemoteAdd(this); } else if (bpReqInfo.bpLocation.bpLocationType == (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FUNC_OFFSET) { string func; IDebugFunctionPosition2 funcPosition = (IDebugFunctionPosition2)(Marshal.GetObjectForIUnknown(bpReqInfo.bpLocation.unionmember2)); funcPosition.GetFunctionName(out func); m_engine = engine; m_func = func; m_enabled = true; m_deleted = false; m_hitCount = 0; m_bpLocationType = (uint)enum_BP_LOCATION_TYPE.BPLT_CODE_FUNC_OFFSET; m_pendingBreakpoint = pendingBreakpoint; m_remoteID = m_engine.BPMgr.RemoteAdd(this); } // if ((m_remoteID == 0) && (VSNDK.AddIn.VSNDKAddIn.isDebugEngineRunning == false)) if (m_remoteID == 0) { return; } // Set the hit count and condition if (bpReqInfo.bpPassCount.stylePassCount != enum_BP_PASSCOUNT_STYLE.BP_PASSCOUNT_NONE) { SetPassCount(bpReqInfo.bpPassCount); } if (bpReqInfo.bpCondition.styleCondition != enum_BP_COND_STYLE.BP_COND_NONE) { SetCondition(bpReqInfo.bpCondition); } // Get the Line Position sent back from GDB TEXT_POSITION tpos = new TEXT_POSITION(); tpos.dwLine = m_GDB_linePos - 1; uint xAddress = UInt32.Parse(m_GDB_Address.Substring(2), System.Globalization.NumberStyles.HexNumber); AD7MemoryAddress codeContext = new AD7MemoryAddress(m_engine, xAddress); AD7DocumentContext documentContext = new AD7DocumentContext(m_GDB_filename, tpos, tpos, codeContext); m_breakpointResolution = new AD7BreakpointResolution(m_engine, xAddress, documentContext); m_engine.Callback.OnBreakpointBound(this, 0); }