What is the equivalent of System.Diagnostics.Debugger.Launch() in unmanaged code?

前端 未结 3 946
被撕碎了的回忆
被撕碎了的回忆 2021-02-01 23:34

I need to launch a debugger from my native C++ program when certain conditions are met. In C# I just call System.Diagnostics.Debugger.Launch(). I thought that Win32 DebugBreak()

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-02 00:21

    DebugBreak() is fine, so is the __debugbreak() intrinsic. They both do the same thing, they crash the program with a STATUS_BREAKPOINT exception. Which then triggers the Windows Error Reporting dialog, it trundles for a while then offers the Debug button. Which then starts the debugger.

    The only real mistake you could make is not waiting long enough for the WER dialog and pressing Cancel too quick. Or having WER disabled. If there is no debugger available at all then, yes, you don't get to choose one.

    The registry key that matters is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger. Normally set to vsjitdebugger.exe, the one that displays the "Possible debuggers" dialog.

提交回复
热议问题