gdbinit 利用python,支持打印各种容器中的元素

GDB attempts to use a python "pretty printer" and reports the following error:

[Thread debugging using libthread_db enabled]
Traceback (most recent call last):
  File "/usr/local/lib64/libstdc++.so.6.0.16-gdb.py", line 59, in <module>
    from libstdcxx.v6.printers import register_libstdcxx_printers
ImportError: No module named libstdcxx.v6.printers
[Inferior 1 (process 31059) exited normally]
(gdb)

GDB Version: GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08

I found that by doing the following it fixes the problem:

svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python gdb_printers
mv gdb_printers /usr/local/etc
cd ~
vi .gdbinit

(copy & paste into .gdbinit)

python
import sys
sys.path.insert(0, '/usr/local/etc/gdb_printers')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end

设置打印元素的个数: set print element 10240

你可能感兴趣的:(gdbinit 利用python,支持打印各种容器中的元素)