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

Emit sequence points in ascending offset order #853

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions Mono.Cecil/AssemblyWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3302,8 +3302,15 @@ public void WriteSequencePoints (MethodDebugInformation info)
if (!info.TryGetUniqueDocument (out previous_document))
previous_document = null;

for (int i = 0; i < info.SequencePoints.Count; i++) {
var sequence_point = info.SequencePoints [i];
// The sequence points need to be emitted in strict ascending offset order, which is not guaranteed to be the case for
// info.SequencePoints.
var sequencePoints = new SortedDictionary<int, SequencePoint> ();
foreach (var sequence_point in info.SequencePoints) {
sequencePoints [sequence_point.Offset] = sequence_point;
}

var previous_offset = 0;
foreach (var sequence_point in sequencePoints.Values) {

var document = sequence_point.Document;
if (previous_document != document) {
Expand All @@ -3316,13 +3323,12 @@ public void WriteSequencePoints (MethodDebugInformation info)
previous_document = document;
}

if (i > 0)
WriteCompressedUInt32 ((uint) (sequence_point.Offset - info.SequencePoints [i - 1].Offset));
else
WriteCompressedUInt32 ((uint) sequence_point.Offset);
WriteCompressedUInt32 ((uint) (sequence_point.Offset - previous_offset));
previous_offset = sequence_point.Offset;

if (sequence_point.IsHidden) {
WriteInt16 (0);
WriteCompressedUInt32 (0);
WriteCompressedUInt32 (0);
continue;
}

Expand Down