Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make Qt Creator's debugger show the contents of C++ vectors in OS X?

I'm writing a program that makes extensive use of vectors and am developing with Qt Creator 2.0.1 on Mac OS X 10.6.6 for the first time.

As I am debugging, I can see literals and arrays just fine in the Locals and Watchers window, but as soon as I go to expand a vector, in this case of type Student, I get this tree:

alt text

The other person I am working with on this is using the same version of Qt Creator on Ubuntu and can see the contents of the vectors just fine. What am I doing wrong?

This is his debugger:

alt text

like image 602
DanBlakemore Avatar asked Jan 18 '11 04:01

DanBlakemore


People also ask

How to Set a breakpoint in Qt Creator?

Adding BreakpointsIn the code editor, click the left margin or press F9 (F8 on macOS) on a particular line you want the program to stop. In the Breakpoint Preset view or the Breakpoints view: Double-click the empty part of the view. Right-click the view, and select Add Breakpoint in the context menu.


2 Answers

QtCreator 2.6 has support for Mac FSF GDB (7.5) support. FSF GDB supports python which allows qtcreator to properly display QVector, QSet, QList, QString, etc. It can be download from macports.

  1. Download and Install macports (download it from here http://www.macports.org/install.php)
  2. To install FSF GDB 7.5:

         sudo port install gdb
    
  3. Give FSF GDB permission to debug applications:

    sudo codesign -s gdb-cert /opt/local/bin/ggdb
    

    If gdb-cert isn't found, create a gdb-cert by clicking on the link below, and follow the directions for "Creating a certificate":

    http://sourceware.org/gdb/wiki/BuildingOnDarwin

    If you don't give permission to ggdb, you'll get a:

     Unable to find Mach task port for process-id 28885: (os/kern) failure (0x5).
     (please check gdb is codesigned - see taskgated(8)) 
    
  4. Change the kit debugger in QtCreator enter image description here

    Change the path from /usr/bin/gdb to /opt/local/bin/ggdb

  5. By default FSF GDB fails to handle breakpoints correctly because mac clang++ doesn't export debug symbols. To export the debugging symbols, dsymutil needs to be run manually. Luckly, dysmutil command can be run automatically after link the program using qmake. Add the following lines in your .pro file:

    macx {
        CONFIG(debug, debug|release) {
            QMAKE_POST_LINK = dsymutil \"MyApp.app/Contents/MacOS/MyApp\"
        }
    }   
    
like image 59
vpicaver Avatar answered Sep 17 '22 20:09

vpicaver


You need to build the debugging helper. Should be under Tools -> Options ...

Once the debugging helper is built, you can visualize std::string, QString and containers as well.

There should be a rebuild button in same the place as where you choose which version of Qt to use.

http://www.qtcentre.org/threads/31862-quot-No-valid-Qt-version-set.-Set-one-in-Tools-Options-quot-Windows-QtCreator

like image 44
Dat Chu Avatar answered Sep 19 '22 20:09

Dat Chu