C++ Logo

std-proposals

Advanced search

Re: [std-proposals] #include <debug>

From: Jeremy Rifkin <rifkin.jer_at_[hidden]>
Date: Fri, 29 Nov 2024 10:35:19 -0600
> Another thing would be to keep track of all the places from which a
function is invoked

Why do you need standard library support and code instrumentation to do this?

Jeremy

On Fri, Nov 29, 2024 at 4:06 AM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> On Thu, Nov 28, 2024 at 10:55 PM Sebastian Wittmeier via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > The return address is not necessarily a function pointer.
>
>
> I use a function pointer to store an address of code memory (as
> opposed to data memory).
>
> So if we have the address of a function:
>
> void (*func)(void) = &SomeFunction;
>
> And if we know that the first 16 bytes of that function are the
> machine code to test a variable and jump, then we can add 16 to the
> function pointer to elide the test. Of course this would be very
> low-level nitty gritty debugging.
>
> Another thing would be to keep track of all the places from which a
> function is invoked (i.e. keep track of all the call sites), something
> like:
>
> void Func(void)
> {
> static thread_local std::set<void(*)(void)> callsites;
> callsites.insert( std::debug::get_return_address() );
> }
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2024-11-29 16:35:33