Exemple #1
0
    public void Log(string label, object value)
    {
        var entry = values.SingleOrDefault(currentEntry => currentEntry.label == label);

        if (entry == null)
        {
            entry = new DebugValue {
                label = label, value = value
            };
            values.Add(entry);
        }
        else
        {
            entry.value = value;
        }
    }
Exemple #2
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method determines whether or not any metadata is
        /// different between the input instance and the current instance.</summary>
        ///
        /// <param name="inputDebugItem">The debugitem to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsIdenticalMetadata(DebugItem inputDebugItem)
        {
            if (DebugExpression.GetString() != inputDebugItem.DebugExpression.GetString())
            {
                return(false);
            }
            if (DebugValue.GetString() != inputDebugItem.DebugValue.GetString())
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }
        public int DisplayValue(uint ownerHwnd, uint visualizerId, IDebugProperty3 debugProperty)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            try
            {
                DEBUG_PROPERTY_INFO[] propertyInfo = new DEBUG_PROPERTY_INFO[1];
                debugProperty.GetPropertyInfo(
                    enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_STANDARD |
                    enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_FULLNAME |
                    enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_PROP |
                    enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE_RAW,
                    10 /* Radix */,
                    10000 /* Eval Timeout */,
                    new IDebugReference2[] { },
                    0,
                    propertyInfo);

                DebugValue debugValue = new DebugValue();
                debugValue.visualizerId = visualizerId;

                int index = propertyInfo[0].bstrType.IndexOf(" {");
                if (index != -1)
                {
                    propertyInfo[0].bstrType = propertyInfo[0].bstrType.Remove(index);
                }
                bool isPointer   = IsEndsWith(propertyInfo[0].bstrType, "*") || IsEndsWith(propertyInfo[0].bstrType, "* const");
                bool isReference = IsEndsWith(propertyInfo[0].bstrType, "&");

                string variableName = propertyInfo[0].bstrName;
                if (propertyInfo[0].bstrFullName != propertyInfo[0].bstrName)
                {
                    variableName = Regex.Match(propertyInfo[0].bstrFullName, @"^[^$.-]*").Value + "..." + variableName;
                }
                debugValue.variableName = Regex.Replace(variableName, @"[""'\/ ]", "_");

                debugValue.expressionResult = ExecuteExpression((isPointer ? "" : "&") + propertyInfo[0].bstrFullName);
                if (Parse(debugValue.expressionResult, 16).GetValueOrDefault(0) == 0)
                {
                    throw new Exception("Incorrect argument!");
                }

                string typeName = null;
                if (visualizerId > 1000)
                {
                    debugProperty.GetCustomViewerCount(out uint viewersCount);
                    DEBUG_CUSTOM_VIEWER[] viewers = new DEBUG_CUSTOM_VIEWER[viewersCount];
                    debugProperty.GetCustomViewerList(0, viewersCount, viewers, out uint _);

                    for (uint i = 0; i != viewersCount; ++i)
                    {
                        if (System.Guid.Parse(viewers[i].bstrMetric) == typeof(IRuntimeDumperService).GUID &&
                            viewers[i].dwID == visualizerId)
                        {
                            debugValue.externalDumper = viewers[i].bstrMenuName;
                            typeName = viewers[i].bstrDescription;
                            break;
                        }
                    }
                    if (debugValue.externalDumper is null)
                    {
                        throw new Exception("External dumper is not found!");
                    }
                }
                else if (isReference)
                {
                    int length = propertyInfo[0].bstrType.Length;
                    typeName = propertyInfo[0].bstrType.Substring(0, length - 1) + " *";
                }
                else if (isPointer)
                {
                    typeName = propertyInfo[0].bstrType;
                }
                else
                {
                    typeName = propertyInfo[0].bstrType + " *";
                }
                debugValue.typeName = @"\""" + Regex.Replace(typeName, @"[\w.]+!", "") + @"\""";

                debugValues.Add(debugValue);
                int count = debugValues.Count;
                _ = System.Threading.Tasks.Task.Delay(1000).ContinueWith(t =>
                {
                    Dump(count);
                }, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext());
            }
            catch (Exception ex)
            {
                dte.StatusBar.Text = "[Dumper] " + ex.Message;
                dte.StatusBar.Highlight(true);
                Utils.PrintMessage("Debug", "[Dumper] [ERROR] " + ex.Message, true);
                Utils.PrintMessage("Dumper", "[Dumper] [ERROR] " + ex.Message + "\n" + ex.StackTrace);
            }

            return(0);
        }
Exemple #4
0
 public DebugCommand(DebugValue value) => Value = value;