Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Break point in release mode

I am using (C++) Visual Studio 2010.

I have to trace the control flow of my Application. To do so, I have put a break point in the source code.

While running the app in Debug mode, the break point hits. But in Release mode it didn't hit.

How can I cause the break point to be hit when debugging in Release mode?

like image 623
Aneesh Narayanan Avatar asked Feb 10 '12 07:02

Aneesh Narayanan


3 Answers

I'm using VS2015. after lots of failed solutions I found one that worked for me. Just uncheck "Enable Just My Code" under Menu->Debug->Options->Debugging->General. See attached image: enable debug in release mode-VS2015

I really hope this will solve the problem to you :)

like image 132
user1988918 Avatar answered Oct 11 '22 21:10

user1988918


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

Debug mode doesn't have these kind of optimization and is designed for debugging your code.

like image 23
Wouter de Kort Avatar answered Oct 11 '22 21:10

Wouter de Kort


You can use the __debugbreak() intrinisic. This is also very handy if you want to break on a specific condition. For example:

if (var > LIMIT)
  __debugbreak();
like image 30
ConfusedSushi Avatar answered Oct 11 '22 23:10

ConfusedSushi