Debugging an application in QtCreator
my application crashes and I can not find the reason why. There is a lot of signals/slots and I can not identify where the problem occurs.
I tried to debug my application using GDB. Unfortunately the only useful output I got was this:
ASSERT failure in QList<T>::operator: "index out of range", file C:/Qt/5.9.1/mingw53_32/include/QtCore/qlist.h, line 549
I can see I'm calling a list with wrong index. But still didn't help me. I spent many hours trying to find where the incorrect call comes from without any success.
Is there any way to trace back the call to find out at which line of my code the crash happens? Thank you.
mchinand last edited by
Check out the Debugging section of the QtCreator manual. Debugging in QtCreator should show you where in your code you have this error (it's probably also possible with just gdb and compiled with the proper compiler flags, but I'm not as familiar with it).
m.sue last edited by m.sue
you can get a gdb backtrace with the command
bt. You will see a list of numbered stack frames. You can change to a specific frame with the
f 23changes to frame 23). There you can print the code with the
land values of variables with the
p <variable name>command.
You see, as soon as you make it work, it's far easier with a GUI debugger like Qt Creator than GDB.
Hi Michael, this is exactly what I'm looking for. Can I run these commands from QtCreator? Or is it somewhere directly implemented in the GUI and I just don't see it?
Seenu last edited by
Hi use CDB debugger it available in
install and in the code in debugger mode.It will list all Error and warnings where exactly it causing problem
@Seenu He is using MinGW, so he cannot use CDB.
If we run in debug mode, when there is a crash, a pointer is showed in tabular column level-function-file-line number.
According to you if pointer points at Qlist<T > - line 549,
Memory is not accessible for QList, Check list creation.
go downward to get exact location.
I hope this should help you.!!
Vinod Kuntoji last edited by
You can use backtrace command and print the variables
artwaw last edited by
@yuvaram Hi, I think you've got a little misled here.
Debugger points you to QList source file, since it's where actual wrong index has been used by the source of it is probably in your code. Index you provided is out of bounds. I would advise putting a breakpoint in your code and then executing subroutine that fails step by step (without getting into build-in routines) to actually see which call fails.
I agree with you. I gave sample to check logs and trace based on debug output.
Thank you all for the useful information. Unfortunately I still don't understand the steps to get the location in my code where the QList with incorrect index was called.
Setting brake points didn't help me. I have a lot functions called by signals emitted by Qt which I can not disable. And I had hard time finding the function which caused the incorrect call. For this particular problem I already found it in the end. I have put some console output to each function end and start to know in which it crashes. Then I found the function and root cause of the problem.
But I would like to know the right and quicker solution using DBG in QtCreator.
debugging can be analyzed without sharing your code.