Date: Fri, 29 Nov 2024 10:06:00 +0000
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_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() );
}
Received on 2024-11-29 10:06:13