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 调试器似乎在跟踪内联函数时遇到问题

Guru**** 664280 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/1193629/ccs-debugger-seems-to-have-problems-tracking-inline-functions

在尝试调试已内联的函数时、我会看到一些奇怪的问题。 我不会假装了解正在发生的情况、但我怀疑 CCS 调试器在代码被内联时会遇到一些问题。

为了让您了解我看到的内容、我生成了一个简单的逻辑位、加载上下文结构、然后将其传递到两个基本相同的函数、一个保留为可调用函数、另一个强制内联函数。 这两个函数都返回相同(正确)的结果、但通过调试器在函数执行中查看的结果肯定不正确。 我的演示逻辑如下所示、注释显示了我通过调试器看到的内容。

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;
}

两个函数都返回正确的值这一事实表明编译器正在正确地管理内联函数。 但是、调试器 在函数本身内部跟踪该函数时似乎非常远。

是否有人可以对此添加任何见解? 我是否错过了它?

这一切都使用 MSP 5964上的 GCC 工具链。

谢谢- Andrew

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Andrew:

    感谢您的测试案例。 我可以在 GCC 中看到一些类似的异常行为。 当我使用 TI MSP430编译器编译同一个项目时、不会出现此问题。 因此、它看起来像是 CCS 调试器和 GCC 调试符号的问题。  

    我将为此文件一个错误

    谢谢

    Ki  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    [引用 userid="2210" URL"~/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/1193629/ccs-debugger-seems-to-have-problems-tracking-inline-functions/4500134 #4500134"]我将为此文件提出一个错误

    跟踪链接: https://sir.ext.ti.com/jira/browse/EXT_EP-11026

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    谢谢 Ki -您比我更简洁!

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    他有很多描述错误的练习。 ^μ A)