I'm interested in making a program that will take c# code and allow me to step through the execution of that code line by line - a debugger.
How would I go about this project without having to write a whole c# compiler? I'm using Microsoft Visual Studio, but I want my software to be as independent of their debugger implementation as possible.
First thing you must do is create your C source files containing any functions that will be used. Your library can contain multiple object files. After creating the C source files, compile the files into object files. This will create a static library called libname.
To write the source code of your first C program you need to open the Notepad++ text editor. The quickest way to do that in Windows 10 is to hit your Win key, type Notepad++ in the search window, and hit Enter. and paste it into the editor. Yes, this is your first C program!
You're looking for ICorDebug, the managed debugging API.
You can use csc.exe
to compile the code (this is included in a standard .Net Framework installation and wrapped by the CSharpCodeProvider class), then execute the assembly, attach the debugger, and step through the code.
Note that you would probably still need a C# parser to figure out where you are in the source.
The PDB file will contain some of this information; I'm not sure how much.
Note that most of the features in VS's debugger which we take for granted (especially the Watch window and variable tooltips) will require painful re-implementation. (Func-evals)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With