Qt Pretty Printers

Qt Creator loads the GDB pretty printers in the following manner.

First, it imports the gdbbridge module by running the following gdb command.

python from gdbbridge import *

The file of the gdbbridge module is c:\Qt5.12.1\Tools\QtCreator\share\qtcreator\debugger\gdbbridge.py. This module creates a python object theDumper of class Dumper.  Then Qt creator uses theDumper to load all dumpers(pretty printers).

python theDumper.loadDumpers()

The dumpers(pretty printers) are scattered in several modules: qttypes, stdtypes, misctypes, boosttypes, opencvtypes, creatortypes, personaltypes. The location of these pretty printer modules is also :\Qt5.12.1\Tools\QtCreator\share\qtcreator\debugger\. Each module contains a certain kind of pretty printers.  For example, qttypes contains the pretty printers for Qt types such as QString. The name of the pretty printer is of the form qdump__xxxx such as qdump__QString. stdtypes contains the debugging helpers for stl types. For example, the pretty printer for list is qdump__std__list. The name takes the form of qdump__NAMESPACE__class. Similarly, boosttypes contains the pretty printers for boost lib and opencvtypes includes the pretty  printers for opencv lib. You can write your own pretty printers in personaltypes.py.

The loadDumpers method will import all these modules. It does not register these pretty printers in the modules to GDB using GDB’s python API, but maintains a map qqDumpers to associate the type like QString with the pretty printer functions like qdump__QString. When need to display a variable of particular type, Qt creator will use the type to look up the map for the printer function then call the function to handle the value of the variable.

 

If you like my content, please consider buying me a coffee. Buy me a coffeeBuy me a coffee Thank you for your support!
Posted in

Leave a Reply