如何在GDB中打印STL容器? [英] How to pretty-print STL containers in GDB?
问题描述
我已经按照 GDB wiki 上的说明安装python漂亮打印机查看STL容器。我的〜/ .gdbinit
现在看起来像这样:
I've followed the instructions on the GDB wiki to install the python pretty-printers for viewing STL containers. My ~/.gdbinit
now looks like this:
python
import sys
sys.path.insert(0, '/opt/gdb_prettyprint/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
但是,当我运行GDB并尝试打印STL类型时,我得到以下内容: p>
However, when I run GDB and attempt to print an STL type, I get the following:
print myString
Python Exception <class 'gdb.error'> No type named std::basic_string<char>::_Rep.:
$3 =
任何人都可以看出这一点吗?我正在运行Ubuntu 12.04,它附带了GDB 7.4。
Can anyone shed some light on this? I'm running Ubuntu 12.04, which comes with GDB 7.4.
推荐答案
您可以尝试以下 GDB宏(将其附加到您的〜/ .gdbinit 文件)以打印STL包含类型数据甚至数据成员: https://gist.github.com/3978082
You can try with below GDB macro (append it to your ~/.gdbinit file) to print STL containter types data and even their data members: https://gist.github.com/3978082
这篇关于如何在GDB中打印STL容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!