Perhaps someone can provide some insight here..
I am trying to implement a simple stack overflow check by writing an 0xAA55 pattern at the bottom 10 bytes (lowest addresses, last used) of the C Stack. I will add a check for this pattern (actually the top of the 10 bytes) in my dispatcher loop, so it is checked regularly to see if it is overwritten as the stack grows.
The compiler and linker generate labels __STACK_END (0x0600) and __STACK_SIZE (0x0050). I cannot find any specific way to identify the data types of these labels, but the debugger claims they are BOTH (void *), despite the clear intent that __STACK_SIZE is a LENGTH, not a pointer!
I can find the label __STACK_END used in the compiler library boot.c file. I cannot find ANY reference to __STACK_END ANYWHERE except in the .map file
In short, I cannot correctly access the value of __STACK_SIZE. Please see the attached screen capture. Note that all variables are visible in the 'Watch' window. __STACK_SIZE appears correct, but every attempt to access it is WRONG. I tried various data types because I am not sure what it really is.
This would have been a little easier to do if there were some way to completely turn off compiler optimization. Note all the idiotic code I had to add simply to PREVENT the optimizer from discarding my attempts to read __STACK_SIZE and __STACK_END. ALL optimization is supposedly turned off...NOT!
Note that the Watch window shows one of my variables in R13. According to the Compiler User's guide SLAU132E, page 102, the C Stack Pointer is R13, and it defaults to a 2048 byte stack size, which is pretty remarkable on processors that generally have less than 2K of RAM. I think this is actually boilerplate text from the manual for another processor (ARM? LEG?), but no one has bothered to correct it through multiple editions of the document. boot.c shows the SP register being used for the C Stack pointer.
BTW, this is just one of many bizarre screen captures I have collected from CCS 4.2.0 TI should be congratulated from bringing embedded software development tools to an astonishing new low. CCS (Computer Crashing Software?) is without question the buggiest, most non-deterministic software I have used in several decades of embedded system development. Something as simple as clicking on the {cancel} button during a compile sometimes results in in it completely locking out all input (WITHOUT stopping!), requiring the use of Task Manager to close and stop it.