]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Improve robustness of stack usage tracking in concurrent contexts
authorJose Ruiz <ruiz@adacore.com>
Tue, 22 Jul 2025 09:22:36 +0000 (11:22 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 23 Sep 2025 13:01:13 +0000 (15:01 +0200)
commit0a10fc5d72f51eec249d5ec9976089dc6211c7c3
treec49a8bcfef82afc4d09cf22fd51058df56d33dea
parent346b4921f994360194c4582066a52c484c2687fc
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.
gcc/ada/libgnarl/s-stusta.adb
gcc/ada/libgnat/s-stausa.adb
gcc/ada/libgnat/s-stausa.ads