Setting up GDB pretty printing in Ubuntu 13.10
I tried to set up GDB pretty printing (for easier work with standard containers) according to this anwer. Instead of using python pretty printers code from svn I used the ones that ship with ubuntu. After going through the rest of the process I ended up with the following error message when launching gdb:
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/home/nietaki/gdb_printers/python/libstdcxx/v6/printers.py", line 54
raise ValueError, "Cannot find type %s::%s" % (str(orig), name)
^
SyntaxError: invalid syntax
/home/nietaki/.gdbinit:6: Error in sourced command file:
Error while executing Python code.
After looking a little deeper into the problem I found out the root cause lays deeper - Python 3 used in gdb is incompatible with libstdc++ pretty printers.
Does anyone have a functional workaround for that? For now I'm stuck with the (also useful, but not as functional) helpers from Dan Marinescu: http://www.yolinux.com/TUTORIALS/GDB-Commands.html#STLDEREF
Solution 1:
The easiest fix seems to be to set up the pretty printers as normal but then convert printers.py
to python3 using 2to3:
2to3 printers.py -w
I've only tested it briefly, but it seems to work fine.