how to view contents of STL containers using GDB 7.x(如何使用 GDB 7.x 查看 STL 容器的内容)
问题描述
我一直在使用宏解决方案,如 此处这里一个>.但是,提到了如何在没有宏的情况下查看它们.我指的是 GDB 版本 7 及更高版本.
有人能说明一下吗?
谢谢
从SVN获取python查看器
svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
将以下内容添加到您的 ~/.gdbinit
python导入系统sys.path.insert(0, '/path/to/pretty-printers/dir')从 libstdcxx.v6.printers 导入 register_libstdcxx_printersregister_libstdcxx_printers(无)结尾
那么打印应该就可以了:
std::map地图;the_map[23] = "你好";the_map[1024] = "世界";
在 gdb 中:
(gdb) 打印 the_map$1 = std::map with 2 个元素 = { [23] = "hello", [1024] = "world" }
要返回旧视图,请使用 print/r
(/r
用于原始视图).
另请参阅:http://sourceware.org/gdb/wiki/STLSupportp>
I have been using the macro solution, as it is outlined here. However, there is a mention on how to view them without macros. I am referring to GDB version 7 and above.
Would someone illustrate how?
Thanks
Get the python viewers from SVN
svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
Add the following to your ~/.gdbinit
python
import sys
sys.path.insert(0, '/path/to/pretty-printers/dir')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
Then print should just work:
std::map<int, std::string> the_map;
the_map[23] = "hello";
the_map[1024] = "world";
In gdb:
(gdb) print the_map
$1 = std::map with 2 elements = { [23] = "hello", [1024] = "world" }
To get back to the old view use print /r
(/r
is for raw).
See also: http://sourceware.org/gdb/wiki/STLSupport
这篇关于如何使用 GDB 7.x 查看 STL 容器的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 GDB 7.x 查看 STL 容器的内容
基础教程推荐
- C++ 程序在执行 std::string 分配时总是崩溃 2022-01-01
- C++,'if' 表达式中的变量声明 2021-01-01
- 运算符重载的基本规则和习语是什么? 2022-10-31
- 如何定义双括号/双迭代器运算符,类似于向量的向量? 2022-01-01
- 您如何将 CreateThread 用于属于类成员的函数? 2021-01-01
- C++ 标准:取消引用 NULL 指针以获取引用? 2021-01-01
- 设计字符串本地化的最佳方法 2022-01-01
- 什么是T&&(双与号)在 C++11 中是什么意思? 2022-11-04
- 调用std::Package_TASK::Get_Future()时可能出现争用情况 2022-12-17
- 如何在 C++ 中处理或避免堆栈溢出 2022-01-01