Overriding Default Storage Pool for Another Package

I want to track all allocations done while running a test suite on another package so I can report leaks and perform other analyses.

pragma Default_Storage_Pool doesn’t seem to work on external packages and I’m looking for a way to do this globally. In other circumstances I might use Valgrind or BoehmGC, but I’m looking for an Ada-specific solution that I can hook extra logic into.

I seem to recall the default storage pool pragma can be used as a configuration pragma.
Barring that, I think you might be able to achieve this with generic.

Generic
 Default : in out Storage_Pool;
Package Testing_Base is
  Pragma Default_Storage_Pool( Default ); -- Here? Or on the child-generics?
End Testing_Base;

then as child/nested packages

Generic
  with Procedure Procedure_to_Test;
Package Child_Procedure is
 -- …

I think… it’s been a while since I messed w/ storage-pools.

I’d recommend ensuring you have a working logging storage-pool, and adding some instrumentation to log what it’s doing, then swapping to your actual-custom pool.

While it’s not specific to Ada or storage pools, I had a good experience recently with ‘-fsanitize=leak’

There are a lot of related compile switches and configuration options set with an environment variable. I found it useful to have the report logged to a file.

LSAN exists in both clang and gcc, but the config should be the same.