Results 1 to 10 of 10

Thread: Xcode Qt4 Custom Data Formatters (for viewing in the debugger)

  1. #1
    Join Date
    May 2010
    Posts
    14
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Xcode Qt4 Custom Data Formatters (for viewing in the debugger)

    Hey Everyone,

    Xcode makes a very nice IDE for Qt for those of use doing our work on a mac. And though Creator is also shaping up to be a very nice IDE, it's one more tool to learn.

    It was irking me to no end that viewing the values of various QObjects wasn't possible in the Debugger. So I set out on a mission.

    The result of the mission is plugin bundle I wrote that does just that. The supported data types are limited as I just got started, but it covers:

    QString (displays the string)
    QModelIndex (displays something like row: 1, col: 5)
    QVariant (displays the toString() for it)
    QFile (displays the assigned file path)


    And I'm working on a QAbstractItemModel (I figure I'll show the metaobject's className property).

    Works with both pointers and instances of those data types "out the box".

    Anyway, during my searching I saw this come up quite a few times with no good solution for it, so here's my work:

    http://github.com/jameskyle/Qt4DataFormatter

  2. The following user says thank you to jkyle for this useful post:

    abey (14th May 2010)

  3. #2
    Join Date
    Oct 2009
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Xcode Qt4 Custom Data Formatters (for viewing in the debugger)

    Great initiative! I was precisely look for a solution for this issue.

    I could compile the bundle (in 32bit) and install it, but couldn't see any change in Xcode. I figured it might be a 64bit vs. 32 bit thing and restarted Xcode in 32bit mode, but it didn't change anything. Is there anything else that must be done/enabled/whatnot?

    Thanks
    Antoine

  4. #3
    Join Date
    Oct 2009
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Xcode Qt4 Custom Data Formatters (for viewing in the debugger)

    Actually, never mind my question above. It's actually working!

    What wasn't working is for references (QString&). Is there any way this could be done?

  5. #4
    Join Date
    May 2010
    Posts
    14
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Xcode Qt4 Custom Data Formatters (for viewing in the debugger)

    Quote Originally Posted by abey View Post
    I could compile the bundle (in 32bit) and install it, but couldn't see any change in Xcode. I figured it might be a 64bit vs. 32 bit thing and restarted Xcode in 32bit mode, but it didn't change anything. Is there anything else that must be done/enabled/whatnot?
    Yeah, make sure it's the proper arch. The bundle is loaded when you open the xcode debugger. So if you tail -f /var/log/system.log before opening the debugger you should see any error output that could cause failure to load.

    Also, you can verify the bundle was properly loaded by opening

    Run=>Show=>Shared Libraries

    If the bundle was loaded (after opening the debugger), you'll see a line similar to (you can filter by name)

    Qt Code:
    1. Qt4DataFormatter 0x00000001002 All Default
    To copy to clipboard, switch view to plain text mode 

    I need to build a universal binary of qt4 so I can build a universal of this bundle.

  6. #5
    Join Date
    Oct 2009
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Xcode Qt4 Custom Data Formatters (for viewing in the debugger)

    Thanks for the info. Any idea on how to make it work with QString references?

  7. #6
    Join Date
    May 2010
    Posts
    14
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Xcode Qt4 Custom Data Formatters (for viewing in the debugger)

    Quote Originally Posted by abey View Post
    Actually, never mind my question above. It's actually working!

    What wasn't working is for references (QString&). Is there any way this could be done?
    Sure. The displays are all simple functions that take a pointer as an argument and then return a char* of the summary string. If you double click on the summary, you'll see something like:

    Qt Code:
    1. // Summary String for QString *
    2. {(char *)printQString($VAR, (int) $ID)}:s
    To copy to clipboard, switch view to plain text mode 

    $VAR is the raw variable that's appearing (in this case a pointer) and $ID is some generated instance id. The rest is basically just a function call and I cast the output for good measure.

    So, for a QString &, you could double click the Summary string and put something like:

    Qt Code:
    1. // Summary String for QString &
    2. {(char *)printQString(&$VAR, (int) $ID)}:s
    To copy to clipboard, switch view to plain text mode 

    I'm not 100% on this one, I'll test it the next time I run across a reference, but you get the idea. When you make changes like this, it saves them in ~/Library/Application\ Support/Developer/Shared/Xcode/CustomDataViews/CustomDataViews.plist

    If you find a matching print method, you can add it to the bundle itself too and share. The bundle has a CustomDataViews.plist in it's bundle package that's referred to.

  8. #7
    Join Date
    Oct 2009
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Xcode Qt4 Custom Data Formatters (for viewing in the debugger)

    Awesome, it works! Thanks a bunch!

  9. #8
    Join Date
    May 2010
    Posts
    14
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Xcode Qt4 Custom Data Formatters (for viewing in the debugger)

    I've added summaries for QDomNodes and QDomElements. They are now available in master.

    They'll show up like this in the summary field of the debugger:

    Qt Code:
    1. "tagName: some_tname, text: contents of tag"
    To copy to clipboard, switch view to plain text mode 

  10. #9
    Join Date
    Oct 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Xcode Qt4 Custom Data Formatters (for viewing in the debugger)

    Does anybody know will it work with xcode4? I get compilation error, it can find this file:
    #include "/Developer/Applications/Xcode.app/Contents/PlugIns/GDBMIDebugging.xcplugin/Contents/Headers/DataFormatterPlugin.h"

  11. #10
    Join Date
    Apr 2013
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Xcode Qt4 Custom Data Formatters (for viewing in the debugger)

    Hello

    Thank you for this formatter, it is very useful indeed.

    However, I am having some troubles using it. Though it works in principle, the xCode debugger does not always display the contents of a variable. Sometimes, "out of scope" is displayed although the variable should be known, or the format string itself is displayed instead its evaluation. Also, sometimes the summary is not updated until one or two additional code lines are executed.

    Originally, code optimizations were activated. Deactivating them did help but not entirely remove the above symptoms. Are there other build settings interfering with the formatter? Is there a way to enforce an update of the summary of a variable or is there any other way to avoid the described problems?

    I am using xCode 3.2.6 64-bit (for compatibility reasons, so an update to xCode 4 won't be an option)

    Thanks a lot.

Similar Threads

  1. QFileSystemModel: creating custom rows of data
    By masterlaws in forum Qt Programming
    Replies: 3
    Last Post: 12th August 2013, 12:58
  2. Debugger problem retrieving data for watch view hangs
    By frenk_castle in forum Installation and Deployment
    Replies: 0
    Last Post: 6th May 2010, 00:09
  3. Using QVariant with custom data type
    By QAlex in forum Qt Programming
    Replies: 3
    Last Post: 4th December 2009, 13:04
  4. Get custom data from qstandarditem?
    By alexandernst in forum Newbie
    Replies: 3
    Last Post: 11th August 2009, 04:24
  5. QAbstractTableModel , custom data
    By akon in forum Newbie
    Replies: 0
    Last Post: 17th April 2009, 17:03

Tags for this Thread

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.