deleteVar() публичный Метод

Deletes a previously created variable object and all of its children.
public deleteVar ( string name, bool hasVsNdK_ ) : void
name string Name of the variable.
hasVsNdK_ bool Boolean value that indicates if the variable name has the prefix VsNdK_.
Результат void
Пример #1
0
        /// <summary>
        /// Constructor for Variable Info Object
        /// </summary>
        /// <param name="name">The name of the variable</param>
        /// <param name="type">The data type of the variable</param>
        /// <param name="baseType">The base type of the variable.</param>
        /// <param name="value">The value of the variable</param>
        /// <param name="dispatcher">The event dispatcher</param>
        /// <param name="GDBNames">The GDBNames of the children</param>
        /// <param name="VSNames">The VS Names of the children</param>
        /// <param name="level">The currrent evaluation level</param>
        public VariableInfo(string name, string type, string baseType, string value, EventDispatcher dispatcher, ArrayList GDBNames, ArrayList VSNames)
        {
            /// numChildren - The result of the createvar returns ERROR or a number 0-n where n is the number of children of the variable.
            string numChildren = "";

            _name = name;
            _exp = null;
            _type = type;
            _value = value;
            _children = null;
            _GDBName = null;

            if (baseType != "")
                type = baseType;

            if (GDBNames == null)
            {
                GDBNames = new ArrayList();
                VSNames = new ArrayList();
            }

            if (value == null || (type.Contains("*") && (value != "0x0")))
            {
                // This is an array, struct, union, or pointer.
                // Create a variable object so we can list this variable's children.
                bool hasVsNdK_ = false;

                numChildren = dispatcher.createVar(_name, ref hasVsNdK_);

                if (hasVsNdK_)
                {
                    _GDBName = "VsNdK_" + _name;
                    GDBNames.Add("VsNdK_" + _name);
                    VSNames.Add(_name);
                }

                try // Catch non-numerical data
                {
                    if (Convert.ToInt32(numChildren) > 0) // If the variable has children evaluate
                    {
                        _children = new ArrayList();
                        if (type.Contains("struct"))
                            if (type[type.Length - 1] == '*')
                                this.listChildren(dispatcher, "*", GDBNames, VSNames, hasVsNdK_, null);
                            else if (type.Contains("["))
                                this.listChildren(dispatcher, "struct[]", GDBNames, VSNames, hasVsNdK_, null);
                            else
                                this.listChildren(dispatcher, "struct", GDBNames, VSNames, hasVsNdK_, null);
                        else if (type.Contains("["))
                            this.listChildren(dispatcher, "[]", GDBNames, VSNames, hasVsNdK_, null);
                        else if (type.Contains("*"))
                            this.listChildren(dispatcher, "*", GDBNames, VSNames, hasVsNdK_, null);
                        else
                            this.listChildren(dispatcher, "", GDBNames, VSNames, hasVsNdK_, null);
                    }
                }
                catch (FormatException e)
                {

                }

                dispatcher.deleteVar(_name, hasVsNdK_);
            }

            if (value == null)
                evaluateExpression(name, ref _value, null);
        }
