public override void WriteName(ITextColorWriter output, DbgBreakpointLocationFormatterOptions options)
        {
            bool printedToken = false;

            if ((options & DbgBreakpointLocationFormatterOptions.Tokens) != 0)
            {
                WriteToken(output, location.Token);
                output.WriteSpace();
                printedToken = true;
            }

            var method = owner.GetDefinition <MethodDef>(location.Module, location.Token);

            if (method == null)
            {
                if (printedToken)
                {
                    output.Write(BoxedTextColor.Error, "???");
                }
                else
                {
                    WriteToken(output, location.Token);
                }
            }
            else
            {
                owner.MethodDecompiler.Write(output, method, GetFormatterOptions(options));
            }

            output.WriteSpace();
            output.Write(BoxedTextColor.Operator, "+");
            output.WriteSpace();
            WriteILOffset(output, location.Offset);
        }
示例#2
0
        FormatterOptions GetFormatterOptions(DbgBreakpointLocationFormatterOptions options)
        {
            FormatterOptions flags = 0;

            if ((options & DbgBreakpointLocationFormatterOptions.ModuleNames) != 0)
            {
                flags |= FormatterOptions.ShowModuleNames;
            }
            if ((options & DbgBreakpointLocationFormatterOptions.ParameterTypes) != 0)
            {
                flags |= FormatterOptions.ShowParameterTypes;
            }
            if ((options & DbgBreakpointLocationFormatterOptions.ParameterNames) != 0)
            {
                flags |= FormatterOptions.ShowParameterNames;
            }
            if ((options & DbgBreakpointLocationFormatterOptions.DeclaringTypes) != 0)
            {
                flags |= FormatterOptions.ShowDeclaringTypes;
            }
            if ((options & DbgBreakpointLocationFormatterOptions.ReturnTypes) != 0)
            {
                flags |= FormatterOptions.ShowReturnTypes;
            }
            if ((options & DbgBreakpointLocationFormatterOptions.Namespaces) != 0)
            {
                flags |= FormatterOptions.ShowNamespaces;
            }
            if ((options & DbgBreakpointLocationFormatterOptions.IntrinsicTypeKeywords) != 0)
            {
                flags |= FormatterOptions.ShowIntrinsicTypeKeywords;
            }
            if ((options & DbgBreakpointLocationFormatterOptions.DigitSeparators) != 0)
            {
                flags |= FormatterOptions.DigitSeparators;
            }
            if ((options & DbgBreakpointLocationFormatterOptions.Decimal) != 0)
            {
                flags |= FormatterOptions.UseDecimal;
            }
            return(flags);
        }
示例#3
0
        public override void WriteName(IDbgTextWriter output, DbgBreakpointLocationFormatterOptions options)
        {
            bool printedToken = false;

            if ((options & DbgBreakpointLocationFormatterOptions.Tokens) != 0)
            {
                WriteToken(output, location.Token);
                output.Write(DbgTextColor.Text, " ");
                printedToken = true;
            }

            var method = weakMethod?.Target as MethodDef ?? owner.GetDefinition <MethodDef>(location.Module, location.Token);

            if (method is null)
            {
                if (printedToken)
                {
                    output.Write(DbgTextColor.Error, "???");
                }
                else
                {
                    WriteToken(output, location.Token);
                }
            }
            else
            {
                if (weakMethod?.Target != method)
                {
                    weakMethod = new WeakReference(method);
                }
                owner.MethodDecompiler.Write(new DbgTextColorWriter(output), method, GetFormatterOptions(options));
            }

            switch (location.ILOffsetMapping)
            {
            case DbgILOffsetMapping.Exact:
            case DbgILOffsetMapping.Approximate:
                output.Write(DbgTextColor.Text, " ");
                output.Write(DbgTextColor.Operator, "+");
                output.Write(DbgTextColor.Text, " ");
                if (location.ILOffsetMapping == DbgILOffsetMapping.Approximate)
                {
                    output.Write(DbgTextColor.Operator, "~");
                }
                WriteILOffset(output, location.Offset);
                break;

            case DbgILOffsetMapping.Prolog:
                WriteText(output, "prolog");
                break;

            case DbgILOffsetMapping.Epilog:
                WriteText(output, "epilog");
                break;

            case DbgILOffsetMapping.Unknown:
            case DbgILOffsetMapping.NoInfo:
            case DbgILOffsetMapping.UnmappedAddress:
                WriteText(output, "???");
                break;

            default:
                Debug.Fail($"Unknown IL offset mapping: {location.ILOffsetMapping}");
                goto case DbgILOffsetMapping.Unknown;
            }

            output.Write(DbgTextColor.Text, " ");
            output.Write(DbgTextColor.Punctuation, "(");
            output.Write(DbgTextColor.Number, GetHexPrefix() + location.NativeAddress.Address.ToString("X8"));
            output.Write(DbgTextColor.Operator, "+");
            output.Write(DbgTextColor.Number,
                         (options & DbgBreakpointLocationFormatterOptions.Decimal) != 0 ?
                         location.NativeAddress.Offset.ToString() :
                         GetHexPrefix() + location.NativeAddress.Offset.ToString("X"));
            output.Write(DbgTextColor.Punctuation, ")");
        }
