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.

TMS570LS31x: Worst Case Stack Analysis (cg_xml and call graph)

1. When using the cg_xml stack analysis tool, is it possible to see the worst case stack usage (wcs) of the assembly functions in the call graph ? When I run the call graph I only see wcs = ??? for the assembly functions.

2. Just for informational purposes, how does the cg_xml stack analysis tool calculate or determine worst case stack usage (wcs) when a variable is declared and used only inside a loop ?

Just as a test, when I declare a variable in a for loop and use that variable only in the for loop, then run the call graph for this test build, there doesn't seem to be any difference in the wcs for that particular function. Does this variable declaration have any impact the wcs for the function ? Additionally, optimizations are set to off in the project.

For example, there was no difference in the wcs for the function that the following code was placed in:

for (i = 0; i < 3; i++)
{

int test_count = 2;
test_count = test_count + 3;

...

}

Thanks,
Eric

  • Eric Y said:
    is it possible to see the worst case stack usage (wcs) of the assembly functions in the call graph ?

    By default, the amount of stack used by an assembly function is not known.  An assembly programmer can change this by adding a line of code similar to ...

    name_of_function:    .asmfunc   stack_usage(12)   ; uses 12 bytes of stack space

    To learn more about the .asmfunc directive, please search the TI ARM assembly tools manual for the phrase mark function boundaries.  

    Eric Y said:
    how does the cg_xml stack analysis tool calculate or determine worst case stack usage (wcs) when a variable is declared and used only inside a loop ?

    Such a local variable is handled no differently than one declared at the start of the function.  In this particular case, I suspect the local variable is allocated to a register, and not to the stack.  

    More background ... The compiler allocates space for all the local variables all at once, without regard to their scope in the function.  The amount of stack used by this action is recorded in the Dwarf debug information with an attribute named DW_AT_frame_base or DW_AT_TI_max_frame_size.  The source code for all the cg_xml utilities is in the package.  To see the code for call_graph, view the file install_location\ofd\call_graph.pl.  

    Thanks and regards,

    -George