View Full Version : Best way to debug

24th February 2006, 23:03
Hi to all!!
I'm new in Qt4. What do you think about debugging Qt?
Which is the best way for yoy?

Bye Manuel:cool:

24th February 2006, 23:06
Make sure you have Qt compiled in debug mode, then add "CONFIG += debug console" to your .pro file and watch the console for any messages.

If you use MinGW, download gdb (http://prdownloads.sf.net/mingw/gdb-5.2.1-1.exe?download).

25th February 2006, 00:34
There is a graphical front-end to gdb called Insight (http://mingw.org/download.shtml), but it's pretty buggy.

If you're used to debugging in Visual C++, VB, or C#, prepare to be disappointed using gdb.

25th February 2006, 19:14
If you're used to debugging in Visual C++, VB, or C#, prepare to be disappointed using gdb.
Is it that good? I've never used MSVS and I'm pretty happy with gdb (but then I haven't seen anything better than that)

25th February 2006, 22:05
Is it that good? I've never used MSVS and I'm pretty happy with gdb (but then I haven't seen anything better than that)

Like anything in a programmer's life, it depends on what type of application you're coding, what your coding habbits are, your frustration threshold, and what you're generally used to using.

Since there are no good x-platform development tools, save Eclipse, you need to use the tools of a given platform. Going from a visual environment to command line debugging with gdb was quite a shock. Not because gdb itself is difficult to use, but rather that i don't find it particularly helpful. Some variables i could get the value of, and others i only get a memory offset. I tried formatting the output, and spent hours googling how to get useful information out of gdb to no avail. Either way, for my personal frustration threshold, using gdb was too much work. For debugging something like a Qt app, i mostly just stick with messageboxes and sometimes trace logging. For non-graphical apps, i simply log.

I had at one point considered writing a debugging framework for Qt apps sending output to a special output window using the QtMsgHandler trick we all know about. Aside from straight debugging output, you could also "register" a class with the debug framework, then using Qt's introspection, get the name/value of each member of the class. This would give you the whole view of the class, not just a single member at a time. The problem here is the large amount of ancillary debugging code that would be mixed in with the rest of your source.

Contrast gdb with a visual environment like VSC++ where you simply mouse-over a variable to get its value...no additional typing or coding needed. This is particularly useful for things like vectors, where it will display the first 20 or so values in a popup beside the cursor, and if there are more elements you simply move your mouse over the down arrow box at the bottom of the box. This saved me a huge amount of time when i wrote a UU/yEnc decoding lib and needed to quickly see a bunch of values at the same time to find individual bytes that weren't being decoded correctly. Using the messagebox/logging approach here would have been more time consuming.

Modern environments like VS using a .Net language is an even richer debugging experience. You simply mouse over any class variable to expose it's members with their current values. This comes in particularly handy for nested elements such as a container whose items are the type of some other container whose items are of whatever type, you can simply mouse over and down the tree, exposing all elements as you go.

If you've never seen it, it's difficult to explain, but since VS Express for C# and C++ are free to download, you can easily check them out and judge for yourself...not that it will help you much for Qt development unless you paid for a license.

26th February 2006, 04:20
I tried installing VS Express but it was just too much for my 1.6 Ghz Centrinno with 256 MB of RAM. So I just added support for building Qt apps (http://forums.codeblocks.org/index.php?topic=2253.msg19518) to an IDE that I really liked. I also use ddd heavily as a gui frontend of gdb in linux and that is because it's there (meaning that if I find a better working enviroment in windows - I really doubt that - I'll switch at no time). Anyway it's just my thoughts/experiences and I am always open to new suggestions ;)