【问题描述】
错误提示:
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
【错误分析】
来自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.
这是个bug在很早的版本,不过新的libstdc++.so.6.0.19-gdb.py已经修复了这个import导入问题,如果还会出现这种问题,可能是交叉编译或者py脚本的gcc编译版本与运行环境不同导致的。
【解决方案】
在gdb控制台中,输入
python sys.path.append("/usr/share/gcc-4.8/python");
【感悟】
gdb打印居然是依赖python库文件,好神奇啊。