Description
Hello,
I am using a custom allocator to trace allocations and deallocations when debugging code. I was wondering if adding #[track_caller]
to the GlobalAlloc::alloc
and GlobalAlloc::dealloc
methods could give me the origin of allocations (even if it ends up in libstd), but unfortunately, it only gives me the position of the #[global_allocator]
attribute.
As an alternative, I am trying to obtain it with the backtrace crate, but apparently I cannot resolve the symbols for a stackframe (I suspect it would allocate), so I would need to store the instruction address at runtime, and post process the result with gimli.
Making #[track_caller]
usable from a custom allocator would simplify a lot that use case, since everything returned by panic::Location::caller()
is 'static
, so there are no allocations.
So I'm not sure if this request fits the use case of #[track_caller]
but I'm probably not the only one wanting a nice way to track allocations :)