Dre*_*mer 7 c++ python gdb stl pretty-print
我正在尝试在Ubuntu 14.04上为我的GDB 添加漂亮的STL 打印.有关工具的一些细节:
操作系统:Ubuntu 14.04
gdb版本:7.7
python版本:2.7.6
python3版本:3.4.0
但在我完全按照指令所说的设置之后.我仍然会收到以下错误:
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/home/jerry/myLib/gdb_stl_support/python/libstdcxx/v6/__init__.py", line 19, in <module>
from printers import register_libstdcxx_printers
ImportError: No module named 'printers'
/home/jerry/.gdbinit:6: Error in sourced command file:
Error while executing Python code.
Reading symbols from main...done.
Run Code Online (Sandbox Code Playgroud)
然后我又仔细检查了我漂亮的打印安装目录.在目录下/home/jerry/myLib/gdb_stl_support/python/libstdcxx/v6/
,我可以清楚地看到我有printers.py文件.而且我也查看了printers.py的内容,我确信它也有register_libstdcxx_printers
类.为什么python解释器还在抱怨printers
模块丢失了?这对我来说真的很奇怪.
Dre*_*mer 11
我自己尝试了一些东西,幸运的是,现在它正在发挥作用.至少它可以按预期打印出地图和矢量内容.这是我做的:
既然它抱怨它找不到printer.py
模块,那么我想我应该告诉python解释器这个文件的位置.所以我首先将这个额外的行添加到我的〜/ .gdbinit:
sys.path.append("/home/jerry/myLib/gdb_stl_support/python/libstdcxx/v6")
(行后sys.path.insert(0, '/home/jerry/myLib/gdb_stl_support/python')
)
然后再次运行gdb,我收到以下错误:
Traceback (most recent call last):
File "<string>", line 5, in <module>
File "/home/jerry/myLib/gdb_stl_support/python/libstdcxx/v6/printers.py", line 1247, in register_libstdcxx_printers
gdb.printing.register_pretty_printer(obj, libstdcxx_printer)
File "/usr/share/gdb/python/gdb/printing.py", line 146, in register_pretty_printer
printer.name)
RuntimeError: pretty-printer already registered: libstdc++-v6
/home/jerry/.gdbinit:7: Error in sourced command file:
Error while executing Python code.
Run Code Online (Sandbox Code Playgroud)
鉴于错误信息,我编辑了〜/ .gdbinit文件并注释了该行register_libstdcxx_printers (None)
.
然后在运行gdb后,它可以工作.
但是我仍然想知道sys.path中的目录是否是递归搜索的?我的意思是在我看来,python解释器应该这样工作:一旦你添加了一个目录sys.path
,那么该目录下的子目录也将被搜索一个模块文件.
归档时间: |
|
查看次数: |
7565 次 |
最近记录: |