public AD7BoundBreakpoint(AD7Engine engine, uint address, AD7PendingBreakpoint pendingBreakpoint, AD7BreakpointResolution breakpointResolution) { hitCount = 0; m_engine = engine; m_address = address; m_pendingBreakpoint = pendingBreakpoint; m_breakpointResolution = breakpointResolution; m_enabled = true; m_deleted = false; }
// Binds this pending breakpoint to one or more code locations. int IDebugPendingBreakpoint2.Bind() { try { if (CanBind()) { IDebugDocumentPosition2 docPosition = (IDebugDocumentPosition2)(Marshal.GetObjectForIUnknown(m_bpRequestInfo.bpLocation.unionmember2)); // Get the name of the document that the breakpoint was put in string documentName; EngineUtils.CheckOk(docPosition.GetFileName(out documentName)); // 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]; EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition)); // Ask the symbol engine to find all addresses in all modules with symbols that match this source and line number. uint[] addresses = m_engine.DebuggedProcess.GetAddressesForSourceLocation(null, documentName, startPosition[0].dwLine + 1, startPosition[0].dwColumn); lock (m_boundBreakpoints) { foreach (uint addr in addresses) { AD7BreakpointResolution breakpointResolution = new AD7BreakpointResolution(m_engine, addr, GetDocumentContext(addr)); AD7BoundBreakpoint boundBreakpoint = new AD7BoundBreakpoint(m_engine, addr, this, breakpointResolution); m_boundBreakpoints.Add(boundBreakpoint); m_engine.DebuggedProcess.SetBreakpoint(addr, boundBreakpoint); ((IDebugBoundBreakpoint2)boundBreakpoint).Enable(m_enabled ? 1 : 0); } } return(EngineConstants.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 sample 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(EngineConstants.S_FALSE); } } catch (ComponentException e) { return(e.HRESULT); } catch (Exception e) { return(EngineUtils.UnexpectedException(e)); } }