2014-10-01 8 views
0

간단한 C# 콘솔 응용 프로그램 (아래 코드)이 있다고 가정합니다. mdbg manager wrapper를 사용하여 단계별로 디버깅하고 싶습니다.MDbgEngine을 사용하여 단계별 관리 코드를 디버깅하는 방법

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"); 
     } 
    } 
} 

MDbgEngine을 사용하여이 코드를 단계별로 디버깅하는 방법은 무엇입니까?

[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? 
} 

답변

0

당신은 process.PostDebugEvent 이벤트에 가입해야 희망이 디버거는 응용 프로그램의 맨 처음에 중지 또는 당신은 당신이 사용하여 원하는 위치에 중단 점을 넣을 수 있습니다 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 
    } 
};