示例#4
0
 /// <summary>
 /// Writes the name shown in the Name column
 /// </summary>
 /// <param name="output">Output</param>
 /// <param name="options">Options</param>
 public abstract void WriteName(IDbgTextWriter output, DbgBreakpointLocationFormatterOptions options);
示例#5
0
        public override void WriteName(ITextColorWriter output, DbgBreakpointLocationFormatterOptions options)
        {
            bool printedToken = false;

            if ((options & DbgBreakpointLocationFormatterOptions.Tokens) != 0)
            {
                WriteToken(output, location.Token);
                output.WriteSpace();
                printedToken = true;
            }

            var method = owner.GetDefinition <MethodDef>(location.Module, location.Token);

            if (method == null)
            {
                if (printedToken)
                {
                    output.Write(BoxedTextColor.Error, "???");
                }
                else
                {
                    WriteToken(output, location.Token);
                }
            }
            else
            {
                owner.MethodDecompiler.Write(output, method, GetFormatterOptions(options));
            }

            switch (location.ILOffsetMapping)
            {
            case DbgILOffsetMapping.Exact:
            case DbgILOffsetMapping.Approximate:
                output.WriteSpace();
                output.Write(BoxedTextColor.Operator, "+");
                output.WriteSpace();
                if (location.ILOffsetMapping == DbgILOffsetMapping.Approximate)
                {
                    output.Write(BoxedTextColor.Operator, "~");
                }
                WriteILOffset(output, location.Offset);
                break;

            case DbgILOffsetMapping.Prolog:
                WriteText(output, "prolog");
                break;

            case DbgILOffsetMapping.Epilog:
                WriteText(output, "epilog");
                break;

            case DbgILOffsetMapping.Unknown:
            case DbgILOffsetMapping.NoInfo:
            case DbgILOffsetMapping.UnmappedAddress:
                WriteText(output, "???");
                break;

            default: throw new InvalidOperationException();
            }

            output.WriteSpace();
            output.Write(BoxedTextColor.Punctuation, "(");
            output.Write(BoxedTextColor.Number, GetHexPrefix() + location.NativeMethodAddress.ToString("X8"));
            output.Write(BoxedTextColor.Operator, "+");
            output.Write(BoxedTextColor.Number,
                         (options & DbgBreakpointLocationFormatterOptions.Decimal) != 0 ?
                         location.NativeMethodOffset.ToString() :
                         GetHexPrefix() + location.NativeMethodOffset.ToString("X"));
            output.Write(BoxedTextColor.Punctuation, ")");
        }
        public override void WriteName(ITextColorWriter output, DbgBreakpointLocationFormatterOptions options)
        {
            bool printedToken = false;

            if ((options & DbgBreakpointLocationFormatterOptions.Tokens) != 0)
            {
                WriteToken(output, location.Token);
                output.WriteSpace();
                printedToken = true;
            }

            var method = weakMethod?.Target as MethodDef ?? owner.GetDefinition <MethodDef>(location.Module, location.Token);

            if (method == null)
            {
                if (printedToken)
                {
                    output.Write(BoxedTextColor.Error, "???");
                }
                else
                {
                    WriteToken(output, location.Token);
                }
            }
            else
            {
                if (weakMethod?.Target != method)
                {
                    weakMethod = new WeakReference(method);
                }
                owner.MethodDecompiler.Write(output, method, GetFormatterOptions(options));
            }

            switch (location.ILOffsetMapping)
            {
            case DbgILOffsetMapping.Exact:
            case DbgILOffsetMapping.Approximate:
                output.WriteSpace();
                output.Write(BoxedTextColor.Operator, "+");
                output.WriteSpace();
                if (location.ILOffsetMapping == DbgILOffsetMapping.Approximate)
                {
                    output.Write(BoxedTextColor.Operator, "~");
                }
                WriteILOffset(output, location.Offset);
                break;

            case DbgILOffsetMapping.Prolog:
                WriteText(output, "prolog");
                break;

            case DbgILOffsetMapping.Epilog:
                WriteText(output, "epilog");
                break;

            case DbgILOffsetMapping.Unknown:
            case DbgILOffsetMapping.NoInfo:
            case DbgILOffsetMapping.UnmappedAddress:
                WriteText(output, "???");
                break;

            default:
                Debug.Fail($"Unknown IL offset mapping: {location.ILOffsetMapping}");
                goto case DbgILOffsetMapping.Unknown;
            }
        }