Reputation: 1307
In debug mode of Eclipse for C/C++, you can right-click on any watched expression that is a pointer and select "display as array". Then you're prompted for the array bounds and for the rest of this debug run, the watched expression is being displayed as an array according to these bounds.
When I terminate the process and start debugging again, it remembers my watched expressions, but pointers that were previously displayed as arrays will now be mere pointers again and hence, I have to re-cast all pointers in each debug run. In a recent project, this has become very tiresome.
Is there a way to make Eclipse remember the "display as array" choices for watched expressions?
Upvotes: 6
Views: 2307
Reputation: 66721
You have to be able to encode the fact that you want to look at the pointer as an array in the expression string itself.
Say you have an array as int*
and you want to look at (most at) its first 4 elements.
In the Expressions
tab, use one of the two following syntaxes supported by GDB:
(*arr @ 4)
((int[4])*arr)
The surrounding (...)
parens above are important.
You can do this in the Expressions
tabs (watches), but not in the Variables
tab.
Upvotes: 14