Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sequence points can no longer be cleared when using deferred reading mode #694

Closed
ltrzesniewski opened this issue Oct 2, 2020 · 4 comments

Comments

@ltrzesniewski
Copy link
Contributor

ltrzesniewski commented Oct 2, 2020

This is a regression introduced by #686. When using the deferred reading mode, if you clear the sequence points of a method, those will be read again from the source file on writing.

Here's a repro:

using System;
using System.Linq;
using Mono.Cecil;

namespace ConsoleApp
{
    internal static class Program
    {
        public static void Main()
        {
            using var assembly = AssemblyDefinition.ReadAssembly(typeof(Program).Assembly.Location, new ReaderParameters { ReadSymbols = true });
            var method = assembly.MainModule.GetType(typeof(Program).FullName).Methods.Single(m => m.Name == nameof(SomeMethod));

            Console.WriteLine($"Sequence points A: {method.DebugInformation.SequencePoints.Count}");

            method.DebugInformation.SequencePoints.Clear();

            Console.WriteLine($"Sequence points B: {method.DebugInformation.SequencePoints.Count}");

            assembly.Write("Processed.dll", new WriterParameters { WriteSymbols = true });

            Console.WriteLine($"Sequence points C: {method.DebugInformation.SequencePoints.Count}");
        }

        private static void SomeMethod()
        {
            Console.WriteLine("Hello!");
        }
    }
}

This prints the following on v0.11.3:

Sequence points A: 3
Sequence points B: 0
Sequence points C: 3

It prints the expected result on v0.11.2, or if you set ReadingMode = ReadingMode.Immediate in ReaderParameters:

Sequence points A: 3
Sequence points B: 0
Sequence points C: 0

I'm not entirely sure what the proper fix would be here. Maybe an additional flag is needed to tell if debug information has been read, so the status does not depend on sequence points.

/cc @thaystg FYI

ltrzesniewski added a commit to ltrzesniewski/InlineIL.Fody that referenced this issue Oct 2, 2020
@jbevain
Copy link
Owner

jbevain commented Oct 2, 2020

@ltrzesniewski good catch. Could you submit a failing test? Thank you!

ltrzesniewski added a commit to ltrzesniewski/cecil that referenced this issue Oct 2, 2020
@thaystg
Copy link
Contributor

thaystg commented Oct 2, 2020

If you need to revert it's okay for me I did a workaround on wasm debugger side.

@jbevain
Copy link
Owner

jbevain commented Oct 5, 2020

Cool, let's do that then.

jbevain added a commit that referenced this issue Oct 13, 2020
Co-authored-by: Jb Evain <jb@evain.net>
@jbevain
Copy link
Owner

jbevain commented Oct 15, 2020

Fixed in master. Thanks!

@jbevain jbevain closed this as completed Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants