2014-06-22 130 views
1

我跟着STL Support Tools并发现它不能在我的系统上工作。 我使用gnome Ubuntu 14.04。我试过这个:gdb漂亮打印机stl扔“TypeError”

(gdb) p vct 
Python Exception <class 'TypeError'> iter() returned non-iterator of type '_iterator': 
$1 = std::vector of length 20, capacity 32 

它抛出一个“TypeError”,只打印长度和容量。 我的G ++和gdb的版本:

g++ --version 
g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2 
gdb --version 
GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7 

我.gdbinit:

python 
import sys 
sys.path.insert(0,'/home/james/bin/gdb_printers/python') 
from libstdcxx.v6.printers import register_libstdcxx_printers 
register_libstdcxx_printers (None) 
end 

请帮助我,非常感谢你。

回答

2

sys.path.insert(0,'/home/james/bin/gdb_printers/python')

你是怎么/home/james/bin/gdb_printers/python

假设您是在wiki上(不准确)的说明,以及这样做:

svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python 

你现在有匹配最新libstdc++来源(又名“主干”)漂亮的打印机,而你libstdc++本身已经有一年多了,来自gcc-4.8

要获得正确的漂亮打印机,您需要从匹配的gcc分支中获取它们。我相信正确的命令是:

svn co svn://gcc.gnu.org/svn/gcc/branches/gcc-4_8-branch/libstdc++-v3/python 
+0

感谢您的回复。您的解决方案在Ubuntu 14.10上不起作用,它使用python 3作为gdb。我现在已经解决了这个问题,搜索后,我发现https://github.com/Manicqin/gdb_printers__python,它可以很好地解决我的问题。 – Mackerel

0
git clone https://github.com/Manicqin/gdb_printers__python python 

这将很好地解决这个问题。

no TypeError和no python 3 problem。

0

请注意,这些说明仅适用于过去(在封装之前)或非Linux系统上的人员。您典型的现代Linux发行版将以“正常工作”的方式安装这些调试脚本,而无需您额外配置。