配置 Code::Blocks 10.05 + gdb 7.1 使支持 STL

Code::Blocks 10.05 本身对 STL 的调试做出了一定的支持:支持 std::string 和 std::vector 两个容器,并且 std::vector<std::string> 不能正确显示。这样在调试使用 STL 的程序时显然是不给力的,于是果断 Google 之,最终找到一个名叫 GDB Python pretty printers 的东西可以解决这个问题。

 

首先得把这玩意儿的脚本下载到本地:

sudo svn checkout svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python /opt/gdb/stlPrettyPrinter

 

然后配置 Code::Blocks:

点击 Settings->Compiler and debugger,对话框打开后选择 Debugger settings,在 Debugger initialization commands 文本框中填入下面的代码后点击 OK。

 

Debugger initialization commands 代码:

#

# .gdbinit : GDB Config file

#

# 3/2010 - Ichthyo: add python pretty printers for STL

 

python

import sys

sys.path.insert(0, '/opt/gdb/stlPrettyPrinter')

from libstdcxx.v6.printers import register_libstdcxx_printers

register_libstdcxx_printers (None)

end

 

最后还得取消 Code::Blocks 10.05 本身对 STL 的支持:

将 脚本文件 /usr/share/codeblocks/scripts/gdb_types.script 中函数 RegisterTypes 的 STL String 和 STL Vector 两部分代码注释掉。若不取消其本身对 STL 的支持,则当容器元素类型为 std::string 时,还是不能正确显示。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值