Results 1 to 6 of 6

Thread: Best way to debug

  1. #1
    Join Date
    Feb 2006
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Cool Best way to debug

    Hi to all!!
    I'm new in Qt4. What do you think about debugging Qt?
    Which is the best way for yoy?


    Bye Manuel

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Best way to debug

    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.

  3. #3
    Join Date
    Jan 2006
    Location
    Winnipeg, MB. Canada
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Best way to debug

    There is a graphical front-end to gdb called Insight, but it's pretty buggy.

    If you're used to debugging in Visual C++, VB, or C#, prepare to be disappointed using gdb.
    Plan? There ain't no plan!

  4. #4
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Best way to debug

    Quote Originally Posted by rh
    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)

  5. #5
    Join Date
    Jan 2006
    Location
    Winnipeg, MB. Canada
    Posts
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Best way to debug

    Quote Originally Posted by yop
    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.
    Plan? There ain't no plan!

  6. #6
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Best way to debug

    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 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

Similar Threads

  1. Some very weird compilation warnings
    By MarkoSan in forum Qt Programming
    Replies: 21
    Last Post: 23rd January 2008, 17:48
  2. Replies: 2
    Last Post: 8th November 2007, 21:15
  3. Qt4 open src mingw from a PC to another
    By nvictor in forum Installation and Deployment
    Replies: 11
    Last Post: 1st May 2007, 18:41
  4. Adding custom defines when on debug build
    By chus in forum Qt Programming
    Replies: 2
    Last Post: 2nd March 2007, 12:38
  5. Replies: 11
    Last Post: 22nd March 2006, 20:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.