Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make QtCreator break on exceptions?

Tags:

c++

qt-creator

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.

like image 534
Grzenio Avatar asked May 24 '13 12:05

Grzenio


People also ask

How do I debug Qt Creator programs?

You can use the Qt Creator debugger interface from the command line. To attach it to a running process, specify the process ID as a parameter for the -debug option. To examine a core file, specify the file name. Qt Creator executes all the necessary steps, such as searching for the binary that belongs to a core file.

Why do I need to build my own Qt Creator build?

There are several reasons why you might want to do your own build of Qt Creator, like using the most current development version and being able to tweak Qt Creator at one or the other place. It is also necessary if you want to create your own Qt Creator plugin. Prebuilt Qt Creator packages usually use the latest stable release of Qt.

Why can't I see stack trace in Qt Creator?

That's very strange. if you run the program in the debugger, it will stop at the exception and show you the stack trace. If not, something is wrongly set up and you need to provide more info about your environment and setup. I presume you mean in Qt Creator.

How do I change the default views in Qt Creator?

To change the default settings, select View > Views, and then select views to display or hide. Alternatively, you can enable or disable views from the context menu of the title bar of any visible debugger view. You can drag and drop the views in Qt Creator to new positions on the screen. The size and position of views are saved for future sessions.


1 Answers

  • Open Debug mode (Ctrl+F4 or just 4th mode on right bar).

    enter image description here

  • Open context menu in breakpoints list at right bottom:

    enter image description here

  • Select "Add Breakpoint" and set the breakpoint type to "Break when C++ exception is thrown":

    enter image description here

like image 142
Sergey Shambir Avatar answered Oct 02 '22 08:10

Sergey Shambir