Esempio n. 1
0
        internal AD7BoundBreakpoint AddBoundBreakpoint(BoundBreakpoint bp)
        {
            lock (_boundBreakpoints)
            {
                if (!IsDataBreakpoint && _boundBreakpoints.Find((b) => b.Addr == bp.Addr) != null)
                {
                    return(null);   // already bound to this breakpoint
                }
                AD7BreakpointResolution breakpointResolution = new AD7BreakpointResolution(_engine, IsDataBreakpoint, bp.Addr, bp.FunctionName, bp.DocumentContext(_engine));
                AD7BoundBreakpoint      boundBreakpoint      = new AD7BoundBreakpoint(_engine, this, breakpointResolution, bp);
                //check can bind one last time. If the pending breakpoint was deleted before now, we need to clean up gdb side
                if (CanBind())
                {
                    foreach (var boundBp in _boundBreakpoints.Where((b) => b.Number.Equals(boundBreakpoint.Number, StringComparison.Ordinal)).ToList())
                    {
                        _engine.Callback.OnBreakpointUnbound(boundBp, enum_BP_UNBOUND_REASON.BPUR_BREAKPOINT_REBIND);
                        _boundBreakpoints.Remove(boundBp);
                    }

                    _boundBreakpoints.Add(boundBreakpoint);
                    PendingBreakpoint.AddedBoundBreakpoint();
                    _engine.Callback.OnBreakpointBound(boundBreakpoint);
                }
                else
                {
                    boundBreakpoint.Delete();
                }
                return(boundBreakpoint);
            }
        }
Esempio n. 2
0
        internal AD7BoundBreakpoint AddBoundBreakpoint(BoundBreakpoint bp)
        {
            lock (_boundBreakpoints)
            {
                if (_boundBreakpoints.Find((b) => b.Addr == bp.Addr) != null)
                {
                    return(null);   // already bound to this breakpoint
                }
                AD7BreakpointResolution breakpointResolution = new AD7BreakpointResolution(_engine, bp.Addr, bp.FunctionName, bp.DocumentContext(_engine));
                AD7BoundBreakpoint      boundBreakpoint      = new AD7BoundBreakpoint(_engine, bp.Addr, this, breakpointResolution, bp);

                //check can bind one last time. If the pending breakpoint was deleted before now, we need to clean up gdb side
                if (CanBind())
                {
                    _boundBreakpoints.Add(boundBreakpoint);
                    PendingBreakpoint.AddedBoundBreakpoint();
                    _engine.Callback.OnBreakpointBound(boundBreakpoint);
                }
                else
                {
                    boundBreakpoint.Delete();
                }
                return(boundBreakpoint);
            }
        }
Esempio n. 3
0
        // Engines notify the debugger that a breakpoint has bound through the breakpoint bound event.
        public void OnBreakpointBound(object objBoundBreakpoint)
        {
            AD7BoundBreakpoint       boundBreakpoint = (AD7BoundBreakpoint)objBoundBreakpoint;
            IDebugPendingBreakpoint2 pendingBreakpoint;

            ((IDebugBoundBreakpoint2)boundBreakpoint).GetPendingBreakpoint(out pendingBreakpoint);

            AD7BreakpointBoundEvent eventObject = new AD7BreakpointBoundEvent((AD7PendingBreakpoint)pendingBreakpoint, boundBreakpoint);

            Send(eventObject, AD7BreakpointBoundEvent.IID, null);
        }
 internal AD7BoundBreakpoint AddBoundBreakpoint(BoundBreakpoint bp)
 {
     lock (_boundBreakpoints)
     {
         if (!IsDataBreakpoint && _boundBreakpoints.Find((b) => b.Addr == bp.Addr) != null)
         {
             return null;   // already bound to this breakpoint
         }
         AD7BreakpointResolution breakpointResolution = new AD7BreakpointResolution(_engine, IsDataBreakpoint, bp.Addr, bp.FunctionName, bp.DocumentContext(_engine));
         AD7BoundBreakpoint boundBreakpoint = new AD7BoundBreakpoint(_engine, this, breakpointResolution, bp);
         //check can bind one last time. If the pending breakpoint was deleted before now, we need to clean up gdb side
         if (CanBind())
         {
             _boundBreakpoints.Add(boundBreakpoint);
             PendingBreakpoint.AddedBoundBreakpoint();
             _engine.Callback.OnBreakpointBound(boundBreakpoint);
         }
         else
         {
             boundBreakpoint.Delete();
         }
         return boundBreakpoint;
     }
 }
