This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C2000-CGT: C28x DWARF RA@CFA+0 breaks chained unwinding

Part Number: C2000-CGT

C28x .debug_frame encodes RA at CFA+0, which violates DWARF spec §6.4.1. 
CFA must identify caller frame base, not RA location. This corrupts chained unwinding:

Standard:  CFA = caller_SP, RA = CFA+offset  
C28x:      CFA = R20-N,    RA = CFA+0 → caller_SP wrong

Next frame lookup uses incorrect SP, breaking stack reconstruction beyond 1 level.

Is RA@CFA+0 intentional C28x behavior?

How should unwinders compute true caller SP when RA is at CFA+0?

Can we get the official documentation for this DWARF implementation?

This prevents reliable multi-frame unwinding in external debuggers. Standard DWARF tools fail completely.

I currently use an adapted DWARF reading tool that we have, but we can only get a partial call stack. 

Using C2000_cgt_22_6_2

  • Hi Robert,

    There is no official documentation specific to the DWARF implementation.  The existing implementation has been in use in the compiler for many years, respecting the C28x stack and calling convention.  Note that we support TI Code Composer Studio (CCS), but we don't claim support with "external debuggers", so it's possible something in DWARF could be missed that CCS handles with no problems.  We can't help with your "adapted DWARF reading tool", but if you see the same behavior with a more standard tool, or within CCS or TI tools, we can take a closer look.

    To make sure we're on the same page, could you provide a preprocessed test case of what you reference?  Please follow the directions in the article How to Submit a Compiler Test Case and also be sure to include your build options.

    Thanks!

  • Hi Alan,
    While preparing the test case, I was able to identify the discrepancy, and the call stack now works properly on our side.
    The difference is in the FDE rules for the return addresses.
    The CIE correctly indicates that the return address is taken from register 26, the RPC register. 
    However, the FDE then specifies that the return address should be calculated from the CFA with an offset of 0x00.
    This rule appears to be used consistently in all the FDE entries of the applications I built with C2000-CGT.
    The regular DWARF would simply skip this rule, as the rule is already included in the CIE.
    As a workaround, I ignored the return address rules from the FDE entries, and as a result, the unwinding now works correctly. 
    Thank you again for your support.