cancel
Showing results for 
Search instead for 
Did you mean: 

How to read the <Static Call Graph.html> file generated by ARM Linker?

Lingjun Kong
Associate III
Posted on July 30, 2017 at 12:42

I'm a little confused about the Stack Size, Thumb and Max Depth shown on the file. Which is generated by the ARM Linker.

1. Where could I found the information what these several words exactly meaning?

for example:

f_open (Thumb, 450 bytes, Stack size 608 bytes, ff.o(i.f_open)) [Stack]Max Depth = 840Call Chain = f_open ⇒ dir_register ⇒ dir_find ⇒ dir_next ⇒ create_chain ⇒ put_fat ⇒ move_window ⇒ sync_window ⇒ disk_write [Calls]>> get_fattime>> st_clust>> remove_chain>> move_window>> ld_clust>> inc_lock>> follow_path>> find_volume>> enq_lock>> dir_register>> chk_lock

I know the Max Depth is the Stack needed of the Longest Call Chain. Is that means, for this function, the stack it needed is exactly equal the Max Depth?

If so, what about the 'Stack Size'? Is which means the stack size of the current function itself needed?

If so, what's the 'Thumb'? Is which means that, 'Thumb' Instruction Set?

Could I say:

Max Depth=Thumb + all Stack Size in the call chain + some other unknown exception
?

2. How to read the Call Graph file?I've noticed that there are several piece in the file

z. Maximum Stack Usage = xxxx bytes + Unknown(Cycles, Untraceable Function Pointers) a. Call chain for Maximum Stack Depth b. Mutually Recursive functions c. Function Pointers d. Global Symbols e. Local Symbols f. Undefined Global Symbols

Is the 'Local Symbols' response to the functions which aren't referenced on the .h header file?

3. Why the call chain doesn't show the Heap Size of the function?

4. Could the Maximum Stack Usage indicate the real Max Stack Needed?

for example, one of my project, it shows

Maximum Stack Usage = 78160 bytes + Unknown(Cycles, Untraceable Function Pointers)
in the Static Call Graph file.

But the stack size I setted in the startup file is 0xDFA0 (I find out this value by experiment), in this size of stack, my program works well in most time, and in some case it doesn't work well. Why it could still work well?

5. Where could I get the knowledge about my question upper?

for these several questions, I've found answer on internet for about one whole but finally get nothing. Where and how could I learn about those knowledge?

Thanks.

c-compiler call-stack arm-gcc st-linker stack cortex-mx linker-stm32 linker stm32-jump-function-call
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on July 30, 2017 at 15:02

I suppose one could get better at searching the Internet and reviewing ARM documentation, as well as experimenting with the generated code to see how it functions and interacts with the processor. This is a multidimensional problem which requires you to understand and connect a lot of information and knowledge. 

Thumb would be 16-bits code used by the Cortex processor, ARM would be the alternative 32-bit code not suported here. The size is the number of bytes consumed by the opcodes and literals for the machine code describing the function. The stack details tend to measure the local automatic variables, using worst case scoping, and sub function that may be called. Assumes all code points are visited. finding paths with largest scope contributions, and call trees. 

Experiment and review in the context of the code output. Use manual static analysis to cross check output.

Contrast with stack usage in the dynamic case.

If using malloc/free be conscious of leakage and fragmentation issues with the heap, embedded systems typically run for a long time and resources are finite. 

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..

View solution in original post

4 REPLIES 4
Posted on July 30, 2017 at 15:02

I suppose one could get better at searching the Internet and reviewing ARM documentation, as well as experimenting with the generated code to see how it functions and interacts with the processor. This is a multidimensional problem which requires you to understand and connect a lot of information and knowledge. 

Thumb would be 16-bits code used by the Cortex processor, ARM would be the alternative 32-bit code not suported here. The size is the number of bytes consumed by the opcodes and literals for the machine code describing the function. The stack details tend to measure the local automatic variables, using worst case scoping, and sub function that may be called. Assumes all code points are visited. finding paths with largest scope contributions, and call trees. 

Experiment and review in the context of the code output. Use manual static analysis to cross check output.

Contrast with stack usage in the dynamic case.

If using malloc/free be conscious of leakage and fragmentation issues with the heap, embedded systems typically run for a long time and resources are finite. 

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal
Posted on August 05, 2017 at 12:23

Most linker generate a map file which typically build recursively all the stack and ram used. If you want to know the max stack area needed, assuming no rtos and no recurse or ram functions, add the deepest stack size for main and add up all interrupts stack budget. If the code use function pointers things become more challenging.

Posted on August 05, 2017 at 12:02

An interesting thing I've met today. that is I've set the heap size in startup file to 0x0000, but the program could still work out the correct result. I'm using Keil=MDK  and STM32F746, what's the reason?

Posted on August 05, 2017 at 12:27

Yes, I could see the max depth and stack size in the call stack.html file