Mono Soft Debugger - Add Breakpoint

413 views Asked by At

i´m currently developing a debugger for Mono. Therefore I am using the Mono.Debugger.Soft.dll which has the VirtualMachineManager and VirtualMachine.

The question is: If I want to create a breakpoint in a simple program, how can i do this? (E.g. Sourceodefile: Program.cs and Line: 17)

The Instance of VirtualMachine has a SetBreakpoint-Method, but this Method wants a MethodMirror. It is not clear for me how i can obtain this with knowing only the location within the sourcecode-File?

greets Christian

1

There are 1 answers

0
jstedfast On

What you have to do is listen for TypeLoad events. When you get a TypeLoad event, iterate over all of the MethodMirrors in the TypeMirror looking for a matching filename and line number.

If you find a match, then you can set a breakpoint on that MethodMirror at the ILOffset.

However, if the program has already started running, you may have a problem in that you may have missed the TypeLoad event for the Type that the method exists in. The solution to that is to keep a cache of all loaded TypeMirrors from the very start of debugging the program so that you can also iterate over types that have been loaded before the user tries to add said breakpoint.

You may be interested to know that a command-line debugger is already in development: https://github.com/mono/sdb