How can I make QtCreator break on exceptions? - c++

I am Debugging some BOOST unit tests in QtCreator and it sadly happened that they crash with an exception. How can I make QtCreator automagically break if any exception is raised? In Visual Studio there is a tick box for this one, is it also available in QtCreator?
In my case, BOOST catches the exception, so the program doesn't technically crash. However, the reported message is not really helpful.
I tried the same in KDevelop previuosly, hence I am asking separate questions about both of these IDEs.

Open Debug mode (Ctrl+F4 or just 4th mode on right bar).
Open context menu in breakpoints list at right bottom:
Select "Add Breakpoint" and set the breakpoint type to "Break when C++ exception is thrown":

Related

Breakpoint: Break when c++ exception is thrown - why so slow?

Using Qt Creator, Qt 5.3, VC12 (VS2013)
When I set a "Break when c++ exception is thrown" breakpoint in Qt creator, my application becomes extremely slow. Maybe 5-10 slower than running with other breakpoints such as "File name and line number"
Why is debugging with this kind of breakpoint so slow? Just curious ..
-- Edit --
As of CR's comment, do I face an abnormality on my system?
It is a problem with the Microsoft-provided debugger that you have downloaded to use with Qt Creator. The debugger that Qt Creator uses is not the visual studio debugger, since the latter IIRC can't be easily used externally. Unfortunately there's nothing that Qt Creator could do to improve things, I don't think, short of using a non-existent port of, say, lldb.

VS2010 Remote debugger stopping where is no breakpoint

I am remotely debugging a dll (C++, unmanaged) for Microsoft FSX (I do not know whether this matters). The dll is compiled as "Multi-threaded-dll", since it does not work as "Multi-threaded-dll debug". My dll currently just contains a DllStart and DllStop function, this is standard in FSX.
I general debugging works (it stops at my breakpoints), but somehow the debugger also stops in places where I did not place a breakpoint. First the issue came up in the "NO Source available" flavor. After checking
Suppress "No Source Available" pane in 2010 and
No Source available
the only solution working for me was to install the mentioned extension. Now I do not get the "No source" tab anymore, but debugger still stops somewhere outside my code. I have cleaned all breakpoints as recommended in " Debugger stops when there is no breakpoint VS2010 ".
bglmanx.dll is another dll, also started by FSX. I was thinking, OK, maybe there is some ambiguity about the symbols and have renamed my functions to DllStartFSXM and DllStopFSXM (and hence being unique). No improvement.
Any ideas, hints?
It could be caused by having __asm int 3 or a DebugBreak in the other code?
Perhaps there is some way of disabling these commands or reimplmenting the DebugBreak function?

Disable exception handling while debugging c++ project using Google Test

I have my (native C++) DLL project and a corresponding test EXE project based on Google Test. While debugging my DLL via this EXE I have exceptions automatically handled by Google Test. So if my DLL throws an unhandled exception during debug, I expect to see error message from Visual Studio with debug session paused after the code caused exception. Instead, I have breakpoint triggered in gtest.cc. And if I disable --gtest_break_on_failure flag I will receive no breaks at all.
I found no such option in Google Test documentation. Have I missed it? I don't want to check "break when thrown" flag for different exceptions in Debug settings, because I'm only interested in unhandled ones.
The answer is in the Advanced page section called "Disabling Catching Test-Thrown Exceptions". What you have to do is invoke your binary with --gtest_catch_exceptions=0.

Visual Studio C++ exception... weirdness

I have a Qt application that I compile in release configuration, run, and then perform operation X in the program. Everything runs fine.
I then compile it in debug configuration, run without debugging (so CTRL+F5), perform operation X in the program. Everything still runs dandy fine.
But when I try to run the debug configuration with debugging (so just F5) and then perform operation X, Visual Studio breaks in with a message that an exception has been thrown... in a completely unrelated part of the program (code being executed is far from the site where VS breaks, in the QHash template)... and then VS hangs and I have to kill it with the Task Manager. I can repeat this ad infinitum, and it always freaks out the same way.
Boost::exception is used for the exceptions. VS is 2008, SP1. Qt is 4.6.2, using the precompiled VS binaries from the Qt site.
Does anyone have a clue what is going on?
Visual Studio has a feature called "first chance exception handling" where, when running attached to the debugger, you can have the debugger break when exceptions of certain types are thrown.
You can change these settings by going to Debug -> Exceptions (Ctrl+Alt+E) and (un)checking the appropriate checkboxes.
When it breaks you should get a message in the Output window indicating what exception was thrown.
If you have _HAS_ITERATOR_DEBUGGING enabled (it is enabled by default in debug builds), it can cause a lot of iterator errors to throw exceptions instead of performing operations that would cause access violations. That's the only thing I can think of off the top of my head that would cause an exception to occur "randomly."

can I use breakpoints with try catch statements with qt creator?

if an exception is thrown inside a try/catch, can i put a breakpoint there to get into debu mode before the program exits?
Tested here with a simple code, were I called a function that always throw. The breakpoints inside de catch block not ignored, and the debug mode started normally.
Anyway, qtCreator uses GDB for debugging (At least on my machine). You can find out more about how GDB handle exceptions debugging here http://www.caf.dk/cafonly/gnu/gdb/gdb_31.html
I don't see why not, this can certainly be done with the C/C++ IDE in Eclipse just by clicking in the margin where you want to break and running in "debug mode". In Eclipse, there is a run and a run in debug mode separation - I assume that's the case also in Qt Creator. Try it?