Ejemplo 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);
            }
        }
Ejemplo n.º 2
0
        internal List <BoundBreakpoint> BindAddresses(ResultValue bkpt)
        {
            List <BoundBreakpoint> resultList = new List <BoundBreakpoint>();

            if (bkpt == null)
            {
                return(resultList);
            }
            BoundBreakpoint bbp = null;

            if (bkpt is ValueListValue)
            {
                var list = (ValueListValue)bkpt;
                for (int i = 1; i < list.Content.Length; ++i)
                {
                    bbp = GetBoundBreakpoint(list.Content[i] as TupleValue);
                    if (bbp != null)
                    {
                        resultList.Add(bbp);
                    }
                }
            }
            else
            {
                _breakState = StringToBreakpointState(bkpt.TryFindString("addr"));
                bbp         = GetBoundBreakpoint(bkpt as TupleValue);
                if (bbp != null)
                {
                    resultList.Add(bbp);
                }
            }
            return(resultList);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Decode the mi results and create a bound breakpoint from it.
        /// </summary>
        /// <param name="bkpt">breakpoint description</param>
        /// <returns>null if breakpoint is pending</returns>
        private async Task <BoundBreakpoint> GetBoundBreakpoint(TupleValue bkpt)
        {
            string            addrString = bkpt.TryFindString("addr");
            MIBreakpointState state      = StringToBreakpointState(addrString);

            if (state == MIBreakpointState.Multiple)
            {
                // MI gives no way to find the set of addresses a breakpoint is bound to. So bind the breakpoint to address zero until hit.
                // When the breakpoint is hit can rebind to actual address.
                bkpt.Content.RemoveAll((keyval) => { return(keyval.Name == "addr"); });
                bkpt.Content.Add(new NamedResultValue("addr", new ConstValue("0")));
            }
            else if (state == MIBreakpointState.Pending)
            {
                return(null);
            }
            else if (!string.IsNullOrEmpty(addrString) && bkpt.FindAddr("addr") == BreakpointManager.INVALID_ADDRESS)
            {
                return(null);
            }

            var bbp = new BoundBreakpoint(this, bkpt);

            // On GDB, the returned line information is from the pending breakpoint instead of the bound breakpoint.
            // Check the address mapping to make sure the line info is correct.
            if (this.DebuggedProcess.MICommandFactory.Mode == MIMode.Gdb && !string.IsNullOrEmpty(bbp.CompiledFileName))
            {
                bbp.Line = await this.DebuggedProcess.LineForStartAddress(bbp.CompiledFileName, bbp.Addr);
            }

            return(bbp);
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
0
 public AD7BoundBreakpoint(AD7Engine engine, AD7PendingBreakpoint pendingBreakpoint, AD7BreakpointResolution breakpointResolution, BoundBreakpoint bp)
 {
     _engine               = engine;
     _pendingBreakpoint    = pendingBreakpoint;
     _breakpointResolution = breakpointResolution;
     _deleted              = false;
     _bp = bp;
 }
Ejemplo n.º 6
0
 public AD7BoundBreakpoint(AD7Engine engine, AD7PendingBreakpoint pendingBreakpoint, AD7BreakpointResolution breakpointResolution, BoundBreakpoint bp)
 {
     _engine = engine;
     _pendingBreakpoint = pendingBreakpoint;
     _breakpointResolution = breakpointResolution;
     _deleted = false;
     _bp = bp;
 }
Ejemplo n.º 7
0
 public AD7BoundBreakpoint(AD7Engine engine, ulong address, AD7PendingBreakpoint pendingBreakpoint, AD7BreakpointResolution breakpointResolution, BoundBreakpoint bp)
 {
     _engine = engine;
     Addr = address;
     _pendingBreakpoint = pendingBreakpoint;
     _breakpointResolution = breakpointResolution;
     _enabled = true;
     _deleted = false;
     _bp = bp;
 }
Ejemplo n.º 8
0
 public AD7BoundBreakpoint(AD7Engine engine, ulong address, AD7PendingBreakpoint pendingBreakpoint, AD7BreakpointResolution breakpointResolution, BoundBreakpoint bp)
 {
     _engine               = engine;
     Addr                  = address;
     _pendingBreakpoint    = pendingBreakpoint;
     _breakpointResolution = breakpointResolution;
     _enabled              = true;
     _deleted              = false;
     _bp = bp;
 }
Ejemplo n.º 9
0
        private static BindResult EvalBindWatchResult(Results bindResult, AD7PendingBreakpoint pbreak, string address, uint size)
        {
            string errormsg = "Unknown error";

            if (bindResult.ResultClass == ResultClass.error)
            {
                if (bindResult.Contains("msg"))
                {
                    errormsg = bindResult.FindString("msg");
                }
                if (String.IsNullOrWhiteSpace(errormsg))
                {
                    errormsg = "Unknown error";
                }
                return(new BindResult(errormsg));
            }
            else if (bindResult.ResultClass != ResultClass.done)
            {
                return(new BindResult(errormsg));
            }
            TupleValue bkpt = null;

            if (bindResult.Contains("wpt"))
            {
                ResultValue b = bindResult.Find("wpt");
                if (b is TupleValue)
                {
                    bkpt = b as TupleValue;
                }
            }
            else
            {
                return(new BindResult(errormsg));
            }

            string number = bkpt.FindString("number");

            PendingBreakpoint bp  = new PendingBreakpoint(pbreak, number, MIBreakpointState.Single);
            BoundBreakpoint   bbp = new BoundBreakpoint(bp, MICore.Debugger.ParseAddr(address), size);

            return(new BindResult(bp, bbp));
        }
Ejemplo n.º 10
0
 public BindResult(PendingBreakpoint bp, BoundBreakpoint boundBreakpoint)
     : this(bp)
 {
     _boundBreakpoints.Add(boundBreakpoint);
 }
Ejemplo n.º 11
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())
         {
             _boundBreakpoints.Add(boundBreakpoint);
             PendingBreakpoint.AddedBoundBreakpoint();
             _engine.Callback.OnBreakpointBound(boundBreakpoint);
         }
         else
         {
             boundBreakpoint.Delete();
         }
         return boundBreakpoint;
     }
 }
