GDB Pretty Printing


GDB pretty printing is a gdb feature that allows gdb to display complex objects (and other containers) in a more friendly way.

For example, when gdb pretty printing is disabled, viewing an STL map is pretty much useless. Consider the following code:

typedef std::map<std::string, int> StringToIntMap_t;
StringToIntMap_t mymap;
mymap.insert( std::make_pair("String One",   1) );
mymap.insert( std::make_pair("String Two",   2) );
mymap.insert( std::make_pair("String Three", 3) );

Without pretty printing enabled, viewing mymap in the Locals view will give the following:

However, with Pretty Printing enabled, it will look like this:

Setting up pretty printing

Before you can enable this feature within CodeLite, you will need to install the following:

  • GDB with Python enabled. For Windows users, I recommend downloading the one from here (just extract it somewhere)
  • Python 2.7.x installed on your system.

Make sure to point CodeLite to the correct gdb. You can do this from the main menu Settings -> GDB Settings -> GNU gdb debugger -> General
and select the new gdb in the Debugger path field.

Once everything is set up properly, go to CodeLite's menu bar: Settings -> GDB Settings -> GNU gdb debugger -> General and enable the option Enable GDB pretty printing.

Next, switch to Start up commands and make sure you have the following startup commands:

import sys
sys.path.insert(0, 'PATH_TO_CODELITE_SETTINGS_FOLDER/gdb_printers')

from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)

from qt4 import register_qt4_printers
register_qt4_printers (None)

from wx import register_wx_printers
register_wx_printers (None)

Note: make sure to replace PATH_TO_CODELITE_SETTINGS_FOLDER with the correct path to your gdb_printers (CodeLite creates this directory when it is launched for the first time).
Under Linux, you should replace it with:


and under Windows it should point to:


Replace the placeholder PATH_TO_CODELITE_SETTINGS_FOLDER with the absolute path. Do not use environment variables etc

This is how the Startup Commands looks on my Windows box:

Edit - History - Print - Recent Changes - Search
Page last modified on September 01, 2014, at 07:04 PM