8

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

nietaki
  • 207
  • 2
  • 10
  • I have two questions: First, is Ask Ubuntu the right place, and why? Second, isn't this is a bug of the application? In both cases, it is off-topic! – Lucio Jan 09 '14 at 22:26
  • How is this off-topic? I linked a confirmed, high importance bug from the **Ubuntu** launchpad that causes my problem and asked for a workaround. If anyone using 13.10 got this working I could certainly use their solution. I checked with a friend who is on Gentoo and this issue doesn't affect them. – nietaki Jan 09 '14 at 22:38
  • 2
    There is an uncommitted patch to make the printers work with Python 3 at http://gcc.gnu.org/ml/libstdc++/2013-10/msg00243.html – Jonathan Wakely Jan 11 '14 at 19:21

1 Answers1

8

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.

dshepherd
  • 338
  • 2
  • 9