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

Steve Atkins steve at blighty.com
Fri Jun 8 20:21:41 CEST 2018


> On Jun 8, 2018, at 11:07 AM, Murphy, Sean <smurphy at walbro.com> wrote:
> 
> I'm sure I'm doing something stupid, but I'm not sure how to find it. I've got an existing codebase that we've just discovered fails on a new type of input - basically we crossed over the signed/unsigned boundary of a single byte field. So previous runs on the application always had this variable <= 127, now we're providing an input where the variable should be >= 128. I fixed the first place I found the issue, but that has changed where the problem occurs to somewhere later in my code I'm getting an assertion, but I'm having trouble figuring out where.
> 
> When running a debug build inside Qt Creator, all I get in the Application Output pane is:
>  ASSERT failure in QList<T>::at: "index out of range", file C:\Qt_5_3_2\5.3\mingw482_32\include/QtCore/qlist.h, line 479
> 
> But I have no idea where in my code this is happening, and gdb isn't breaking on this assert, allowing me to see where in my call stack this is happening. I've got plenty of QList's all over the place, and I'm fairly certain this issue is happening after a bunch of different signals fire, which is leading to the difficulty of tracking down where this happens.
> 
> 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.

Cheers,
  Steve




More information about the Qt-creator mailing list