Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to make my own c# debugger - how would one do that? What tools should I be using?

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.

like image 503
Amichai Avatar asked Nov 21 '10 03:11

Amichai


People also ask

Can I create my own library in C?

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.

Where do I write C code?

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!


1 Answers

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)

like image 129
SLaks Avatar answered Oct 20 '22 01:10

SLaks