Qt Creator and GDB pretty printing



  • I have a GDB pretty printer that works under GDB. I can't get Qt Creator to use the printers in the locals window. Can Qt Creator use GDB pretty printers and if so, how can I set up?

    I appreciate any help you can provide. Thank you,
    Chris


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You're probably looking for that part of Qt Creator's "documentation":http://qt-project.org/doc/qtcreator-3.2/creator-debugging-helpers.html

    Hope it helps



  • Qt Creator can wrap and use "normal" GDB pretty printers that are registered in the global gdb.pretty_printers and all obj.pretty_printers that are loaded at application startup using the usual GDB means.

    The feature can be enabled by switching on "Load system GDB pretty printers" in the Tools->Options, Debugger settings.

    However, that is not recommended to use. Instead, the prefered solution is to write "Creator style" pretty printers (also in Python, see share/qtcreator/debugger/*types.py for examples). These require usually less code, are able to deliver output in different formats, and are "portable" in so far as they can also be used with LLDB.



  • Thanks for the reply, I appreciate the help.

    I have "Load system GDB pretty printers" checked but the printers still don't seem to be working. The locals still show the raw output. From GDB my printers are working fine. If I print from the GDB window my printer is in use. Qt Creator doesn't seem to use them, though. It seems to use some bb command, which I assume is a Qt Creator extension? Is there a way to make the locals windows use standard GDB commands (print)?

    Regarding the creator style printers, we're reluctant right now to switch to them right now. We have printers that work in GDB that we'd like to get working in Qt Creator.

    Thanks again for any help.



  • You could try to search the debugger log (Windows->Views->Debugger Log) for obvious error messages.

    "bb" is the main entry point to run the Python code Creator uses for pretty printing. It will trigger Creator's own pretty printing, but also the "imported" pretty printers, assuming that the import went ok. "importing" here means asking GDB for registered pretty printers (and if your GDB-style pretty printers work on the command line, there should some reports), and making them known to the "bb" machinery. Without seeing your actual printer implementation (and the layout of the structures you are trying to pretty print) it's hard to guess where the import fails.

    [I am somewhat tempted to offer you to re-do your GDB-style pretty printers in "Creator style", just to prove a point, but... ;-)]



  • For the Creator style printers, is it possible to put them in a module? I can only seem to get them to be recognized if they're directly in ~/.gdbinit or Creator's startup commands. I'd like to have them in a module, likely a few different modules.

    Thanks!
    --Chris


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.