Unlock Mode Breakpoint

I am using (C ++) visual studio 2010.

I need to trace the control flow of my appication.So that I set a breakpoint in the source code

during application launch in debug mode, the breakpoint hits. But in realease mode, he did not hit.

So, please, suggest a solution for the hot spot break in release mode ???

+5
source share
4 answers

In release mode, your code is optimized and can change the flow of your program. For example, if a function is simple and is called only once, the compiler can embed the function in release mode.

Debug mode does not have this optimization and is designed to debug your code.

+7
source

VS2015. , . " " "- > - > - > " - > ". . : debug - VS2015

, :)

+12

__debugbreak() intrinisic. , . :

if (var > LIMIT)
  __debugbreak();
+3

. - release_mode_breakpoint() . :

#pragma optimize("", off)
void release_mode_breakpoint()
{
    int put_breakpoint_here = 1;
}
#pragma optimize("", on)

You can then put a breakpoint on this int declaration line, and it will be deleted even in release mode. Then simply raise the stack in the debugger back to the function in which you really wanted to get a breakpoint.

In fact, do not leave this code in your final release, since an unoptimized line may prevent the compiler from optimizing the call code correctly.

0
source

All Articles