Esempio n. 5
0
 public AD7BreakpointBoundEvent(AD7PendingBreakpoint pendingBreakpoint, AD7BoundBreakpoint boundBreakpoint)
 {
     _pendingBreakpoint = pendingBreakpoint;
     _boundBreakpoint   = boundBreakpoint;
 }
Esempio n. 6
0
 public AD7BreakpointUnboundEvent(AD7BoundBreakpoint bp, enum_BP_UNBOUND_REASON reason)
 {
     _reason = reason;
     _bp     = bp;
 }
Esempio n. 7
0
        private AD7PendingBreakpoint BindToAddress(string bkptno, ulong addr, /*OPTIONAL*/ TupleValue frame, out AD7BoundBreakpoint bbp)
        {
            bbp = null;
            AD7PendingBreakpoint pending = CodeBreakpoints.FirstOrDefault((p) => { return(p.BreakpointId == bkptno); });

            if (pending == null)
            {
                return(null);
            }
            // the breakpoint number is known, check to see if it is known to be bound to this address
            bbp = Array.Find(pending.EnumBoundBreakpoints(), (b) => b.Addr == addr);
            if (bbp == null)
            {
                // add this address as a bound breakpoint
                bbp = Array.Find(pending.EnumBoundBreakpoints(), (b) => b.Addr == 0);
                if (bbp != null)    // <MULTIPLE>
                {
                    bbp.UpdateAddr(addr);
                }
                else
                {
                    bbp = pending.AddBoundBreakpoint(new BoundBreakpoint(pending.PendingBreakpoint, addr, frame));
                }
            }
            return(pending);
        }
Esempio n. 8
0
 private AD7PendingBreakpoint BindToAddress(string bkptno, ulong addr, /*OPTIONAL*/ TupleValue frame, out AD7BoundBreakpoint bbp)
 {
     bbp = null;
     AD7PendingBreakpoint pending = CodeBreakpoints.FirstOrDefault((p) => { return p.BreakpointId == bkptno; });
     if (pending == null)
     {
         return null;
     }
     // the breakpoint number is known, check to see if it is known to be bound to this address
     bbp = Array.Find(pending.EnumBoundBreakpoints(), (b) => b.Addr == addr);
     if (bbp == null)
     {
         // add this address as a bound breakpoint
         bbp = Array.Find(pending.EnumBoundBreakpoints(), (b) => b.Addr == 0);
         if (bbp != null)    // <MULTIPLE>
         {
             bbp.UpdateAddr(addr);
         }
         else
         {
             bbp = pending.AddBoundBreakpoint(new BoundBreakpoint(pending.PendingBreakpoint, addr, frame));
         }
     }
     return pending;
 }
Esempio n. 9
0
 public AD7BreakpointBoundEvent(AD7PendingBreakpoint pendingBreakpoint, AD7BoundBreakpoint boundBreakpoint)
 {
     _pendingBreakpoint = pendingBreakpoint;
     _boundBreakpoint = boundBreakpoint;
 }
Esempio n. 10
0
 public AD7BreakpointUnboundEvent(AD7BoundBreakpoint bp, enum_BP_UNBOUND_REASON reason)
 {
     _reason = reason;
     _bp = bp;
 }
Esempio n. 11
0
        // Engines notify the SDM that a bound breakpoint change resulted in an error
        public void OnBreakpointUnbound(AD7BoundBreakpoint bp, enum_BP_UNBOUND_REASON reason)
        {
            AD7BreakpointUnboundEvent eventObject = new AD7BreakpointUnboundEvent(bp, reason);

            Send(eventObject, AD7BreakpointUnboundEvent.IID, null);
        }
