Open ElektroKill opened 2 years ago
In commit 9f776f9, I added support for setting breakpoints on yield break;
statements for all 3 types of yield-return state machines. This does not always work but it's a step in the right direction.
In commit https://github.com/dnSpyEx/dnSpy/commit/d6bf16f96cf03abdc9c3e580fba4a5ce19ddb4ad, I fixed debug info generation for inlined finally blocks in yield return state machines. This means point number 2 from the original issue has now been fully resolved.
As an improvement to "debug info" it would be cool to put a breakpoint wherever the stack length is greater than zero. The example in the picture, where in "pseudo code" stack is greater than 0 (i.e. all variables generated by decompiler are dummy) you cannot put breakpoint.
As an improvement to "debug info" it would be cool to put a breakpoint wherever the stack length is greater than zero. The example in the picture, where in "pseudo code" stack is greater than 0 (i.e. all variables generated by decompiler are dummy) you cannot put breakpoint.
This is not a limitation of dnSpy or it’s debug info system. It’s a limitation of the .NET debugging APIs which we can’t overcome.
In order for the debugger to function properly, the ILSpy decompiler has been modified to generate debug info which tells us what IL code corresponds to what text in the text view as well as some other information that may be useful for the debugger. This debug info generation works well for regular code but over the past few days of extensive testing, I noticed many edge cases where strange, unusual, and unexpected behavior can occur.
yield break;
statements making it impossible to set a breakpoint on them. The next problem is a bit more complex. When a method which usesyield return
and has a finally handler is compiled, a separate method is inserted into the state machine containing the code which was inside the finally handler. The decompiler currently handles this but the inlined statements have IL offsets that are from the finally method and when the debug info for them is generated it applies the offsets to the current decompiled method and not the finally method causing an incorrect breakpoint to be set. Example: This second problem is much harder to fix as it requires changes to the debug info code to allow a debug info for a specific method to specify from which method each statement is.This issue will take some time to fix as it will require changes to the debug info system to make everything work smoothly and as expected.