Skip to content

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

Closed

Description

@ltrzesniewski

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

Activity

  1. jbevain commented on Oct 2, 2020

    @jbevain
    Owner

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

  2. thaystg commented on Oct 2, 2020

    @thaystg
    Contributor

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

  3. jbevain commented on Oct 5, 2020

    @jbevain
    Owner

    Cool, let's do that then.

  4. added a commit that references this issue on Oct 13, 2020
  5. jbevain commented on Oct 15, 2020

    @jbevain
    Owner

    Fixed in master. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions