0

I am writing some code that makes use of the std::vector class to store objects of a user-defined class. For debugging, I need to keep watch on a few particular member variables of this class. Towards this end, I went to the variables view in my debugger perspective and put the relevant member variables on watch. However, in the expressions view, I ended up with variables that looked something like this:

((((((class std::_Vector_base >::_Vector_impl_data) ((((class std::_Vector_base >) ((baseExpression).baseExpression)))._M_impl)))._M_start))->expressionPtr)

Needless to say, this is pretty annoying to look at.

I tried editing the names of the variables under the "expression" column in the expressions view, however that seemed to remove the entire variable from the watch window. For example, I would try to set the above name to simply "expressionPtr" only to be greeted by the following errors:

Multiple errors reported.

1) Failed to execute MI command:
-var-create - * expressionPtr
Error message from debugger back end:
-var-create: unable to create variable object

2) Unable to create variable object

3) Failed to execute MI command:
-data-evaluate-expression expressionPtr
Error message from debugger back end:
No symbol "expressionPtr" in current context.

4) Failed to execute MI command:
-var-create - * expressionPtr
Error message from debugger back end:
-var-create: unable to create variable object

Is there a way to assign unique identifiers to member variables while debugging to make it a bit easier on the eyes? Also, since the vector class will hold an indefinite number of objects during run-time, I would also like to keep track of the member variables of each object. For example, consider the following code:

class Foo
{
public:
    int a_var;
    int b_var;
};

int main ()
{
    Foo a;
    Foo b;
    //some code to work with Foo::a_var and Foo::b_var
}

I would like keep track of the member variables of both a and b as and when they are allocated. Some help will be really appreciated. Thanks in advance!

anon12c
  • 11
  • 3

1 Answers1

0

After messing around a bit, I figured out the solution to this and it was stupidly simple. All I had to do was add the member object variable of my vector object that contained my class objects to the watch list. I, however, was trying to add each member variable to the watch list individually like a complete idiot.
Anyway, after putting the object titled std::_Vector_base<Expression, std::allocator<Expression> >::_Vector_impl_data<Expression> >::_Vector_impl_data of the type std::_Vector_base<Expression, std::allocator<Expression> >::_Vector_impl_data on watch, my problem was solved. After that, all I have to do was expand this object which would now be listed in the expressions view and viola! I had all my required member variables right where I could see them.

anon12c
  • 11
  • 3