about std container debugging

General questions regarding the usage of CodeLite
kingsyj
CodeLite Curious
Posts: 2
Joined: Wed Apr 27, 2011 8:45 pm
Genuine User: Yes
IDE Question: c++
Contact:

about std container debugging

Post by kingsyj »

hei, guys, thanks provide such a good IDE, it's the most VC alike IDE I have ever found currently. but there's still some important subject missing, because when I use STL containers or I use the container of my owner, I can't visualize the elements in the debugger window.

when we use visual studio, I know I can provide autoexp.dat script to visualize the elements of the containers, is there a similar method that can use when work with codelite? thank you!
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: about std container debugging

Post by eranif »

You will need to give an example of such container.
Also, please read this before posting:
http://codelite.org/forum/viewtopic.php?f=3&t=804

Eran
Make sure you have read the HOW TO POST thread
kingsyj
CodeLite Curious
Posts: 2
Joined: Wed Apr 27, 2011 8:45 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: about std container debugging

Post by kingsyj »

thanks for reminder, here is my profile

os: window xp version 2002 service pack 3
codelite version: v2.10.0.4778
gdb: I'm using the mingw version accompany along with the codelite download package.

for code examples, such

Code: Select all

#include <stdio.h>
#include <vector>

int main(int argc, char **argv)
{
	printf("hello world\n");
	
	int a = 3;
	
	std::vector<int> array;
	array.push_back(1);
	array.push_back(2);
	array.push_back(3);
	
	array.clear();
	
	return 0;
}

when I debugging, do I have any methods to visualize the array size, elements in the debugging window? thanks for reply.
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: about std container debugging

Post by eranif »

The problem is that gdb does not provide it automatically like the VS debugger, but it can be done.

For example, to display the content of std::vector, you can do this:

- First, since gdb is buggy when it comes to un-initial variables, you will need to turn off the following option in codelite:
settings | debugger settings ... | GNU Gdb debuggger | General | Use PreDefined types for the 'Locals' view

- Next, define new type for the debugger from:
settings | debugger settings ... | Pre Defined types

Code: Select all

Type: std::vector
Expression: *($(Variable)._M_impl._M_start)@$(Variable).size()
Debugger command: print
Click OK, and restart your debugging session.

Now, when clicking CTRL when hovering with the mouse over the word 'array' while debugging you will see this:
dbg-vector.png
Eran
You do not have the required permissions to view the files attached to this post.
Make sure you have read the HOW TO POST thread
Post Reply