Ejemplo n.º 12
0
        private static BindResult EvalBindWatchResult(Results bindResult, AD7PendingBreakpoint pbreak, string address, uint size)
        {
            string errormsg = "Unknown error";
            if (bindResult.ResultClass == ResultClass.error)
            {
                if (bindResult.Contains("msg"))
                {
                    errormsg = bindResult.FindString("msg");
                }
                if (String.IsNullOrWhiteSpace(errormsg))
                {
                    errormsg = "Unknown error";
                }
                return new BindResult(errormsg);
            }
            else if (bindResult.ResultClass != ResultClass.done)
            {
                return new BindResult(errormsg);
            }
            TupleValue bkpt = null;
            if (bindResult.Contains("wpt"))
            {
                ResultValue b = bindResult.Find("wpt");
                if (b is TupleValue)
                {
                    bkpt = b as TupleValue;
                }
            }
            else
            {
                return new BindResult(errormsg);
            }

            string number = bkpt.FindString("number");

            PendingBreakpoint bp = new PendingBreakpoint(pbreak, number, MIBreakpointState.Single);
            BoundBreakpoint bbp = new BoundBreakpoint(bp, MICore.Debugger.ParseAddr(address), size);
            return new BindResult(bp, bbp);
        }
Ejemplo n.º 13
0
 public BindResult(PendingBreakpoint bp, BoundBreakpoint boundBreakpoint)
     : this(bp)
 {
     _boundBreakpoints.Add(boundBreakpoint);
 }
