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.

CCS debugger seems to have problems tracking inline functions



I am seeing some weird issues when trying to debug functions that have been inlined. I won't pretend to understand what is happening, but I suspect the CCS debugger is having some issues tracking this when code has been inlined.

To give you some idea what I am seeing, I have generated a simple bit of logic the loads a context structure, then passes this to two essentially identical functions, one that is left as a callable function, the other that is forced inline. These both return the same (correct) result, but the view via the debugger inside the function execution is definitely not correct. My demo logic looks as follows, with comments showing what I am seeing via the debugger.

typedef struct {
    uint16_t integer1;
} test_ctx_t;

// inside main - removed bits that turn off watchdog etc

    test_ctx_t test_str;        // This is located at 0x3BE8
    uint16_t result;
    uint16_t result2;
    test_str.integer1 = 1234;   // Set up some value in the test_str
    
    // Now return this value through inlined and callable code
    
    result = test (&test_str);          // both return correctly as 1234
    result2 = test2 (&test_str);
    
....
// Now the two functions, which simply retrieve the value of the integer
// from within the context structure, and returns ts. THe comments show what I
// am seeing with the debugger

inline uint16_t __attribute__((always_inline)) test (void *context_addr) {
     test_ctx_t *context;
     uint16_t some_integer;
    
    // the incoming context address is some gibberish value, and nothing like the 
    // 0x3BE8 expected. 

     context = (test_ctx_t *)context_addr;
     some_integer = context -> integer1;
     
    // Once cast to a test_ctx_t, it also contains gibberish. The value contained
    // in some_integer happens to be 16780, which should be what is returned???
    
     return some_integer;
     
     // However, the value returned is the correct 1234
}

uint16_t test2 (void *context_addr) {
    test_ctx_t *context;
    uint16_t some_integer;

    // the called function is debugged exactly as expected. The incoming address 
    // is the 0x3BE8 as expected, containing the expected integer with a 
    // value of 1234, which is returned

    context = (test_ctx_t *)context_addr;
    some_integer = context -> integer1;
    return some_integer;
}

The fact that both functions return the correct value would indicate the the compiler is correctly managing the inlined function. But the debugger seems wildly offbeam in tracking this inside the function itself.

Can anyone add any insight to this? Is it something I am missing?

This is all using the GCC toolchain on an MSP 5964.

Thanks - Andrew