14

I have a problem with GDB. Whenever I try to debug any C++ program, just after running it, GDB gives this error:

(gdb) run
Starting program: /home/errikos/Workspaces/tests/a.out 
Traceback (most recent call last):
  File "/usr/lib/debug/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.18-gdb.py", line 59, in <module>
    from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named libstdcxx.v6.printers
Traceback (most recent call last):
  File "/usr/lib/debug/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.18-gdb.py", line 59, in <module>
    from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named libstdcxx.v6.printers

After that, GDB continues running (ie. does not crash completely).

I am aware that there are several bug reports about this (here, here and here). In the second report, there is also a claim that there is a fix released. In the third one, there is a symlink workaround, that did not work for me (and which I do not like, even if it worked).

Has anyone found a workaround for this? Any missing package?

Note: I have the Ubuntu Toolchain test builds (ppa:ubuntu-toolchain-r/test) PPA activated.

7

This is a bug in /usr/lib/debug/usr/lib/$triple/libstdc++.so.6.0.18-gdb.py; if it were operating correctly, you would only see the ImportError once, and the pretty-printers would work.

See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=701935#18 for some information about what's going wrong here. This worked okay in Debian's gcc-4.7, but until recently did not work in gcc-4.8 on Debian. I'm not sure if I even tried this with gcc-4.6.

Regardless, you can patch that file to look in the right place.

| improve this answer | |
  • 2
    Could you provide a sample patch? – fouric Nov 27 '13 at 6:14
  • This has been probably fixed by the latest packages in ppa:ubuntu-toolchain-r/test, as I do not get this error anymore. I had lost interest in this as I have not been doing much C/C++ development lately. Thanks for your answer though! – ergys Nov 27 '13 at 9:37
  • Note: Matthias Klose has since moved the relevant file to a place where it doesn't trigger the spurious ImportError anymore in Debian unstable. – SamB Jul 25 '14 at 18:13
  • How can I patch this? – becko May 7 '15 at 18:07
  • @becko: What is your exact installed version of libstdc++6? – SamB May 8 '15 at 18:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.