查看文章
 
配置 Code::Blocks 10.05 + gdb 7.1 使支持 STL
2011年09月15日 星期四 4:56

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 时,还是不能正确显示。

 

参考:

http://lumiera.org/documentation/technical/howto/DebugGdbPretty.html


类别:程序设计资料||添加到搜藏 |分享到i贴吧|浏览(209)|评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
     

   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu