Example #1
0
        public AD7StackFrame(AD7Engine engine, AD7Thread thread, StackFrameInfo info, int index)
        {
            Engine = engine;
            uint tId;

            thread.GetThreadId(out tId);
            ThreadID            = (int)tId;
            this.Thread         = thread;
            this.StackFrameInfo = info;
            Index = index;

            _functionName = info.MethodName;
            if (info.LocalVariables != null)
            {
                localVars = new ILProperty[info.LocalVariables.Length];
                for (int i = 0; i < localVars.Length; i++)
                {
                    localVars[i] = new ILProperty(engine, thread, info.LocalVariables[i], this);
                    propertyMapping[info.LocalVariables[i].Name] = localVars[i];
                }
            }
            else
            {
                localVars = new ILProperty[0];
            }
            docContext = new AD7DocumentContext(info);
        }
Example #2
0
 public int EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback,
                         out IDebugProperty2 ppResult)
 {
     if (property != null)
     {
         ppResult = property;
         return(Constants.S_OK);
     }
     else
     {
         property = frame.Engine.DebuggedProcess.Resolve(frame, exp, dwTimeout) as ILProperty;
         ppResult = property;
         if (property != null)
         {
             if (string.IsNullOrEmpty(property.Name))
             {
                 property.Name = oriExp;
             }
             return(Constants.S_OK);
         }
         else
         {
             return(Constants.E_FAIL);
         }
     }
 }
Example #3
0
        ILProperty ResolveNameExpression(NameExpression exp, uint dwTimeout)
        {
            ILProperty res = null;

            if (frame.Properties.TryGetValue(exp.Content, out res))
            {
                return(res);
            }
            uint threadHash;

            frame.Thread.GetThreadId(out threadHash);

            if (exp.IsRoot)
            {
                var info = frame.Engine.DebuggedProcess.ResolveVariable(null, exp.Content, (int)threadHash, dwTimeout);
                if (info == null)
                {
                    info          = new VariableInfo();
                    info.Name     = exp.Content;
                    info.Value    = "null";
                    info.TypeName = "null";
                }
                res = new AD7.ILProperty(frame.Engine, frame.Thread, info);
            }
            else
            {
                var info = VariableInfo.FromObject(null);
                info.Type = VariableTypes.FieldReference;
                info.Name = exp.Content;
                res       = new ILProperty(frame.Engine, frame.Thread, info);
            }
            return(res);
        }
Example #4
0
        public int EnumChildren(enum_DEBUGPROP_INFO_FLAGS dwFields, uint dwRadix, ref Guid guidFilter,
                                enum_DBG_ATTRIB_FLAGS dwAttribFilter, string pszNameFilter, uint dwTimeout,
                                out IEnumDebugPropertyInfo2 ppEnum)
        {
            uint thId;

            thread.GetThreadId(out thId);
            var children = engine.DebuggedProcess.EnumChildren(GetVariableReference(), (int)thId, dwTimeout);

            DEBUG_PROPERTY_INFO[] info = new DEBUG_PROPERTY_INFO[children.Length];
            for (int i = 0; i < children.Length; i++)
            {
                var        vi   = children[i];
                ILProperty prop = new ILProperty(engine, thread, vi);
                if (vi.Type == VariableTypes.IndexAccess)
                {
                    prop.Parameters = new VariableReference[] { VariableReference.GetInteger(vi.Offset) }
                }
                ;
                prop.Parent = this;
                info[i]     = prop.GetDebugPropertyInfo(dwFields);
            }
            ppEnum = new AD7PropertyInfoEnum(info);
            return(Constants.S_OK);
        }
Example #5
0
 public AD7Expression(AD7Engine engine, ILProperty root, string[] names)
 {
     this.engine = engine;
     this.parent = root;
     this.names  = names;
     curIdx      = 1;
 }
Example #6
0
        ILProperty ResolveMemberAccessExpression(MemberAcessExpression exp, uint dwTimeout)
        {
            ILProperty body   = Resolve(exp.Body, dwTimeout);
            string     member = exp.Member;
            ILProperty prop;

            if (body != null)
            {
                if (!body.Children.TryGetValue(member, out prop))
                {
                    VariableReference reference = body.GetVariableReference();
                    if (reference != null)
                    {
                        uint threadHash;
                        frame.Thread.GetThreadId(out threadHash);

                        if (reference.Type < VariableTypes.Error)
                        {
                            if (exp.IsRoot)
                            {
                                var info = frame.Engine.DebuggedProcess.ResolveVariable(reference, member, (int)threadHash, dwTimeout);
                                prop                  = new AD7.ILProperty(frame.Engine, frame.Thread, info);
                                prop.Parent           = body;
                                body.Children[member] = prop;
                            }
                            else
                            {
                                var info = VariableInfo.FromObject(null);
                                info.Type   = VariableTypes.FieldReference;
                                info.Name   = member;
                                prop        = new ILProperty(frame.Engine, frame.Thread, info);
                                prop.Parent = body;
                            }
                        }
                        else if (reference.Type == VariableTypes.NotFound)
                        {
                            if (exp.IsRoot)
                            {
                                var info = frame.Engine.DebuggedProcess.ResolveVariable(null, reference.Name + "." + member, (int)threadHash, dwTimeout);
                                prop = new AD7.ILProperty(frame.Engine, frame.Thread, info);
                            }
                            else
                            {
                                var info = VariableInfo.FromObject(null);
                                info.Type = VariableTypes.FieldReference;
                                info.Name = reference.Name + "." + member;
                                prop      = new ILProperty(frame.Engine, frame.Thread, info);
                            }
                        }
                    }
                }
            }
            else
            {
                prop = new ILProperty(frame.Engine, frame.Thread, VariableInfo.NullReferenceExeption);
            }
            return(prop);
        }
