ada: Improve robustness of stack usage tracking in concurrent contexts
Enabled computation of stack usage for tasks that have already
initialized their stacks with the expected fill pattern.
Ensured that stack usage snapshots for tasks are taken while
the runtime is locked, to maintain consistency.
For the environment task, approximated the stack origin using
the topmost stack known address during initialization, and take
into account that the Stack_Analyzer object is not part of its
ATCB.
gcc/ada/ChangeLog:
* libgnarl/s-stusta.adb (Report_Impl): Export a copy of
the current stack usage while holding the runtime lock.
(Report_For_Task): Do not compute stack usage for a task
that has not yet initialized its stack with the expected
pattern.
(Report_For_Task): The Stack_Analyzer object for the
environment task is not part of its ATCB. For the rest of
the tasks wait until we have initialized the stack pattern
before computing stack usage.
(Report_All_Tasks, Get_All_Tasks_Usage,
Get_Current_Task_Usage): Adapt to the new interface from
Report_Impl. Take into account that Result_Array can be
null. When we don't store stack results for a task we
need to compute it when requested.
(Print): Handle the case when we don't know the stack
usage to be reported.
* libgnat/s-stausa.adb (Initialize): For the environment
task, approximate the stack origin with the topmost
stack address that is known.
* libgnat/s-stausa.ads: Clarify comments.