[ZZ]配置GDB以支持查看stl容器数据
来源:互联网 发布:在清华读书的体验知乎 编辑:程序博客网 时间:2024/04/29 08:09
#include <vector>
using namespace std;
int main()
{
vector<int> vec;
vec.push_back(2);
vec.push_back(3);
vec.push_back(4);
return 0;
}
#g++ -o bugging -g bugging.cpp
gdb调试:
# gdb bugging
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-slackware-linux"...
(gdb) help pvector
Prints std::vector<T> information.
Syntax: pvector <vector> <idx1> <idx2>
Note: idx, idx1 and idx2 must be in acceptable range [0..<vector>.size()-1].
Examples:
pvector v - Prints vector content, size, capacity and T typedef
pvector v 0 - Prints element[idx] from vector
pvector v 1 2 - Prints elements in range [idx1..idx2] from vector
(gdb) break main
Breakpoint 1 at 0x80485c6: file bugging.cpp, line 6.
(gdb) run
Starting program: /root/learn/c++/bugging
Breakpoint 1, main () at bugging.cpp:6
6 vector<int> vec;
(gdb) n
7 vec.push_back(2);
(gdb)
8 vec.push_back(3);
(gdb) pvector
Prints std::vector<T> information.
Syntax: pvector <vector> <idx1> <idx2>
Note: idx, idx1 and idx2 must be in acceptable range [0..<vector>.size()-1].
Examples:
pvector v - Prints vector content, size, capacity and T typedef
pvector v 0 - Prints element[idx] from vector
pvector v 1 2 - Prints elements in range [idx1..idx2] from vector
(gdb) pvector vec
elem[0]: $1 = 2
Vector size = 1
Vector capacity = 1
Element type = int *
(gdb) n
9 vec.push_back(4);
(gdb)
10 return 0;
(gdb) pvector vec
elem[0]: $2 = 2
elem[1]: $3 = 3
elem[2]: $4 = 4
Vector size = 3
Vector capacity = 4
Element type = int *
(gdb)
5. 默认情况下gdb不能用[]查看stl容器的数据元素,提示如下错误:
(gdb) print vec[0]
One of the arguments you tried to pass to operator[] could not be converted to what the function wants.
一些常用内置的命令
Data type GDB command
std::vector<T> pvector stl_variable
std::list<T> plist stl_variable T
std::map<T,T> pmap stl_variable
std::multimap<T,T> pmap stl_variable
std::set<T> pset stl_variable T
std::multiset<T> pset stl_variable
std::deque<T> pdequeue stl_variable
std::stack<T> pstack stl_variable
std::queue<T> pqueue stl_variable
std::priority_queue<T> ppqueue stl_variable
std::bitset<n>td> pbitset stl_variable
std::string pstring stl_variable
std::widestring pwstring stl_variable
- [ZZ]配置GDB以支持查看stl容器数据
- 配置GDB以支持查看stl容器数据
- 配置GDB以支持查看stl容器数据
- 配置GDB以支持查看stl容器数据
- 配置GDB以支持查看stl容器数据
- 配置GDB以支持查看stl容器数据
- 配置GDB以支持查看stl容器数据
- gdb 查看 stl容器 zz
- gdb 查看 STL 容器值
- gdb调试-查看STL容器
- GDB中查看STL容器中数据的方法
- 配置GDB支持STL调试
- 支持stl容器的gdb自定义命令
- 在gdb中查看stl容器
- gdb查看stl容器中的内容
- gdb中查看stl容器内容
- gdb查看stl容器中的内容
- GDB对STL容器的查看
- android ListView没有数据时信息显示
- Android-ListView实现类似Gallery的功能
- widgets
- 通过重写Adapter实现多选的ListView
- Android-ListView实现类似Gallery的功能
- [ZZ]配置GDB以支持查看stl容器数据
- C/C++中使用GnuPlot
- 实际代码中的二分法
- Delphi获取Mac地址方法
- linux中关闭报警音
- C#枚举的应用
- ofsa简单介绍
- peizhi
- VC2005 和 VC2008 类向导脚本运行错误