public string FullName()
 {
     if (_parent != null)
     {
         return(_parent.FullName() + "." + Name);
     }
     return(Name);
 }
示例#2
0
 private string ReplaceNamesInExpression(string expression, IVariableInformation variable, IDictionary <string, string> scopedNames)
 {
     return(ProcessNamesInString(expression, new Substitute[] {
         (m) =>
         {                    // finds children of this structure and sub's in the fullname of the child
             IVariableInformation var = variable == null ? null : variable.FindChildByName(m.Value);
             if (var != null) // found a child
             {
                 return "(" + var.FullName() + ")";
             }
             return null;
         },
         (m) =>
         {       // replaces the '$Tx' with actual template parameter
             string res;
             if (scopedNames != null && scopedNames.TryGetValue(m.Value, out res))
             {
                 return res;
             }
             return null;
         }
     }));
 }
示例#3
0
        // Construct a DEBUG_PROPERTY_INFO representing this local or parameter.
        public DEBUG_PROPERTY_INFO ConstructDebugPropertyInfo(enum_DEBUGPROP_INFO_FLAGS dwFields)
        {
            IVariableInformation variable = _variableInformation;

            if ((dwFields & (enum_DEBUGPROP_INFO_FLAGS)enum_DEBUGPROP_INFO_FLAGS100.DEBUGPROP100_INFO_NOSIDEEFFECTS) != 0)
            {
                if ((variable = _engine.DebuggedProcess.Natvis.Cache.VisualizeOnRefresh(_variableInformation)) == null)
                {
                    return(AD7ErrorProperty.ConstructErrorPropertyInfo(dwFields, _variableInformation.Name, ResourceStrings.NoSideEffectsVisualizerMessage, this, _variableInformation.FullName()));
                }
            }

            DEBUG_PROPERTY_INFO propertyInfo = new DEBUG_PROPERTY_INFO();
            string fullName = variable.FullName();

            if ((dwFields & enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_FULLNAME) != 0)
            {
                propertyInfo.bstrFullName = fullName;
                if (propertyInfo.bstrFullName != null)
                {
                    propertyInfo.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_FULLNAME;
                }
            }

            if ((dwFields & enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_NAME) != 0)
            {
                propertyInfo.bstrName  = variable.Name;
                propertyInfo.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_NAME;
            }

            if ((dwFields & enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_TYPE) != 0 && !string.IsNullOrEmpty(variable.TypeName))
            {
                propertyInfo.bstrType  = variable.TypeName;
                propertyInfo.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_TYPE;
            }

            if ((dwFields & enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE) != 0)
            {
                propertyInfo.bstrValue = _engine.DebuggedProcess.Natvis.FormatDisplayString(variable);
                propertyInfo.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE;
            }

            if ((dwFields & enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ATTRIB) != 0)
            {
                if (variable.CountChildren != 0)
                {
                    propertyInfo.dwAttrib |= enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_OBJ_IS_EXPANDABLE;
                }

                if (variable.Error)
                {
                    propertyInfo.dwAttrib |= enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_VALUE_ERROR;
                }
                else
                {
                    propertyInfo.dwAttrib |= enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_DATA;
                    if (!string.IsNullOrEmpty(fullName))
                    {
                        lock (_engine.DebuggedProcess.DataBreakpointVariables)
                        {
                            if (_engine.DebuggedProcess.DataBreakpointVariables.Any(candidate =>
                                                                                    candidate.Length > fullName.Length &&
                                                                                    candidate.EndsWith(fullName, StringComparison.Ordinal) &&
                                                                                    candidate[candidate.Length - fullName.Length - 1] == ','))
                            {
                                try
                                {
                                    if (_engine.DebuggedProcess.DataBreakpointVariables.Contains(variable.Address() + "," + fullName))
                                    {
                                        propertyInfo.dwAttrib |= (enum_DBG_ATTRIB_FLAGS)DBG_ATTRIB_HAS_DATA_BREAKPOINT;
                                    }
                                }
                                catch (Exception) { }
                            }
                        }
                    }
                }

                if (variable.IsStringType)
                {
                    propertyInfo.dwAttrib |= enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_VALUE_RAW_STRING;
                }
                propertyInfo.dwAttrib |= variable.Access;
            }

            // If the debugger has asked for the property, or the property has children (meaning it is a pointer in the sample)
            // then set the pProperty field so the debugger can call back when the children are enumerated.
            if (((dwFields & enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_PROP) != 0) ||
                (variable.CountChildren != 0))
            {
                propertyInfo.pProperty = (IDebugProperty2)this;
                propertyInfo.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_PROP;
            }

            return(propertyInfo);
        }
示例#4
0
 public VisualizerKey(IVariableInformation variable)
 {
     _name     = variable.FullName();
     _threadId = variable.Client.Id;
     _level    = (int)variable.ThreadContext.Level;
 }