Пример #2
0
        public static VariableInfo get(string name, EventDispatcher m_eventDispatcher, AD7StackFrame m_frame)
        {
            VariableInfo vi = null;
            string search = "";
            string separator = "";
            bool isArray = false;
            bool isRoot = true;

            do
            {
                int dot = name.IndexOf(".");
                int squareBracket = name.IndexOf("[");
                int pos = name.IndexOf("->");
                if (dot == -1)
                    dot = name.Length;
                if (squareBracket == -1)
                    squareBracket = name.Length;
                if (pos == -1)
                    pos = name.Length;
                int stop = dot < squareBracket ? dot : squareBracket;
                stop = stop < pos ? stop : pos;

                search = search + separator + name.Substring(0, stop);
                separator = "";

                if (stop < name.Length)
                {
                    separator = name.Substring(stop, 1);
                    if (separator == "-")
                    {
                        separator = "->";
                        name = name.Substring(stop + 2, name.Length - (stop + 2));
                    }
                    else if (separator == "[")
                    {
                        int aux = name.IndexOf("]");
                        isArray = true;
                        separator = name.Substring(stop, (aux - stop) + 1);
                        name = name.Substring(aux + 1, name.Length - (aux + 1));
                    }
                    else
                        name = name.Substring(stop + 1, name.Length - (stop + 1));
                }
                else
                    name = "";

                if (vi == null)
                {
                    if (m_frame._locals != null)
                    {
                        foreach (VariableInfo var in m_frame._locals)
                        {
                            if (var._name == search)
                            {
                                vi = var;
                                break;
                            }
                        }
                    }

                    if (vi == null)
                    {
                        if (m_frame._arguments != null)
                        {
                            foreach (VariableInfo var in m_frame._arguments)
                            {
                                if (var._name == search)
                                {
                                    vi = var;
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    isRoot = false;
                    VariableInfo vi_child = null;
                    if (vi._children != null)
                    {
                        foreach (VariableInfo var in vi._children)
                        {
                            if (var._name == search)
                            {
                                vi_child = var;
                                break;
                            }
                        }
                    }
                    vi = vi_child;
                }
            } while ((vi != null) && ((isArray) || (name != "")));

            if (name != "") // variable not found probably because it is in an expression, so return to the original name to evaluate it.
                search = search + separator + name;

            string result = "";
            bool valid;
            if (vi == null)
                valid = evaluateExpression(search, ref result, null);
            else
                valid = evaluateExpression(search, ref result, vi._GDBName);

            if (vi != null)
            {
                if ((vi._value != result) || (!isRoot))  // if is not root means that it can be expanded...
                {
                    vi._value = result;
                    if (vi._value == null || (vi._type.Contains("*") && (vi._value != "0x0")))
                    {
                        // This is an array, struct, union, or pointer.
                        // Create a variable object so we can list this variable's children.
                        ArrayList GDBNames = new ArrayList();
                        ArrayList VSNames = new ArrayList();
                        bool hasVsNdK_ = false;
                        m_eventDispatcher.createVar(vi._name, ref hasVsNdK_);
                        if (hasVsNdK_)
                        {
                            GDBNames.Add("VsNdK_" + vi._name);
                            VSNames.Add(vi._name);
                        }
                        vi._children = new ArrayList();
                        if (vi._type.Contains("struct"))
                            if (vi._type[vi._type.Length - 1] == '*')
                                vi.listChildren(m_eventDispatcher, "*", GDBNames, VSNames, hasVsNdK_, null);
                            else if (vi._type.Contains("["))
                                vi.listChildren(m_eventDispatcher, "struct[]", GDBNames, VSNames, hasVsNdK_, null);
                            else
                                vi.listChildren(m_eventDispatcher, "struct", GDBNames, VSNames, hasVsNdK_, null);
                        else if (vi._type.Contains("["))
                            vi.listChildren(m_eventDispatcher, "[]", GDBNames, VSNames, hasVsNdK_, null);
                        else if (vi._type.Contains("*"))
                            vi.listChildren(m_eventDispatcher, "*", GDBNames, VSNames, hasVsNdK_, null);
                        else
                            vi.listChildren(m_eventDispatcher, "", GDBNames, VSNames, hasVsNdK_, null);
                        m_eventDispatcher.deleteVar(vi._name, hasVsNdK_);
                    }
                }
            }
            else
            {
                if (!valid)
                    vi = new VariableInfo(search, "", result);
                else
                {
                    string aux_exp = search.Replace(" ", "");
                    string datatype;
                    string firstDatatype = GDBParser.parseCommand("whatis " + aux_exp, 3);
                    string baseDatatype = GDBParser.parseCommand("ptype " + aux_exp, 4);
                    if ((baseDatatype[baseDatatype.Length - 1] == '{') && (baseDatatype[baseDatatype.Length - 2] == ' '))
                        baseDatatype = baseDatatype.Remove(baseDatatype.Length - 2);
                    if (baseDatatype.Length < firstDatatype.Length)
                    {
                        if (firstDatatype.Contains(baseDatatype))
                        {
                            baseDatatype = firstDatatype;
                        }
                    }
                    if ((baseDatatype == firstDatatype) || ((baseDatatype.Contains("::")) && (!baseDatatype.Contains("union"))))
                    {
                        baseDatatype = "";
                        datatype = firstDatatype;
                    }
                    else
                    {
                        datatype = baseDatatype;
                    }
                    if (datatype[datatype.Length - 1] == '*')
                        if (result == "0x0")
                        {
                            vi = new VariableInfo(search, firstDatatype, result);
                        }
                        else
                        {
                            vi = new VariableInfo(search, firstDatatype, baseDatatype, result, m_eventDispatcher, null, null);
                        }
                    else if ((datatype.Contains("struct")) || (datatype.Contains("[")))
                    {
                        vi = new VariableInfo(search, firstDatatype, baseDatatype, null, m_eventDispatcher, null, null);
                    }
                    else
                    {
                        vi = new VariableInfo(search, firstDatatype, result);
                    }
                }
            }
            return vi;
        }
Пример #3
0
        /// <summary>
        /// Constructor for Variable Info Object inquiring for the variable's children
        /// </summary>
        /// <param name="name"> The name of the variable. </param>
        /// <param name="type"> The data type of the variable. </param>
        /// <param name="baseType"> The base type of the variable. </param>
        /// <param name="value"> The value of the variable. </param>
        /// <param name="dispatcher"> The event dispatcher. </param>
        /// <param name="GDBNames"> The names of the variables used by GDB. </param>
        /// <param name="VSNames"> The Names of the variables used by VS. </param>
        public VariableInfo(string name, string type, string baseType, string value, EventDispatcher dispatcher, ArrayList GDBNames, ArrayList VSNames)
        {
            /// numChildren - The result of the createvar returns ERROR or a number from 0 to "n" where "n" is the number of children
            /// of the variable.
            string numChildren = "";

            _name = name;
            _type = type;
            _value = value;
            _children = null;
            _GDBName = null;

            if (baseType != "")
                type = baseType;

            if (GDBNames == null)
            {
                GDBNames = new ArrayList();
                VSNames = new ArrayList();
            }

            if (value == null || (type.Contains("*") && (value != "0x0")))
            {
                // This is an array, struct, union, or pointer.
                // Create a variable object so we can list this variable's children.

                /// Some VS variable names cannot be used by GDB. When that happens, it is added the prefix VsNdK_ to the GDB variable
                /// name and it is stored in the GDBNames array. At the same time, the VS name is stored in the VSNames array using the
                /// same index position. This bool variable just indicate if this prefix is used or not.
                bool hasVsNdK_ = false;

                numChildren = dispatcher.createVar(_name, ref hasVsNdK_);

                if (hasVsNdK_)
                {
                    _GDBName = "VsNdK_" + _name;
                    GDBNames.Add("VsNdK_" + _name);
                    VSNames.Add(_name);
                }

                try // Catch non-numerical data
                {
                    if (Convert.ToInt32(numChildren) > 0) // If the variable has children, evaluate them.
                    {
                        _children = new ArrayList();
                        if (type.Contains("struct"))
                            if (type[type.Length - 1] == '*')
                                this.listChildren(dispatcher, "*", GDBNames, VSNames, hasVsNdK_, null);
                            else if (type.Contains("["))
                                this.listChildren(dispatcher, "struct[]", GDBNames, VSNames, hasVsNdK_, null);
                            else
                                this.listChildren(dispatcher, "struct", GDBNames, VSNames, hasVsNdK_, null);
                        else if (type.Contains("["))
                            this.listChildren(dispatcher, "[]", GDBNames, VSNames, hasVsNdK_, null);
                        else if (type.Contains("*"))
                            this.listChildren(dispatcher, "*", GDBNames, VSNames, hasVsNdK_, null);
                        else
                            this.listChildren(dispatcher, "", GDBNames, VSNames, hasVsNdK_, null);
                    }
                }
                catch (FormatException e)
                {

                }

                dispatcher.deleteVar(_name, hasVsNdK_);
            }

            if (value == null)
                evaluateExpression(name, ref _value, null);
        }