Setting breakpoints in release mode in Qt creator - c++

I am using Qt creator and cdb debugger for my c++ project. I need to set some breakpoints in code and see what happens during runtime. Unfortunately because of some third party library I absolutely can not use Debug mode so I have to stick to the release mode.
In visual studio I always do such thing and use breakpoints in the release mode easily but how could I do that in Qt creator?
(Versions: Qt 5.12 / Qt creator 4.8)

Try using a "Profile" build in Qt Creator. That will include separate debugging line information in a "Release" (optimized) build. You can then launch it using the Debug button in Qt Creator and set breakpoints as you need.
Caveats:
You may not be able to get the exact line you want because of optimizations by the compiler.
You most variables will be optimized into registers, so you can't view them. If you need to view registers, try the good, old fashion method of printing their values out with a qDebug() statement. (When in doubt, print it out.)

Related

Can i set a breakpoint inside Qt itself?

As a sub-question to this, I want to know, since Qt5 is distributed with full source code, is it possible to set up debugger break-points inside Qt itself?
Is there a symbol file shipped with Qt5 for the binary build? Do I have to build my own Qt to do this?
What is the fastest way to have breakpoints inside Qt5 working with QtCreator on Ubuntu?
You need to configure and build qt yourself with debug symbols. (-debug)
Then in QtCreator you can go to Options > Debugger > General and "Add the Qt-Sources".

QStrings not showing when debugging with Qt Creator on Windows

I'm debugging a Qt 5.5 application with Qt Creator on Windows 10 using MSVC 2013 compiler.
CDB Debugger is set up in Qt Creator and I can start the debug session. However variable contents of Qt objects (QStrings...) can not be inspected, I just get the memory location, size etc.
I expect I'm missing for debugging helpers or the debugger extension mentioned here.
Any clues what to do?
I temporarily deleted qtcreatorcdbext.dll, started debugger (forcing to diplay an error) and moved the dll back. Now everything works.
It seems there was a problem with the setup procedure, maybe because debugging tools were installed after Qt Creator.
I had to update qtcreatorcdbext.dll in /lib/qtcreatorcdbext32 folder. My Qt creator installed separatly from the Qt pack so I copied the dll from the Qt installation/tools/qtcreator/lib/qtcreatorcdbext32 to the separatly installed qtcreator

Breakpoint: Break when c++ exception is thrown - why so slow?

Using Qt Creator, Qt 5.3, VC12 (VS2013)
When I set a "Break when c++ exception is thrown" breakpoint in Qt creator, my application becomes extremely slow. Maybe 5-10 slower than running with other breakpoints such as "File name and line number"
Why is debugging with this kind of breakpoint so slow? Just curious ..
-- Edit --
As of CR's comment, do I face an abnormality on my system?
It is a problem with the Microsoft-provided debugger that you have downloaded to use with Qt Creator. The debugger that Qt Creator uses is not the visual studio debugger, since the latter IIRC can't be easily used externally. Unfortunately there's nothing that Qt Creator could do to improve things, I don't think, short of using a non-existent port of, say, lldb.

using qt creator only as editor: are qt libraries necessary

I want to use qt creator, only as an editor, which does code completion and finds declarations etc. I dont want to use it to build etc. Is there a way, I can circumvent the need of qt-libraries? I am using a server, where my file space is limited. Also, without qt libraries, it does not allow making even a project. When I tried to install qt-libraries, it configures fine, but on make gives error.
So, can you suggest an alternative? Thanks
No, you need the Qt libs because the editor was coded in Qt.
Actually - at least under Windows -, you can. You just have to deselect all Qt library versions and only select the editor. If you want to have a debugger available on Windows, also select the checkbox for CDB support.
I have forgotten how this works with the Linux installer, but I imagine the same applies there as well, except of course for the CDB debugger, which is not available on Linux. Instead you should be able to chose from GDB and some other alternatives, though it might not be during the installation.
Once you installed it and are about to set up a new "Plain C++" project, you can't select a Qt version when creating a new kit, obviously.
If you blindly selected an already existing kit, Qt Creator might have tried to use a Qt installation for your vanilla C++ project. Instead of doing so, you should click the "Manage..." button on one of your preexisting kits and add a new, custom kit. Here you can set the "Qt version" option to "None". The rest should be set according to your needs.

How to use debugger in Qt Creator

I use Qt Creator for C++ projects (non-Qt actually). This might be a dumb question, but how do you manage to use the debugger in Qt Creator? I have been using CDB along with VisualStudio or gdb along with IDEs like Code::Blocks and they are all intuitive to use. When it comes to Qt Creator though, I'm hopeless!
For instance, I've tried putting breakpoints, but when I run the code, it just skips the breakpoints without doing anything! What am I doing wrong?
You should make "Debug" target, not "Release" one (located projects tab -> build settings -> build configuration)
You should use Debug menu items "Start debugging", "Step over", "Continue" etc, not just "Run"
hope it helps.