heinbali01 wrote on Tuesday, September 15, 2015:
It sounds like the optimisation plays a part in this.
In non-optimised code, every local variable is located on the stack. Its value can be seen during its entire lifetime.
When optimised, most variables will live as shortly as possible, mostly in registers. And as compilers are very clever, it is often hard to follow which register represents which variable.
My projects often need the optimisations, without the
-Os option the code wouldn’t even fit into the part.
What you can do is making variables
void vAssertCalled( const char *pcFileName, uint32_t ulLine )
/* Make these variables 'volatile' to ensure
their visibility in the debugger. */
volatile const char *pcAssertedFileName;
volatile int iAssertedErrno;
volatile uint32_t ulAssertedLine;
ulAssertedLine = ulLine;
iAssertedErrno = stdioGET_ERRNO();
pcAssertedFileName = pcFileName;
while( ulBlockVariable == 0UL )
/* Insert a NOP instruction to be able
to set a breakpoint here. */
__asm volatile( "NOP" );
In the above function
vAssertCalled(), the parameters will be invisible to the debugger: as soon as they are not used any more, they stop to exist.
As long as you’re playing with the demo project you might want to disable all compiler optimisations, use -O0 (minus O zero)
Note that bigger variables like structs and arrays are often very well visible in the debugger. The reason is that they’re too big to fit into single registers.