Ejemplo n.º 1
0
        ObjectValue CreateObjectValue(string name, DebugEngineWrapper.DebugScopedSymbol symbol)
        {
            string vname    = symbol.Name;
            string typeName = symbol.TypeName;
            string value    = symbol.TextValue;
            int    nchild   = (int)symbol.ChildrenCount;

            ObjectValue      val;
            ObjectValueFlags flags = ObjectValueFlags.Variable;

            // There can be 'public' et al children for C++ structures
            if (typeName == null)
            {
                typeName = "none";
            }

            val      = ObjectValue.CreatePrimitive(this, new ObjectPath(vname), typeName, new EvaluationResult(value), flags);
            val.Name = name;
            return(val);

            /*
             *          if (typeName.EndsWith ("]")) {
             *                  val = ObjectValue.CreateArray (this, new ObjectPath (vname), typeName, nchild, flags, null);
             *          } else if (value == "{...}" || typeName.EndsWith ("*") || nchild > 0) {
             *                  val = ObjectValue.CreateObject (this, new ObjectPath (vname), typeName, value, flags, null);
             *          } else {
             *                  val = ObjectValue.CreatePrimitive (this, new ObjectPath (vname), typeName, new EvaluationResult (value), flags);
             *          }
             *          val.Name = name;
             */

            return(val);
        }
Ejemplo n.º 2
0
        ObjectValue CreateObjectValue(string name, DebugEngineWrapper.DebugScopedSymbol symbol)
        {
            string vname    = symbol.Name;
            string typeName = symbol.TypeName;
            string value    = symbol.TextValue;
            int    nchild   = (int)symbol.ChildrenCount;

            ObjectValue val = symbolResolver.Resolve(symbol.Offset, vname, typeName, value, symbol.Parent);

            if (val == null)
            {
                ObjectValueFlags flags = ObjectValueFlags.Variable;

                // There can be 'public' et al children for C++ structures
                if (typeName == null)
                {
                    typeName = "none";
                }

                val      = ObjectValue.CreatePrimitive(this, new ObjectPath(vname), typeName, new EvaluationResult(value), flags);
                val.Name = name;
            }

            return(val);
        }
 private AbstractType[] ResolveParentSymbol(DEW.DebugScopedSymbol parentsymbol, ResolutionContext ctxt)
 {
     if (parentsymbol.Parent != null)
     {
         return(TypeDeclarationResolver.ResolveFurtherTypeIdentifier(parentsymbol.Name, ResolveParentSymbol(parentsymbol.Parent, ctxt), ctxt, null));
     }
     else
     {
         return(TypeDeclarationResolver.ResolveIdentifier(parentsymbol.Name, ctxt, null));
     }
 }
            public DObjectValue(DEW.DebugScopedSymbol symb, PlainDbgEngBasedBacktrace backtrace)
            {
                this.Backtrace = backtrace;
                Symbol         = symb;

                /*var type = symb.TypeName.Replace('@','.');
                 * if (type.StartsWith("class"))
                 *      type = type.Substring(5);
                 * if (!string.IsNullOrWhiteSpace(type))
                 *      DType = DParser.ParseBasicType(type);*/
            }
Ejemplo n.º 5
0
        public ObjectValue[] GetChildren(ObjectPath path, int index, int count, EvaluationOptions options)
        {
            List <ObjectValue> children = new List <ObjectValue>();

            session.SelectThread(threadId);

            if (Engine.Symbols.ScopeLocalSymbols == null)
            {
                return(children.ToArray());
            }

            DEW.DebugScopedSymbol parent = null;

            for (uint i = 0; i < Engine.Symbols.ScopeLocalSymbols.Symbols.Length; i++)
            {
                DEW.DebugScopedSymbol symbol = Engine.Symbols.ScopeLocalSymbols.Symbols[i];
                if (symbol.Name == path.LastName)
                {
                    parent = symbol;
                    break;
                }
            }

            if (parent == null || parent.ChildrenCount == 0)
            {
                return(children.ToArray());
            }

            for (uint i = 0; i < parent.ChildrenCount; i++)
            {
                DEW.DebugScopedSymbol child = parent.Children[i];

                string name     = child.Name;
                string typename = child.TypeName;
                string val      = child.TextValue;
                ulong  offset   = child.Offset;

                ObjectValue ov = symbolResolver.Resolve(offset, name, typename, val, child.Parent);
                if (ov == null)
                {
                    ObjectValueFlags flags = ObjectValueFlags.Variable;
                    ov = ObjectValue.CreatePrimitive(this, new ObjectPath(name), typename, new EvaluationResult(val), flags);
                }

                if (ov != null)
                {
                    children.Add(ov);
                }
            }

            return(children.ToArray());
        }
Ejemplo n.º 6
0
        ObjectValue CreateVarObject(string exp)
        {
            try
            {
                session.SelectThread(threadId);

                //DebugEngineWrapper.DebugSymbolData[] datasymbols = Engine.Symbols.GetSymbols("*");

                var rootSymbols = Array.FindAll <DEW.DebugScopedSymbol>(Engine.Symbols.ScopeLocalSymbols.Symbols, (a) => (a.Parent == null));
                DEW.DebugScopedSymbol foundSymbol = FindScopedSymbol(exp, rootSymbols);

                if (foundSymbol != null)
                {
                    session.RegisterTempVariableObject(exp);
                    return(CreateObjectValue(exp, foundSymbol));
                }
                return(ObjectValue.CreateUnknown(exp));
            }
            catch
            {
                return(ObjectValue.CreateUnknown(exp));
            }
        }
