Reputation: 608
Assuming that I have simple C# console application (code below). I want to debug it step by step using mdbg manager wrapper.
using System;
namespace TestApplication
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("1");
Console.WriteLine("2");
Console.WriteLine("3");
Console.WriteLine("4");
Console.WriteLine("5");
}
}
}
How to use MDbgEngine to debug this code step by step?
[MTAThread]
static void Main(string[] args)
{
var debugger = new MDbgEngine();
debugger.Options.CreateProcessWithNewConsole = true;
debugger.Options.StopOnException = true;
var process = debugger.CreateProcess("TestApplication.exe", "", DebugModeFlag.Debug, null);
process.Go();
//HOW TO GO STEP BY STEP TROUGH THE TestApplication?
}
Upvotes: 0
Views: 992
Reputation: 359
You have to subscribe to process.PostDebugEvent
event, Hopefully debugger will stop at very beginning of your application or you can put breakpoint in the location you want using process.Breakpoints.CreateBreakpoint()
process.PostDebugEvent += (ss, ee) => {
if (ee.CallbackType == ManagedCallbackType.OnBreakpoint)
{
// here do what you want and then you can
// process.StepInto, StepOver, or StepOut to move from here
}
};
Upvotes: 1