Previous: Static Stack Usage Analysis, Up: Stack Related Facilities


22.3 Dynamic Stack Usage Analysis

It is possible to measure the maximum amount of stack used by a task, by adding a switch to gnatbind, as:

     $ gnatbind -u0 file

With this option, at each task termination, its stack usage is output on stderr. It is not always convenient to output the stack usage when the program is still running. Hence, it is possible to delay this output until program termination. for a given number of tasks specified as the argument of the -u option. For instance:

     $ gnatbind -u100 file

will buffer the stack usage information of the first 100 tasks to terminate and output this info at program termination. Results are displayed in four columns:

Index | Task Name | Stack Size | Actual Use [min - max]

where:

Index
is a number associated with each task.
Task Name
is the name of the task analyzed.
Stack Size
is the maximum size for the stack.
Actual Use
is the measure done by the stack analyzer. In order to prevent overflow, the stack is not entirely analyzed, and it's not possible to know exactly how much has actually been used. The real amount of stack used is between the min and max values.

The environment task stack, e.g. the stack that contains the main unit, is only processed when the environment variable GNAT_STACK_LIMIT is set.