Example #1
0
        void TryBindBreakpoint(CSBindBreakpoint msg)
        {
            var domain = ds.AppDomain;
            SCBindBreakpointResult res = new Protocol.SCBindBreakpointResult();

            res.BreakpointHashCode = msg.BreakpointHashCode;
            IType type;

            if (domain.LoadedTypes.TryGetValue(msg.TypeName, out type))
            {
                if (type is ILType)
                {
                    ILType   it    = (ILType)type;
                    ILMethod found = null;
                    foreach (var i in it.GetMethods())
                    {
                        if (i.Name == msg.MethodName)
                        {
                            ILMethod ilm = (ILMethod)i;
                            if (ilm.StartLine <= (msg.StartLine + 1) && ilm.EndLine >= (msg.StartLine + 1))
                            {
                                found = ilm;
                                break;
                            }
                        }
                    }
                    if (found != null)
                    {
                        ds.SetBreakPoint(found.GetHashCode(), msg.BreakpointHashCode, msg.StartLine);
                        res.Result = BindBreakpointResults.OK;
                    }
                    else
                    {
                        res.Result = BindBreakpointResults.CodeNotFound;
                    }
                }
                else
                {
                    res.Result = BindBreakpointResults.TypeNotFound;
                }
            }
            else
            {
                res.Result = BindBreakpointResults.TypeNotFound;
            }
            SendSCBindBreakpointResult(res);
        }
Example #2
0
        void TryBindBreakpoint(CSBindBreakpoint msg)
        {
            var domain = ds.AppDomain;
            SCBindBreakpointResult res = new Protocol.SCBindBreakpointResult();

            res.BreakpointHashCode = msg.BreakpointHashCode;
            IType type;

            if (msg.IsLambda)
            {
                ILMethod found = null;
                foreach (var i in domain.LoadedTypes.ToArray())
                {
                    var vt = i.Value as ILType;
                    if (vt != null)
                    {
                        if (vt.FullName.Contains(msg.TypeName))
                        {
                            foreach (var j in vt.GetMethods())
                            {
                                if (j.Name.Contains(string.Format("<{0}>", msg.MethodName)))
                                {
                                    ILMethod ilm = (ILMethod)j;
                                    if (ilm.StartLine <= (msg.StartLine + 1) && ilm.EndLine >= (msg.StartLine + 1))
                                    {
                                        found = ilm;
                                        break;
                                    }
                                    else if (CheckCompilerGeneratedStateMachine(ilm, domain, msg.StartLine, out found))
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (found != null)
                    {
                        break;
                    }
                }
                if (found != null)
                {
                    ds.SetBreakPoint(found.GetHashCode(), msg.BreakpointHashCode, msg.StartLine, msg.Enabled, msg.Condition, msg.UsingInfos);
                    res.Result = BindBreakpointResults.OK;
                }
                else
                {
                    res.Result = BindBreakpointResults.CodeNotFound;
                }
            }
            else
            {
                if (domain.LoadedTypes.TryGetValue(msg.TypeName, out type))
                {
                    if (type is ILType)
                    {
                        ILType   it    = (ILType)type;
                        ILMethod found = null;
                        if (msg.MethodName == ".ctor")
                        {
                            foreach (var i in it.GetConstructors())
                            {
                                ILMethod ilm = (ILMethod)i;
                                if (ilm.StartLine <= (msg.StartLine + 1) && ilm.EndLine >= (msg.StartLine + 1))
                                {
                                    found = ilm;
                                    break;
                                }
                            }
                        }
                        else if (msg.MethodName == ".cctor")
                        {
                            ILMethod ilm = it.GetStaticConstroctor() as ILMethod;
                            if (ilm.StartLine <= (msg.StartLine + 1) && ilm.EndLine >= (msg.StartLine + 1))
                            {
                                found = ilm;
                            }
                        }
                        else
                        {
                            foreach (var i in it.GetMethods())
                            {
                                if (i.Name == msg.MethodName)
                                {
                                    ILMethod ilm = (ILMethod)i;
                                    if (ilm.StartLine <= (msg.StartLine + 1) && ilm.EndLine >= (msg.StartLine + 1))
                                    {
                                        found = ilm;
                                        break;
                                    }
                                    else if (CheckCompilerGeneratedStateMachine(ilm, domain, msg.StartLine, out found))
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                        if (found != null)
                        {
                            ds.SetBreakPoint(found.GetHashCode(), msg.BreakpointHashCode, msg.StartLine, msg.Enabled, msg.Condition, msg.UsingInfos);
                            res.Result = BindBreakpointResults.OK;
                        }
                        else
                        {
                            res.Result = BindBreakpointResults.CodeNotFound;
                        }
                    }
                    else
                    {
                        res.Result = BindBreakpointResults.TypeNotFound;
                    }
                }
                else
                {
                    res.Result = BindBreakpointResults.TypeNotFound;
                }
            }
            SendSCBindBreakpointResult(res);
        }