Ejemplo n.º 7
0
        public ObjectValue[] GetLocalVariables(int frameIndex, EvaluationOptions options)
        {
            List <ObjectValue> values = new List <ObjectValue>();

            if (Engine.Symbols.ScopeLocalSymbols == null)
            {
                return(values.ToArray());
            }

            for (uint i = 0; i < Engine.Symbols.ScopeLocalSymbols.Count; i++)
            {
                if (Engine.Symbols.ScopeLocalSymbols.Symbols[i].Parent != null)
                {
                    continue;
                }

                string name     = Engine.Symbols.ScopeLocalSymbols.Symbols[i].Name;
                string typename = Engine.Symbols.ScopeLocalSymbols.Symbols[i].TypeName;
                string val      = Engine.Symbols.ScopeLocalSymbols.Symbols[i].TextValue;
                ulong  offset   = Engine.Symbols.ScopeLocalSymbols.Symbols[i].Offset;
                DEW.DebugScopedSymbol parentSymbol = Engine.Symbols.ScopeLocalSymbols.Symbols[i].Parent;

                ObjectValue ov = symbolResolver.Resolve(offset, name, typename, val, parentSymbol);
                if (ov == null)
                {
                    ObjectValueFlags flags = ObjectValueFlags.Variable;
                    ov = ObjectValue.CreatePrimitive(this, new ObjectPath(name), typename, new EvaluationResult(val), flags);
                }

                if (ov != null)
                {
                    values.Add(ov);
                }
            }
            return(values.ToArray());
        }
			public DObjectValue(DEW.DebugScopedSymbol symb, PlainDbgEngBasedBacktrace backtrace)
			{
				this.Backtrace = backtrace;
				Symbol = symb;

				/*var type = symb.TypeName.Replace('@','.');
				if (type.StartsWith("class"))
					type = type.Substring(5);
				if (!string.IsNullOrWhiteSpace(type))
					DType = DParser.ParseBasicType(type);*/
			}
        public ObjectValue Resolve(ulong offset, string symbolname, string typename, string val, DEW.DebugScopedSymbol parentsymbol)
        {
            DModule module;
            int     codeLine;
            INode   variableNode = null;

            // Search currently scoped module
            string file = "";
            uint   line = 0;

            Engine.Symbols.GetLineByOffset(Engine.CurrentInstructionOffset, out file, out line);
            codeLine = (int)line;

            if (string.IsNullOrWhiteSpace(file))
            {
                return(null);
            }

            AbstractDProject dproj = null;

            module = GetFileSyntaxTree(file, out dproj);

            // If syntax tree built, search the variable location
            if (module != null)
            {
                var ed   = Resolver.DResolverWrapper.CreateEditorData(IdeApp.Workbench.ActiveDocument);
                var ctxt = ResolutionContext.Create(ed, false);

                CodeCompletion.DoTimeoutableCompletionTask(null, ctxt, () =>
                {
                    var loc = new CodeLocation(0, codeLine);
                    ctxt.Push(DResolver.SearchBlockAt(module, loc), loc);

                    AbstractType[] res;
                    if (parentsymbol != null)
                    {
                        var parentres = ResolveParentSymbol(parentsymbol, ctxt);
                        res           = TypeDeclarationResolver.ResolveFurtherTypeIdentifier(symbolname, parentres, ctxt, null);
                    }
                    else
                    {
                        res = TypeDeclarationResolver.ResolveIdentifier(symbolname, ctxt, null);
                    }

                    if (res != null && res.Length > 0 && res[0] is DSymbol)
                    {
                        variableNode = (res[0] as DSymbol).Definition;
                    }
                });
            }

            // Set type string
            string _typeString = typename;

            if (variableNode != null)
            {
                var t = variableNode.Type;
                if (t != null)
                {
                    _typeString = t.ToString();
                }
            }

            // Set value string
            string _valueString = val;

            ObjectValueFlags flags = ObjectValueFlags.Variable;

            if (variableNode != null)
            {
                ITypeDeclaration curValueType = variableNode.Type;
                if (curValueType != null)
                {
                    if (!IsBasicType(curValueType))
                    {
                        if (_typeString == "string")                         //TODO: Replace this by searching the alias definition in the cache
                        {
                            curValueType = new ArrayDecl()
                            {
                                InnerDeclaration = new DTokenDeclaration(DTokens.Char)
                            }
                        }
                        ;
                        else if (_typeString == "wstring")
                        {
                            curValueType = new ArrayDecl()
                            {
                                InnerDeclaration = new DTokenDeclaration(DTokens.Wchar)
                            }
                        }
                        ;
                        else if (_typeString == "dstring")
                        {
                            curValueType = new ArrayDecl()
                            {
                                InnerDeclaration = new DTokenDeclaration(DTokens.Dchar)
                            }
                        }
                        ;

                        if (IsArray(curValueType))
                        {
                            flags = ObjectValueFlags.Array;

                            var clampDecl = curValueType as ArrayDecl;
                            var valueType = clampDecl.InnerDeclaration;

                            if (valueType is DTokenDeclaration)
                            {
                                bool IsString = false;
                                uint elsz     = 0;
                                var  realType = DetermineArrayType((valueType as DTokenDeclaration).Token, out elsz, out IsString);

                                var arr = Engine.Symbols.ReadArray(offset, realType, elsz);

                                if (arr != null)
                                {
                                    _valueString = BuildArrayContentString(arr, IsString);
                                }
                            }
                        }
                        else
                        {
                            flags = ObjectValueFlags.Object;
                        }
                    }
                }
            }

            return(ObjectValue.CreatePrimitive(ObjectValueSource, new ObjectPath(symbolname), _typeString, new EvaluationResult(_valueString), flags));
        }
 public ObjectValue Resolve(DEW.DebugScopedSymbol symbol)
 {
     return(Resolve(symbol.Offset, symbol.Name, symbol.TypeName, symbol.TextValue, symbol.Parent));
 }