This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Static call graph problem

The static call graph feature (MDK-ARM 3.40) is very nice to have, but I am having some problems getting the output I want. The problem is that the linker flags some functions as "UNUSED", and thus refuses to calculate/generate the max stack depth for these functions.

The functions in question are tasks in the RTX system, and thus they are called indirectly from the RTX kernel, which could possibly explain why, except:

This behaviour is only for two of my tasks, for the rest of them I do get the expected output in the static call graph document. These two tasks are not listed in the "Function pointers" section of the call graph document, but the other tasks are.

I am unable to see that I am doing anything different regarding these two tasks, other than the fact that they reside in the same source file as main().

Can anyone offer any advice on how to resolve this?

Regards
-Oyvind

  • Just an addendum:

    I tried moving one of the tasks in question to a different source file, and then the linker did generate a call stack depth for this task. This is not an acceptable solution, but it may provide a clue as to why this is happening.

    Regards
    -Oyvind

  • Talking to myself here... :-)

    I found another way of "patching" the problem. I still don't understand why this happens, but here's the setup:

    void __task init(void)
    {
       /* system initialization */
       os_tsk_delete_self();
    }
    
    int main(void)
    {
       os_sys_init(init);
    }
    

    main is called by the library startup code, which starts the RTX OS by calling my task init. In this case, the static call graph says that init is "UNUSED".

    The linker can be "tricked" into generating the call graph for init if main is changed to include an explicit call to it (which is never actually done).

    int main(void)
    {
       int x = 0;
    
       if(x)
          init();
    
       os_sys_init(init);
    }
    

    It annoys me why this is so, so I'd still like to know why. After all, my other tasks are also called indirectly by RTX, and for those the call graph is generated.

    Regards
    -Oyvind

  • > Talking to myself here... :-)

    Actually, I am also confused and curious about how to use the Static call graph; but I am not good enough to handle the related issues. So, I am glad to see your findings.