Ejemplo n.º 14
0
        private static BindResult EvalBindResult(Results bindResult, AD7PendingBreakpoint pbreak)
        {
            string errormsg = "Unknown error";

            if (bindResult.ResultClass == ResultClass.error)
            {
                if (bindResult.Contains("msg"))
                {
                    errormsg = bindResult.FindString("msg");
                }
                if (String.IsNullOrWhiteSpace(errormsg))
                {
                    errormsg = "Unknown error";
                }
                return(new BindResult(errormsg));
            }
            else if (bindResult.ResultClass != ResultClass.done)
            {
                return(new BindResult(errormsg));
            }
            TupleValue     bkpt = null;
            ValueListValue list = null;

            if (bindResult.Contains("bkpt"))
            {
                ResultValue b = bindResult.Find("bkpt");
                if (b is TupleValue)
                {
                    bkpt = b as TupleValue;
                }
                else if (b is ValueListValue)
                {
                    // "<MULTIPLE>" sometimes includes a list of bound breakpoints
                    list = b as ValueListValue;
                    bkpt = list.Content[0] as TupleValue;
                }
            }
            else
            {
                // If the source file is not found, "done" is the result without a binding
                // (the error is sent via an "&" string and hence lost)
                return(new BindResult(errormsg));
            }
            Debug.Assert(bkpt.FindString("type") == "breakpoint");

            string number  = bkpt.FindString("number");
            string warning = bkpt.TryFindString("warning");
            string addr    = bkpt.TryFindString("addr");

            PendingBreakpoint bp;

            if (!string.IsNullOrEmpty(warning))
            {
                Debug.Assert(string.IsNullOrEmpty(addr));
                return(new BindResult(new PendingBreakpoint(pbreak, number, MIBreakpointState.Pending), warning));
            }
            bp = new PendingBreakpoint(pbreak, number, StringToBreakpointState(addr));
            if (list == null)   // single breakpoint
            {
                BoundBreakpoint bbp = bp.GetBoundBreakpoint(bkpt);

                if (bbp == null)
                {
                    return(new BindResult(bp, MICoreResources.Status_BreakpointPending));
                }
                return(new BindResult(bp, bbp));
            }
            else   // <MULTIPLE> with list of addresses
            {
                BindResult res = new BindResult(bp);
                for (int i = 1; i < list.Content.Length; ++i)
                {
                    BoundBreakpoint bbp = bp.GetBoundBreakpoint(list.Content[i] as TupleValue);
                    res.BoundBreakpoints.Add(bbp);
                }
                return(res);
            }
        }
Ejemplo n.º 15
0
        internal static async Task <BindResult> Bind(string documentName, uint line, uint column, DebuggedProcess process, string condition, AD7PendingBreakpoint pbreak)
        {
            string  basename   = System.IO.Path.GetFileName(documentName);  // get basename from Windows path
            Results bindResult = await process.MICommandFactory.BreakInsert(process.EscapePath(basename), line, condition, ResultClass.None);

            string errormsg = "Unknown error";

            if (bindResult.ResultClass == ResultClass.error)
            {
                if (bindResult.Contains("msg"))
                {
                    errormsg = bindResult.FindString("msg");
                }
                if (String.IsNullOrWhiteSpace(errormsg))
                {
                    errormsg = "Unknown error";
                }
                return(new BindResult(errormsg));
            }
            else if (bindResult.ResultClass != ResultClass.done)
            {
                return(new BindResult(errormsg));
            }
            TupleValue     bkpt = null;
            ValueListValue list = null;

            if (bindResult.Contains("bkpt"))
            {
                ResultValue b = bindResult.Find("bkpt");
                if (b is TupleValue)
                {
                    bkpt = b as TupleValue;
                }
                else if (b is ValueListValue)
                {
                    // "<MULTIPLE>" sometimes includes a list of bound breakpoints
                    list = b as ValueListValue;
                    bkpt = list.Content[0] as TupleValue;
                }
            }
            else
            {
                // If the source file is not found, "done" is the result without a binding
                // (the error is sent via an "&" string and hence lost)
                return(new BindResult(errormsg));
            }
            Debug.Assert(bkpt.FindString("type") == "breakpoint");

            string number = bkpt.FindString("number");
            string addr   = bkpt.TryFindString("addr");

            PendingBreakpoint bp = new PendingBreakpoint(pbreak, number, StringToBreakpointState(addr));

            if (list == null)   // single breakpoint
            {
                BoundBreakpoint bbp = bp.GetBoundBreakpoint(bkpt);

                if (bbp == null)
                {
                    return(new BindResult(bp, MICoreResources.Status_BreakpointPending));
                }
                return(new BindResult(bp, bbp));
            }
            else   // <MULTIPLE> with list of addresses
            {
                BindResult res = new BindResult(bp);
                for (int i = 1; i < list.Content.Length; ++i)
                {
                    BoundBreakpoint bbp = bp.GetBoundBreakpoint(list.Content[i] as TupleValue);
                    res.BoundBreakpoints.Add(bbp);
                }
                return(res);
            }
        }