Remember my choice to display as an array in Eclipse C / C ++

In Eclipse debugging mode for C / C ++, you can right-click on any observable expression that is a pointer and select "display as array". Then you will be offered the boundaries of the array, and for the rest of this debugging run, the observed expression is displayed as an array in accordance with these boundaries.

When I complete the process and start debugging again, it remembers my viewed expressions, but the pointers that were previously displayed as arrays will now be just pointers and therefore I have to re-display all the pointers in each debug run. In a recent project, it has become very tedious.

Is there a way to get Eclipse to remember the display as array option for the lookedup expressions?

+6
source share
1 answer

You should 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 like int* and you want to look (most of them) at its first 4 elements.

On the Expressions tab, use one of the following two syntaxes supported by GDB :

  • (*arr @ 4)
  • ((int[4])*arr)

Priority (...) parens above.

You can do this on the Expressions tabs (hours), but not on the Variables tab.

watching pointer as array

+10
source

All Articles