Can the Mono compiler as a service be used in a debugging context?
Asked Answered
R

2

7

I'd like to know if and how I might be able to use the Mono compiler as a service (see here and here ) within a debugging context to query/modify/visualize/etc objects at runtime within the debugger. At the moment, per this SO post the Roslyn CTP does not support this feature.

Ranunculaceous answered 22/11, 2011 at 18:46 Comment(2)
This sounds a little like what you can do with the REPL shell ( csharp.exe or gsharp.exe )Sofar
Not sure I follow - I'd like to be able to place a breakpoint in my code during debugging (with Visual Studio, for example) and execute test statements withinin a REPL loop. Can this be done somehow with csharp.exe or gsharp.exe?Ranunculaceous
P
2

Yes, thats perfectly possible. I cannot tell you the exact details on how to implement this, but take a look at MonoDevelop which actually implements your idea since v2.8 (or maybe earlier). In MonoDevelop, you have a REPL Pad available, which allows you to enter C# code in the very same context your application stopped because of a breakpoint. I've attached a simple Screenshot of MD in the debugging view and the REPL pad open. Since MD is opensource, you could check out the sources how it was implemented and strip the parts that you need.

Screenshot of MonoDevelop using Direct/REPL evaluation window while debugging

Perspicuous answered 13/12, 2011 at 22:19 Comment(2)
Awesome, had no idea! Thanks, DavidRanunculaceous
Btw, there were some discussion from the mono guys that it would be awesome to attach the REPL to any given mono process (which should be possible because the mono softdebugger is hooked into the VM). IIRC there was some work done on this. Maybe you could catch up and complete the sources, that would be exactly what you need and you would contribute to mono ;)Perspicuous
B
0

I think it should be feasible because Mono Soft Debugger is part of the Mono runtime so you could use the "Debugger Agent":

The debugger agent is a module inside the mono runtime which offers debugging services to client programs.

So, one alternative could be trying to interface with the Mono Soft Debugger in your compiler as service (which runs on top of the Mono runtime).

As the Mono Soft Debugger is used in the MonoDevelop IDE you could also investigate if this IDE could be used for what you are looking for.

Brawny answered 12/12, 2011 at 17:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.