Author: BragadeeshV_41 Version: **
Problem: In PSoC® Creator™ 4.2, when using the MDK-ARM toolchain in debugging mode, the Call Stack window doesn’t display the entire call stack (highlighted in Red color) when the program fails in the CY_ASSERT() function as shown in Figure 1.
Figure 1. Call Stack window
Reason: This is because of the default settings of the MDK-ARM toolchain. The frame pointer register that holds the address of the current application stack is used as a general-purpose register (r11), even at the minimum optimization level. Therefore, the debugger cannot unwind the full stack.
Solution: To reserve a register to store the frame pointer, you need to use the command line option --use_frame_pointer. For newer processors that support Thumb-2 technology, (ARMv6T2 and later), the reserved register is always r11.
To set this command for the compiler, do the following as shown in Figure 2:
- Right-click on the project and select Build Settings.
- Select CM4 ARM MDK Generic > Compiler > Command Line.
- Enter --use_frame_pointer in the Custom Flags field and click OK.
Figure 2. Custom Flags in Build Settings
After adding these, you will be able to see the entire Call Stack during debugging as shown in Figure 3:
Figure 3. Unwinded Call Stack
Further reading and references: