Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DebugBreak not breaking

I'm writing a class in C++ that I cannot debug by using F5. The code will run from another "service" that will invoke it. In the past I've used __debugbreak() and when I got a window telling me that an exception was thrown selected to debug it.

Recently I've updated to windows 7 and it kept working for a while.

Today when I've tried to debug a piece of my code instead of shown the regular dialog that tells me that VSTestHost has stopped working and enable me to to debug the application I got a different dialog suggesting I send the data to microsoft for analysis.

Does anyone knows how can I fix this issue so I'll be able to debug my code?

like image 897
Dror Helper Avatar asked Jun 25 '09 13:06

Dror Helper


People also ask

What does __ DebugBreak do?

Causes a breakpoint in your code, where the user will be prompted to run the debugger.

What is the main purpose of the function Isdebuggerpresent?

This function allows an application to determine whether or not it is being debugged, so that it can modify its behavior. For example, an application could provide additional information using the OutputDebugString function if it is being debugged.

What does break into debugger mean?

If a user-mode debugger is attached, the program will break into the debugger. This means that the program will pause and the debugger will become active.


2 Answers

Finally I found the cause of the issue. It's a Vista/Win7 cause:

  1. Open The Action center control
  2. Goto Action Center settings
  3. Goto Problem Reporting Settings
  4. Choose "Each time a problem occurs, ask me before checking for solution"

Although this is more of IT solution/question I've been plagued with this problem all day and wanted to share the solution with other developers who encounter this problem.

like image 55
Dror Helper Avatar answered Sep 29 '22 17:09

Dror Helper


I finally found the solution for Windows 10 here: https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/enabling-postmortem-debugging

And also: https://docs.microsoft.com/en-us/windows/desktop/Debug/configuring-automatic-debugging

To enable automatic debugger launch, you should add a registry value:

  • key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug, value Auto = 1 (of type REG_DWORD)

The configured debugger is set the by the value Debugger (type REG_SZ); a Visual Studio installation sets this to:

"C:\WINDOWS\system32\vsjitdebugger.exe" -p %ld -e %ld

Note that on 64 bit OS this only works for 64 bit executables. To enable the same behaviour in 32 bit executables set the same values in this key:

  • HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug
like image 23
jp48 Avatar answered Sep 29 '22 17:09

jp48