I am making a managed .NET debugger using an MDBG sample.
I am currently struggling with the behavior of StepInto, while StepOut and StepOver seem to work.
To achieve the Just-My-Code step, I call SetJMCStatus when loading the modules. This works great and allows me to debug only my code.
But since I install the entire module as JMC, some automatically generated code comes into play and crashes step by step. An example of such code would be an auto-property.
Since the debugger executes the Il commands, with a step in, I get inside the automatically generated method get_propertyName and set_propertyName , which is marked as my code because they are part of my module.
To distinguish such automatically generated code from my code, I can use the presence of debugging symbols that are absent in the case of automatically generated code. And then I could just mark the method as not my code to skip it during the step.
The problem is that I donβt know which methods are automatically generated before I enter during the step. When I entered a method that does not have debugging symbols, I can mark it as not my code, but it is too late - the debugger stopped where it should not stop.
Theoretically, I could iterate through my module methods using IMetadataImport and set them to JMCStatus when starting the debugger, but it looks pretty expensive:
foreach (var methodToken in mdbgModule.Importer.EnumerateAllMethodTokens()) { var func = mdbgModule.GetFunction(methodToken); if (func.SymMethod == null) func.CorFunction.JMCStatus = false; }
If I only knew which function would be executed next, then I can set its status and prevent the first step inside the automatically generated code.
I adhere to the MDBG approach for the step, without changing anything, just calling SetJMCStatus where necessary, so I'm not sure if it makes sense to provide any code ... If so, I will edit the question, just add a comment!
Any suggestion on the topic is much appreciated!
Hello,