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!