Exemplo n.º 1
0
        protected override void OnEnableBreakEvent(object handle, bool enable)
        {
            CorBreakpoint bp = handle as CorFunctionBreakpoint;

            if (bp != null)
            {
                bp.Activate(enable);
            }
        }
Exemplo n.º 2
0
        protected override void OnEnableBreakEvent(BreakEventInfo binfo, bool enable)
        {
            CorBreakpoint bp = binfo.Handle as CorFunctionBreakpoint;

            if (bp != null)
            {
                bp.Activate(enable);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Locates MDbgBreakpoint object from the CorBreakpoint object.
 /// </summary>
 /// <param name="corBreakpoint">breakpoint object from CorXXX layer.</param>
 /// <returns>MDbgBreakpoint object</returns>
 /// <remarks>
 ///     returns null if there the breakpoint was not known to the breakpoint
 ///     collection.
 /// </remarks>
 public MDbgBreakpoint Lookup(CorBreakpoint corBreakpoint)
 {
     foreach (MDbgBreakpoint b in m_items)
     {
         foreach (CorBreakpoint cb in b.CorBreakpoints)
         {
             if (cb == corBreakpoint)
             {
                 return(b);
             }
         }
     }
     return(null);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CorBreakpointEventArgs"/> class.
 /// </summary>
 /// <param name="appdomain">The controller.</param>
 /// <param name="thread">The thread.</param>
 /// <param name="breakpoint">The breakpoint.</param>
 public CorBreakpointEventArgs(CorAppDomain appdomain, CorThread thread, CorBreakpoint breakpoint)
     : base(appdomain)
 {
     this.p_thread     = thread;
     this.p_breakpoint = breakpoint;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CorBreakpointEventArgs"/> class.
 /// </summary>
 /// <param name="appdomain">The controller.</param>
 /// <param name="thread">The thread.</param>
 /// <param name="breakpoint">The breakpoint.</param>
 public CorBreakpointEventArgs(CorAppDomain appdomain, CorThread thread, CorBreakpoint breakpoint)
     : base(appdomain, "Breakpoint")
 {
     Thread     = thread;
     Breakpoint = breakpoint;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Function tries to bind a breakpoint to the specified module.
        /// </summary>
        /// <param name="managedModule">A module the breakpoint should be bound to.</param>
        /// <returns>true if breakpoint was successfully bound or false if it failed or was already bound.</returns>
        /// <remarks>
        ///     This function is called by breakpoint manager for every brekapoint whenever a new module
        ///     gets loaded into the debugged process or whenever a dynamic module loads a new class
        ///     or new symbols. This adds any missing bindings, but will not duplicate any that already exist.
        /// </remarks>
        public sealed override bool BindToModule(MDbgModule managedModule)
        {
            MDbgFunction func;
            int          ILoffset;

            // Note that in some cases (eg. source/line breakpoints) we may actually
            // want to bind to multiple locations in this module instead of just one.
            if (!m_location.ResolveLocation(this, managedModule, out func, out ILoffset))
            {
                return(false);
            }

            if (m_breakpoints != null)
            {
                // Assume all breakpoints are CorFunctionBreakpoints.
                // If this ever becomes invalid, we'll need a new check here to avoid
                // duplicating that type of breakpoint.
                foreach (CorFunctionBreakpoint cb in m_breakpoints)
                {
                    // If we find a CorBreakpoint that already matches this location
                    // don't add a new one, or the debugger will stop twice when it's hit.
                    // Note that CorFunction instances are 1:1 with a specific function in a
                    // specific module and AppDomain (but represents all generic instantiations).
                    if (cb.Function == func.CorFunction && cb.Offset == ILoffset)
                    {
                        return(false);
                    }
                }
            }

            // Use the resolved information to get a raw CorBreakpoint object.
            CorBreakpoint breakpoint = null;

            try
            {
                if (ILoffset == 0)
                {
                    breakpoint = func.CorFunction.CreateBreakpoint();
                }
                else
                {
                    // we need to set a breakpoint on code rather than directly on function
                    CorCode code = func.CorFunction.ILCode;

                    if (code == null)
                    {
                        throw new MDbgException(String.Format(CultureInfo.InvariantCulture, "IL Code for function {0} is null", new Object[] { func.FullName }));
                    }
                    breakpoint = code.CreateBreakpoint(ILoffset);
                }
            }
            catch (COMException)
            {
                return(false);
            }

            // Add the new CorBreakpoint object to our internal list and register a handler for it.
            Debug.Assert(breakpoint != null);
            breakpoint.Activate(true);
            if (m_breakpoints == null)
            {
                m_breakpoints = new ArrayList();
            }
            m_breakpoints.Add(breakpoint);

            MDbgProcess p = managedModule.Process;
            CustomBreakpointEventHandler handler = new CustomBreakpointEventHandler(this.InternalOnHitHandler);

            p.RegisterCustomBreakpoint(breakpoint, handler);

            return(true);
        }