// Called by bound breakpoints when they are being deleted.
 public void OnBoundBreakpointDeleted(AD7BoundBreakpoint boundBreakpoint)
 {
     lock (m_boundBreakpoints)
     {
         m_boundBreakpoints.Remove(boundBreakpoint);
     }
 }
        // 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));
            }
        }
Exemplo n.º 3
0
        // Engines notify the debugger that a breakpoint has bound through the breakpoint bound event.
        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);
        }
Exemplo n.º 4
0
        internal void SetBreakpoint(uint address, AD7BoundBreakpoint bb)
        {
            if (address >= breakPointAddresses.Count)
            {
                return;
            }
            BreakPointAddress bpa = breakPointAddresses[(int)address];

            if (bpa != null)
            {
                bpa.boundbp = bb;
                ctx.AddBreakpoint(bpa.filectx, bpa.line, bpa.source);
                engineCallback.OnBreakpointBound(bb, bpa.id);
            }
            // Console.WriteLine("SetBreakpoint");
        }
Exemplo n.º 5
0
        internal void RemoveBreakpoint(uint address, AD7BoundBreakpoint bb)
        {
            if (address >= breakPointAddresses.Count)
            {
                return;
            }
            BreakPointAddress bpa = breakPointAddresses[(int)address];

            if (bpa != null)
            {
                breakPointAddresses[(int)address] = null;
                ctx.RemoveBreakpoint(bpa.filectx, bpa.line, bpa.source);
            }

            //Console.WriteLine("RemoveBreakpoint");
        }
Exemplo n.º 6
0
        internal void ToggleBreakpoint(uint address, AD7BoundBreakpoint bb, bool enable)
        {
            if (address >= breakPointAddresses.Count)
            {
                return;
            }
            BreakPointAddress bpa = breakPointAddresses[(int)address];

            if (bpa != null)
            {
                if (enable)
                {
                    ctx.AddBreakpoint(bpa.filectx, bpa.line, bpa.source);
                }
                else
                {
                    ctx.RemoveBreakpoint(bpa.filectx, bpa.line, bpa.source);
                }
            }

            //Console.WriteLine("RemoveBreakpoint");
        }
Exemplo n.º 7
0
 public AD7BreakpointBoundEvent(AD7PendingBreakpoint pendingBreakpoint, AD7BoundBreakpoint boundBreakpoint)
 {
     m_pendingBreakpoint = pendingBreakpoint;
     m_boundBreakpoint   = boundBreakpoint;
 }