Auto update local scopes in debug info when manipulating instructions #677

Merged
vitek-karas merged 4 commits from UpdateLocalScopes into master 2020-07-23 12:07:13 -05:00
vitek-karas commented 2020-06-23 10:33:01 -05:00 (Migrated from github.com)

Before this change Cecil would not update local scopes when manipulating method bodies. This can lead to corrupted debug info - which when written to a PDB results in corrupted PDB.

Cecil can store local scopes in two ways:

  • Using IL offset numbers - this is how pretty much all of the symbol readers populate the OMs.
  • Using references to instructions.

If the local scopes use offset values this change will update the local scopes for all insert and remove operations on the method body. The behaviors for insert is basically "insert after" in that the new instruction is added to the scopes of the previous instruction.

If the local scopes are using instructions directly the change only removes any references to instructions which are being removed from the method body (and replaces them with the instruction offset value).

To be able to tell the difference between these cases the instruction field has been made internal in the InstructionOffset structure.

Fixes #675.

Before this change Cecil would not update local scopes when manipulating method bodies. This can lead to corrupted debug info - which when written to a PDB results in corrupted PDB. Cecil can store local scopes in two ways: * Using IL offset numbers - this is how pretty much all of the symbol readers populate the OMs. * Using references to instructions. If the local scopes use offset values this change will update the local scopes for all insert and remove operations on the method body. The behaviors for insert is basically "insert after" in that the new instruction is added to the scopes of the previous instruction. If the local scopes are using instructions directly the change only removes any references to instructions which are being removed from the method body (and replaces them with the instruction offset value). To be able to tell the difference between these cases the `instruction` field has been made internal in the `InstructionOffset` structure. Fixes #675.
vitek-karas commented 2020-06-23 16:03:51 -05:00 (Migrated from github.com)

/cc @marek-safar

/cc @marek-safar
jbevain commented 2020-07-23 12:07:22 -05:00 (Migrated from github.com)

Thank you!

Thank you!
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-jbevain/cecil!677
No description provided.