Example #7
0
        public void DoResolve()
        {
            string member = names[curIdx];

            if (!parent.Children.TryGetValue(member, out parent))
            {
                VariableReference reference = parent.GetVariableReference();
                var info = engine.DebuggedProcess.ResolveVariable(reference, member);
                parent.Children[member] = new AD7.ILProperty(info);
            }
            curIdx++;
            if (curIdx < names.Length)
            {
                DoResolve();
            }
            else
            {
                property = parent;
            }
        }
Example #8
0
        public int ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr,
                             out string pbstrError, out uint pichError)
        {
            pbstrError = "";
            pichError  = 0;
            ppExpr     = null;
            string[]   names = pszCode.Split('.');
            ILProperty root  = null;

            if (!propertyMapping.TryGetValue(names[0], out root))
            {
                if (!propertyMapping.TryGetValue("this", out root))
                {
                    pbstrError = "Unsupported Expression";
                    pichError  = (uint)pbstrError.Length;
                    return(Constants.S_FALSE);
                }
            }

            if (names.Length < 2)
            {
                ppExpr = new AD7Expression(root);
                return(Constants.S_OK);
            }
            else
            {
                ppExpr = new AD7Expression(Engine, root, names);
                return(Constants.S_OK);
            }

            /*string lookup = pszCode;
             *
             *
             * LocalVariable result = ThreadContext.GetVisibleVariableByName(lookup);
             * if (result != null)
             * {
             *  ppExpr = new AD7Expression(new MonoProperty(ThreadContext, result));
             *  return VSConstants.S_OK;
             * }
             */
        }
Example #9
0
        public void DoResolve()
        {
            string     member = names[curIdx];
            ILProperty prop;

            if (!parent.Children.TryGetValue(member, out prop))
            {
                VariableReference reference = parent.GetVariableReference();
                if (reference != null)
                {
                    uint threadHash;
                    thread.GetThreadId(out threadHash);
                    var info = engine.DebuggedProcess.ResolveVariable(reference, member, (int)threadHash);
                    if (info == null)
                    {
                        info          = new VariableInfo();
                        info.Name     = member;
                        info.Value    = "null";
                        info.TypeName = "null";
                    }
                    prop = new AD7.ILProperty(info);
                }
                else
                {
                    prop = null;
                }
                parent.Children[member] = prop;
            }
            parent = prop;
            curIdx++;
            if (curIdx < names.Length && parent != null)
            {
                DoResolve();
            }
            else
            {
                resolved = true;
                property = parent;
            }
        }
Example #10
0
        public AD7StackFrame(AD7Engine engine, AD7Thread thread, StackFrameInfo info)
        {
            Engine              = engine;
            this.Thread         = thread;
            this.StackFrameInfo = info;

            _functionName = info.MethodName;
            if (info.LocalVariables != null)
            {
                localVars = new ILProperty[info.LocalVariables.Length];
                for (int i = 0; i < localVars.Length; i++)
                {
                    localVars[i] = new ILProperty(info.LocalVariables[i]);
                    propertyMapping[info.LocalVariables[i].Name] = localVars[i];
                }
            }
            else
            {
                localVars = new ILProperty[0];
            }
            docContext = new AD7DocumentContext(info);
        }
Example #11
0
 public AD7Expression(ILProperty property)
 {
     this.property = property;
 }
Example #12
0
        ILProperty ResolveIndexAccessExpression(IndexAccessExpression exp, uint dwTimeout)
        {
            ILProperty body = Resolve(exp.Body, dwTimeout);
            ILProperty prop = null;

            if (body != null)
            {
                VariableReference reference = body.GetVariableReference();
                if (reference != null)
                {
                    uint threadHash;
                    frame.Thread.GetThreadId(out threadHash);

                    if (reference.Type < VariableTypes.Error)
                    {
                        var idxExp            = exp.Index;
                        VariableReference idx = null;
                        if (idxExp is NameExpression)
                        {
                            int idxInt;
                            var content = ((NameExpression)idxExp).Content;
                            if (content == "true")
                            {
                                idx = VariableReference.True;
                            }
                            else if (content == "false")
                            {
                                idx = VariableReference.False;
                            }
                            else if (content == "null")
                            {
                                idx = VariableReference.Null;
                            }
                            else if (int.TryParse(content, out idxInt))
                            {
                                idx = VariableReference.GetInteger(idxInt);
                            }
                            else
                            {
                                var info = ResolveNameExpression((NameExpression)idxExp, dwTimeout);
                                idx = info.GetVariableReference();
                            }
                        }
                        else if (idxExp is StringLiteralExpression)
                        {
                            idx = VariableReference.GetString(((StringLiteralExpression)idxExp).Content);
                        }
                        else
                        {
                            var info = Resolve(idxExp, dwTimeout);
                            idx = info.GetVariableReference();
                        }
                        if (idx != null && idx.Type < VariableTypes.Error)
                        {
                            if (exp.IsRoot)
                            {
                                var info = frame.Engine.DebuggedProcess.ResolveIndexAccess(reference, idx, (int)threadHash, dwTimeout);
                                prop            = new AD7.ILProperty(frame.Engine, frame.Thread, info);
                                prop.Parent     = body;
                                prop.Parameters = new VariableReference[] { idx };
                            }
                            else
                            {
                                var info = VariableInfo.FromObject(null);
                                info.Type       = VariableTypes.IndexAccess;
                                prop            = new ILProperty(frame.Engine, frame.Thread, info);
                                prop.Parent     = body;
                                prop.Parameters = new VariableReference[] { idx };
                            }
                        }
                    }
                }
            }
            else
            {
                prop = new ILProperty(frame.Engine, frame.Thread, VariableInfo.NullReferenceExeption);
            }
            return(prop);
        }