如何像Visual Studio中那样,像察看数组一样察看vector

软件和网站开发以及相关技术探讨
回复
clarkyzl
帖子: 85
注册时间: 2008-10-06 22:19

如何像Visual Studio中那样,像察看数组一样察看vector

#1

帖子 clarkyzl » 2009-06-10 19:27

我所说的vector是C++标准库中stl::vector,Visual Studio的监视可以直接像监视数组一样监视它,而为什么 Eclipse 、Netbeans 都不行,说实话,Linux平台下,我最喜欢的IDE是Netbeans
头像
xhy
帖子: 3916
注册时间: 2005-12-28 1:16
系统: Ubuntu 12.10 X64
来自: 火星

Re: 如何像Visual Studio中那样,像察看数组一样察看vector

#2

帖子 xhy » 2009-06-10 20:35

终极万能DEBUG方式 写log
目前负债150多万
kamasamikon
帖子: 57
注册时间: 2009-01-05 11:42

Re: 如何像Visual Studio中那样,像察看数组一样察看vector

#3

帖子 kamasamikon » 2009-06-11 10:46

gdb 中自己定义查看的函数!
clarkyzl
帖子: 85
注册时间: 2008-10-06 22:19

Re: 如何像Visual Studio中那样,像察看数组一样察看vector

#4

帖子 clarkyzl » 2009-06-11 13:26

kamasamikon 写了:gdb 中自己定义查看的函数!
我不会啊,教教我吧,谢谢了
clarkyzl
帖子: 85
注册时间: 2008-10-06 22:19

Re: 如何像Visual Studio中那样,像察看数组一样察看vector

#5

帖子 clarkyzl » 2009-06-11 13:28

kamasamikon 写了:gdb 中自己定义查看的函数!
我不会啊,教教我吧,谢谢了
kamasamikon
帖子: 57
注册时间: 2009-01-05 11:42

Re: 如何像Visual Studio中那样,像察看数组一样察看vector

#6

帖子 kamasamikon » 2009-06-11 14:52

clarkyzl 写了:
kamasamikon 写了:gdb 中自己定义查看的函数!
我不会啊,教教我吧,谢谢了
http://www.ibm.com/developerworks/cn/ai ... u-gdb.html
http://www.ibm.com/developerworks/aix/l ... trace.html

这里有一些相关信息。

由于我也只知道一些很简单的,我很少用C++,更不懂STL,所以也没有那么复杂的需求。那你也只能自救了。
还有个可替换的方法,就是你自己在程序中写一个打印STL的函数,然后在 GDB 中使用 call 命令,就可以了。

// your source-code.cpp
void dump_vector(void *addr)
{
printf("xx is :%d\n", addr->xxx);
}

// gdb 命令行
(gdb) call dump_vector(0xYourVecAddress)
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
联系:

Re: 如何像Visual Studio中那样,像察看数组一样察看vector

#7

帖子 BigSnake.NET » 2009-06-12 8:15

xhy 写了:终极万能DEBUG方式 写log
正解...
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
联系:

Re: 如何像Visual Studio中那样,像察看数组一样察看vector

#8

帖子 BigSnake.NET » 2009-06-14 15:00

写log就是打印调试信息的意思
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
asmwarrior
帖子: 43
注册时间: 2009-06-07 9:58

Re: 如何像Visual Studio中那样,像察看数组一样察看vector

#9

帖子 asmwarrior » 2009-06-19 13:46

哈哈,这个问题,我最近刚刚在codeblocks论坛里面和几个人讨论一起解决呢,欢迎来一起讨论!

地址是:

http://forums.codeblocks.org/index.php/ ... l#msg73150

已经解决了一部分了,嘿嘿。
OpenCV & Codeblocks
头像
xiaocheng_zh
帖子: 46
注册时间: 2009-05-30 15:52
来自: DL LIAONING CHN

Re: 如何像Visual Studio中那样,像察看数组一样察看vector

#10

帖子 xiaocheng_zh » 2009-06-21 2:21

#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef vector<string> vstr;

int main()
{
vstr v;
v.push_back("bla bla");
v.push_back("abcdef");

string v0 = v[0];
cout << "Hello world!" << endl;
return 0;
}
偶在CODE::BLOCK下的debug如下:
Debug
Adding source dir: E:\vec\
Adding source dir: E:\vec\
Adding file: bin\Debug\vec.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.7.50.20071127
Child process PID: 8684
Program exited normally.
Debugger finished with status 0
.jpg
asmwarrior
帖子: 43
注册时间: 2009-06-07 9:58

Re: 如何像Visual Studio中那样,像察看数组一样察看vector

#11

帖子 asmwarrior » 2009-06-21 9:07

请下载SVN的代码,自己编译。这个功能最近才放进去.
估计过几天的nightliy build里面就有的!
OpenCV & Codeblocks
clarkyzl
帖子: 85
注册时间: 2008-10-06 22:19

Re: 如何像Visual Studio中那样,像察看数组一样察看vector

#12

帖子 clarkyzl » 2009-07-01 9:57

谢谢各位好人
:em11
asmwarrior
帖子: 43
注册时间: 2009-06-07 9:58

Re: 如何像Visual Studio中那样,像察看数组一样察看vector

#13

帖子 asmwarrior » 2009-07-01 10:02

最新的nightly build里面已经有这个功能了,不过功能比较单一。。。
OpenCV & Codeblocks
回复