Q:
I'm unable to view variables in the Locals window and when I view the Expressions window it displays, "Expressions Window: ERROR: Unknown variable or symbol" why is this?
-----------------------------------
A:
The Locals window will only display local variables if there is debug Information available, and if variables have been defined (not just declared). The Expressions window will also display the "Expressions Window: ERROR: Unknown variable or symbol" message if there is no debug information present.
If optimization is being used, you should be aware that no debug information is available in these circumstances and is probably the most common cause of the behaviour you are seeing. You can try specifying the -Og switch which enables a compiler mode that attempts to perform optimizations while still preserving debugging information.
Please note that the 'Enable Optimization' project option is equivalent to the -O switch and the 'Generate debug information' option, also within the project options, is equivalent to the -g switch. However, having both of these switches enabled is different to the -Og switch. When the -g and -O switches are specified, no debug information is available for local variables and the standard optimizations can sometimes rearrange program code in a way that produces inaccurate line number information. For full debugging capabilities, use the -g switch without the -O switch.
As mentioned previously, the -Og switch enables a compiler mode that attempts to perform optimizations while still preserving debugging information. It is meant as an alternative for users who want a debuggable program but are also concerned about the performance of their debuggable code.
If optimization is being used, you should be aware that no debug information is available in these circumstances and is probably the most common cause of the behaviour you are seeing. You can try specifying the -Og switch which enables a compiler mode that attempts to perform optimizations while still preserving debugging information.
Please note that the 'Enable Optimization' project option is equivalent to the -O switch and the 'Generate debug information' option, also within the project options, is equivalent to the -g switch. However, having both of these switches enabled is different to the -Og switch. When the -g and -O switches are specified, no debug information is available for local variables and the standard optimizations can sometimes rearrange program code in a way that produces inaccurate line number information. For full debugging capabilities, use the -g switch without the -O switch.
As mentioned previously, the -Og switch enables a compiler mode that attempts to perform optimizations while still preserving debugging information. It is meant as an alternative for users who want a debuggable program but are also concerned about the performance of their debuggable code.