示例#5
0
        // Construct a DEBUG_PROPERTY_INFO representing this local or parameter.
        public DEBUG_PROPERTY_INFO ConstructDebugPropertyInfo(enum_DEBUGPROP_INFO_FLAGS dwFields)
        {
            IVariableInformation variable = _variableInformation;

            if ((dwFields & (enum_DEBUGPROP_INFO_FLAGS)enum_DEBUGPROP_INFO_FLAGS100.DEBUGPROP100_INFO_NOSIDEEFFECTS) != 0)
            {
                if ((variable = _engine.DebuggedProcess.Natvis.Cache.VisualizeOnRefresh(_variableInformation)) == null)
                {
                    return(AD7ErrorProperty.ConstructErrorPropertyInfo(dwFields, _variableInformation.Name, ResourceStrings.NoSideEffectsVisualizerMessage, this));
                }
            }

            DEBUG_PROPERTY_INFO propertyInfo = new DEBUG_PROPERTY_INFO();

            if ((dwFields & enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_FULLNAME) != 0)
            {
                propertyInfo.bstrFullName = variable.FullName();
                if (propertyInfo.bstrFullName != null)
                {
                    propertyInfo.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_FULLNAME;
                }
            }

            if ((dwFields & enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_NAME) != 0)
            {
                propertyInfo.bstrName  = variable.Name;
                propertyInfo.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_NAME;
            }

            if ((dwFields & enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_TYPE) != 0 && !string.IsNullOrEmpty(variable.TypeName))
            {
                propertyInfo.bstrType  = variable.TypeName;
                propertyInfo.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_TYPE;
            }

            if ((dwFields & enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE) != 0)
            {
                propertyInfo.bstrValue = _engine.DebuggedProcess.Natvis.FormatDisplayString(variable);
                propertyInfo.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE;
            }

            if ((dwFields & enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ATTRIB) != 0)
            {
                // don't check readonly attribute, it doubles the eval time for a variable
                //if (this.m_variableInformation.IsReadOnly())
                //{
                //    propertyInfo.dwAttrib |= enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_VALUE_READONLY;
                //}

                if (variable.CountChildren != 0)
                {
                    propertyInfo.dwAttrib |= enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_OBJ_IS_EXPANDABLE;
                }

                if (variable.Error)
                {
                    propertyInfo.dwAttrib |= enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_VALUE_ERROR;
                }

                if (variable.IsStringType)
                {
                    propertyInfo.dwAttrib |= enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_VALUE_RAW_STRING;
                }
                propertyInfo.dwAttrib |= variable.Access;
            }

            // If the debugger has asked for the property, or the property has children (meaning it is a pointer in the sample)
            // then set the pProperty field so the debugger can call back when the children are enumerated.
            if (((dwFields & enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_PROP) != 0) ||
                (variable.CountChildren != 0))
            {
                propertyInfo.pProperty = (IDebugProperty2)this;
                propertyInfo.dwFields |= enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_PROP;
            }

            return(propertyInfo);
        }
示例#6
0
        private void InitializeBytes()
        {
            if (_bytes != null)
            {
                return;
            }

            uint fetched = 0;

            _bytes = new byte[0];

            IDebugMemoryContext2 memAddr;

            if (GetMemoryContext(out memAddr) != Constants.S_OK)
            {
                // no address in the expression value, try casting to a char*
                VariableInformation v = new VariableInformation("(char*)(" + _variableInformation.FullName() + ")", (VariableInformation)_variableInformation);
                v.SyncEval();
                if (v.Error)
                {
                    return;
                }
                AD7Property p = new AD7Property(_engine, v);
                uint        pLen;
                if (p.GetStringCharLength(out pLen) == Constants.S_OK)
                {
                    _bytes = new byte[pLen];
                    p.GetStringRawBytes(pLen, _bytes, out fetched);
                }
                return;
            }

            IDebugMemoryBytes2 memContent;

            if (((AD7MemoryAddress)memAddr).Engine.GetMemoryBytes(out memContent) != Constants.S_OK)
            {
                return;
            }

            fetched = 0;
            bool eos = false;

            byte[] bytes = new byte[s_maxChars + 1];
            byte[] chunk = new byte[2048];
            while (!eos)
            {
                // fetched is count of bytes in string so far
                // eos == false => fetch < s_maxChars
                // eos == true => string is terminated, that is bytes[fetched-1] == 0

                uint bytesRead;
                uint bytesUnreadable = 0;
                // get next chunk
                if (memContent.ReadAt(memAddr, (uint)chunk.Length, chunk, out bytesRead, ref bytesUnreadable) != Constants.S_OK)
                {
                    break;
                }
                // copy chunk to bytes
                for (uint i = 0; i < bytesRead; ++i)
                {
                    bytes[fetched++] = chunk[i];
                    if (bytes[fetched - 1] == 0)
                    {
                        eos = true; // end of string
                        break;
                    }
                    if (fetched == s_maxChars)  // buffer is full
                    {
                        bytes[fetched++] = 0;   // end the string
                        eos = true;
                        break;
                    }
                }
                if (bytesRead != chunk.Length)
                {
                    // read to end of available memory
                    break;
                }
                // advance to next chunk
                memAddr.Add(bytesRead, out memAddr);
            }
            if (!eos)
            {
                Debug.Assert(fetched < bytes.Length);
                bytes[fetched++] = 0;
            }
            if (fetched < bytes.Length)
            {
                _bytes = new byte[fetched];
                Array.Copy(bytes, _bytes, (int)fetched);
            }
            else
            {
                _bytes = bytes;
            }
        }