[Qt-creator] How to break on an assert?

André Pönitz apoenitz at t-online.de
Fri Jun 8 22:39:03 CEST 2018


On Fri, Jun 08, 2018 at 06:46:11PM +0000, Murphy, Sean wrote:
> > > Is there some setting in gdb/Qt Creator that would automatically break on
> > this assertion?
> > 
> > Q_ASSERT uses qFatal(), so you can break on that and get a stack trace.
> > 
> > Preferences... -> Debugger -> GDB Extended has "Stop when qFatal() is called",
> > which might do what you need.
> 
> Thanks! That did the trick. I notice at the top of that tab it says "The options
> below should be used with care.", can anyone talk me through the harm of leaving
> this option enabled (and maybe the "Stop when abort() is called") as well?

The harm is mostly startup performance degradation, especially in cases
where the symbol is not found or even present (e.g. in non-Qt applications).

While this is in general true for any breakpoint, it gets more prominent for
functions that may or may not belong to a Qt configured with -qtnamespace as
trying to determine the configured namespace may trigger excessive scans of
debug information.

On Windows there seems also be a problem when that search kicks in very early
in the application startup due to an unrelated interruption either gdb or
the dynamic loader gets confused to a degree that continuation is not possible.

So it's not an option to leave on by default, use it only when you notice you
need it.  But it won't eat kittens, if that's what you are afraid of.

Andre'



More information about the Qt-creator mailing list