GDB crashes with: ImportError: No module named libstdcxx.v6.printers

20,651

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.

Share:
20,651

Related videos on Youtube

lamonadevide
Author by

lamonadevide

Updated on September 18, 2022

Comments

  • lamonadevide
    lamonadevide over 1 year

    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.

  • fouric
    fouric over 10 years
    Could you provide a sample patch?
  • lamonadevide
    lamonadevide over 10 years
    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!
  • SamB
    SamB about 9 years
    @becko: What is your exact installed version of libstdc++6?
  • becko
    becko about 9 years
    libstdc++6 version 4.8.2-19. I am using Ubuntu 14.04 64 bits.
  • SamB
    SamB almost 9 years
    @becko: Hmm, what value for _dir does your libstdc++*-gdb.py file compute?
  • becko
    becko almost 9 years
    @SamB I have no idea what you're talking about. Can you explain?
  • becko
    becko almost 9 years
    @SamB Sorry, I can't use chat. Proxy issues.
  • Ciprian Tomoiagă
    Ciprian Tomoiagă over 8 years
    @becko have you managed to solve it? If so, how?
  • becko
    becko over 8 years
    @CiprianTomoiaga Not sure. Now I am using Xubuntu 15.04 and it doesn't seem to be happening anymore.