Call Stack Doesn’t Unwind in Call Stack Window when CY_ASSERT() fails with a Third-party Toolchain in PSoC Creator 4.2 in PSoC 6 MCU Devices – KBA229134

Version 2

    Author: BragadeeshV_41           Version: **


    Translation - Japanese: PSoC 6 MCU デバイスを PSoC Creator 4.2 でサードパーティ製ツールチェーンを使用してデバッグ時に CY_ASSERT() が失敗するとコールスタックウィンドウ内のコールスタックがアンワインドされない - KBA229134 - Community Translated (JA)


    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:


    1. Right-click on the project and select Build Settings.
    2. Select CM4 ARM MDK Generic > Compiler > Command Line.
    3. 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:

    1. Refer to --use_frame_pointer, --no_use_frame_pointer in the Compiler User Guide.
    2. ARM registers
    3. Refer to Usage of Frame Pointer with Arm controller
    4. CY_ASSERT() in PDL