Force C ++ pause program in Visual Studio debugger

I am debugging a C ++ program compiled using MSVC under Windows. I want to investigate a problem associated with multi-threaded processes. Therefore, I put ASSERT in my code, and when the program reaches ASSERT, it displays a window about ASSERT (Standart [Abort], [Retry], [Ignore]) with a proposal to suspend the program in the debugger. I press the [Retry] button and pause the program. BUT, while I pressed the button, other threads continue to execute. So the question is, how to immediately stop the program when it reaches a certain point in order to find out what other threads were doing at that time?

+7
c ++ multithreading visual-c ++ visual-studio-debugging
source share
2 answers

You might want to set a conditional breakpoint instead of assert :

breakpoint visual studio

+2
source share

If you want to do this programmatically, use DebugBreak . (C # has an equivalent api system.Diagnostics.Debugger.Break)

If you want to do this from ide, from the msdn page you can set a breakpoint (or break the entire application, ctrl + alt + B) from the visual studio, and then control the execution of the stream using "freeze" and "thaw" in the stream window.

+2
source share

All Articles