使用GDB出现ImportError: No module named 'libstdcxx' 错误提示的解决方案

【问题描述】
错误提示:

Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Traceback (most recent call last):
  File "/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19-gdb.py", line 63, in <module>
    from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named 'libstdcxx'
  • 操作系统:Ubuntu 14.04 64-bit
  • gcc版本:gcc-4.8.4
  • python版本: 2.7.6

【错误分析】

  1. 来自stackoverflow的解释

    The script in libstdc++.so.6.0.19-gdb.py ought to be fixed as per that email message, and possibly ported to python 3 (I haven’t looked at it really closely yet). But if your target is compiled with the system version of gcc (i.e. you’re not cross-compiling nor using a version of gcc different from the one that came with the system), you can just do (gdb) python sys.path.append(“/usr/share/gcc-4.8/python”); then it won’t matter that the libstdc++.so.6.0.19-gdb.py script adds a nonexistent directory to the path.

  2. 这是个bug在很早的版本,不过新的libstdc++.so.6.0.19-gdb.py已经修复了这个import导入问题,如果还会出现这种问题,可能是交叉编译或者py脚本的gcc编译版本与运行环境不同导致的。

【解决方案】

在gdb控制台中,输入
python sys.path.append("/usr/share/gcc-4.8/python");

【感悟】
gdb打印居然是依赖python库文件,好神奇啊。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值