What is the correct debug steps ?
Can anyone share with the correct debugging steps with Qt creator? What I already know is opening the debug mode and run, then the program will stop at the place where it unexpectedly crashed. However, the debugging tool shows the page with assembly code which is not easily to trace the root cause. Is there any UI in the debugging tool which is more friendly and providing more information ? If not, what would you do when the program unexpectedly exit without any error message?
Did you build in Debug mode? You can't really debug a release build.
well, thats a very big topic there.
but the following should get you startet:
with a right-mouse-click in the creater -
Mouse over the linecounter preferably- you can set Breakpoints.
Wenn this line of code is called, your program will stop at this breakpoint. You than can look into all local and global variables and see their current values - usualy on the right hand side- with F10 you can continue one more line, with F5 you resume the program untill the next breakpoint
Excuse me, what do you mean "debug a release build" ? I usually choose the "debug", and then "run" (Ctrl + R) every time I changed my code and wanted to see the result. Is that correct?
Thanks, Hilk. Sometimes the code didn't crash at the same line. That is, sometimes it runs correctly in one iteration, while it fails somewhere in another iteration. Since I cannot catch or say guess the possible line. I have no idea where to set the breakpoint. Maybe simply set a lot of breakpoints is the most simple but workable way?
@VincentLiu In which file do you see the assembler code if you app is crashing? Is it some library?
If you see assembler that means you are in a binary which was build in release mode (without debug information).
You have the option to build your project in a release and a debug build.
To use the QT-Debug-Tool you have to build your project in the debug build and start the Debuger with your program.
To start the your program and the debugger, click on the "Play"button left hand side with the little "Bug" on the right side :) or F5 alternatively
to answer you question, when you run your program with the debugger(F5) it very rarely shows you assamble code as the crash-point.
But if it does, I personly place a
qDebug() << "Funktion start";
qDebug() << "Funktion stop";
at start and end, of the function I assume has the error.
9/10 times culprit is a not initialized pointer....
it very rarely shows you assamble code as the crash-point.
It will show you the assembly, if there's no associated source code, for example trying to debug release builds.