Esempio n. 12
0
        private async Task HandleBreakModeEvent(ResultEventArgs results)
        {
            string reason = results.Results.TryFindString("reason");
            int    tid;

            if (!results.Results.Contains("thread-id"))
            {
                Results res = await MICommandFactory.ThreadInfo();

                tid = res.FindInt("id");
            }
            else
            {
                tid = results.Results.FindInt("thread-id");
            }

            ThreadCache.MarkDirty();
            MICommandFactory.DefineCurrentThread(tid);

            DebuggedThread thread = await ThreadCache.GetThread(tid);

            await ThreadCache.StackFrames(thread);  // prepopulate the break thread in the thread cache

            ThreadContext cxt = await ThreadCache.GetThreadContext(thread);

            ThreadCache.SendThreadEvents(this, null);   // make sure that new threads have been pushed to the UI

            //always delete breakpoints pending deletion on break mode
            //the flag tells us if we hit an existing breakpoint pending deletion that we need to continue

            await _breakpointManager.DeleteBreakpointsPendingDeletion();

            //delete varialbes that have been GC'd
            List <string> variablesToDelete = new List <string>();

            lock (VariablesToDelete)
            {
                foreach (var variable in VariablesToDelete)
                {
                    variablesToDelete.Add(variable);
                }
                VariablesToDelete.Clear();
            }

            foreach (var variable in variablesToDelete)
            {
                try
                {
                    await MICommandFactory.VarDelete(variable);
                }
                catch (MIException)
                {
                    //not much to do really, we're leaking MI debugger variables.
                    Debug.Fail("Failed to delete variable: " + variable + ". This is leaking memory in the MI Debugger.");
                }
            }

            if (String.IsNullOrWhiteSpace(reason) && !_bEntrypointHit)
            {
                // CLRDBG TODO: Try to verify this code path
                _bEntrypointHit = true;
                CmdContinueAsync();
                FireDeviceAppLauncherResume();
            }
            else if (reason == "breakpoint-hit")
            {
                string             bkptno = results.Results.FindString("bkptno");
                ulong              addr   = cxt.pc ?? 0;
                AD7BoundBreakpoint bkpt   = null;
                bool       fContinue;
                TupleValue frame = results.Results.TryFind <TupleValue>("frame");
                bkpt = _breakpointManager.FindHitBreakpoint(bkptno, addr, frame, out fContinue); // use breakpoint number to resolve breakpoint
                if (bkpt != null)
                {
                    List <object> bplist = new List <object>();
                    bplist.Add(bkpt);
                    _callback.OnBreakpoint(thread, bplist.AsReadOnly());
                }
                else if (!_bEntrypointHit)
                {
                    _bEntrypointHit = true;
                    _callback.OnEntryPoint(thread);
                }
                else
                {
                    if (fContinue)
                    {
                        //we hit a bp pending deletion
                        //post the CmdContinueAsync operation so it does not happen until we have deleted all the pending deletes
                        CmdContinueAsync();
                    }
                    else
                    {
                        // not one of our breakpoints, so stop with a message
                        _callback.OnException(thread, "Unknown breakpoint", "", 0);
                    }
                }
            }
            else if (reason == "end-stepping-range" || reason == "function-finished")
            {
                _callback.OnStepComplete(thread);
            }
            else if (reason == "signal-received")
            {
                string name = results.Results.TryFindString("signal-name");
                if ((name == "SIG32") || (name == "SIG33"))
                {
                    // we are going to ignore these (Sigma) signals for now
                    CmdContinueAsync();
                }
                else if (MICommandFactory.IsAsyncBreakSignal(results.Results))
                {
                    _callback.OnAsyncBreakComplete(thread);
                }
                else
                {
                    uint   code    = 0;
                    string sigName = results.Results.TryFindString("signal-name");
                    code = results.Results.Contains("signal") ? results.Results.FindUint("signal") : 0;
                    if (String.IsNullOrEmpty(sigName) && code != 0 && EngineUtils.SignalMap.Instance.ContainsValue(code))
                    {
                        sigName = EngineUtils.SignalMap.Instance.First((p) => p.Value == code).Key;
                    }
                    else if (!String.IsNullOrEmpty(sigName) && code == 0 && EngineUtils.SignalMap.Instance.ContainsKey(sigName))
                    {
                        code = EngineUtils.SignalMap.Instance[sigName];
                    }
                    _callback.OnException(thread, sigName, results.Results.TryFindString("signal-meaning"), code);
                }
            }
            else if (reason == "exception-received")
            {
                string exception = results.Results.FindString("exception");
                _callback.OnException(thread, "Exception", exception, 0);
            }
            else
            {
                Debug.Fail("Unknown stopping reason");
                _callback.OnException(thread, "Unknown", "Unknown stopping event", 0);
            }
        }
Esempio n. 13
0
 // Engines notify the SDM that a bound breakpoint change resulted in an error
 public void OnBreakpointUnbound(AD7BoundBreakpoint bp, enum_BP_UNBOUND_REASON reason)
 {
     AD7BreakpointUnboundEvent eventObject = new AD7BreakpointUnboundEvent(bp, reason);
     Send(eventObject, AD7BreakpointUnboundEvent.IID, null);
 }