我正在使用 Code::Blocks 并希望启用 gdb python。所以我按照 C::B wiki http://wiki.codeblocks.org/index.php?title=Pretty_Printers来配置它。
我的 pp.gdb 与 wiki 中的相同,只是我将路径替换为到 printers.py 的路径。
python
import sys
sys.path.insert(0, 'C:/Program Files (x86)/mingw-builds/x32-4.8.1-posix-dwarf-rev3/mingw32/share/gcc-4.8.1/python/libstdcxx/v6')
from printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
然后我测试了它:
(gdb) source C:\Program Files (x86)\mingw-builds\x32-4.8.1-posix-dwarf-rev3\mingw32\bin\pp.gdb
错误信息显示:
Traceback (most recent call last):
File "<string>", line 4, in <module>
File "C:/Program Files (x86)/mingw-builds/x32-4.8.1-posix-dwarf-rev3/mingw32/
share/gcc-4.8.1/python/libstdcxx/v6/printers.py", line 911, in register_libstdcxx_printers
gdb.printing.register_pretty_printer(obj, libstdcxx_printer)
File "c:\program files (x86)\mingw-builds\x32-4.8.1-posix-dwarf-rev3\mingw32\
share\gdb/python/gdb/printing.py", line 146, in register_pretty_printer
printer.name)
RuntimeError: pretty-printer already registered: libstdc++-v6
C:\Program Files (x86)\mingw-builds\x32-4.8.1-posix-dwarf-rev3\mingw32\bin\pp.gd
b:6: Error in sourced command file:
Error while executing Python code.
我该如何解决?