Date: Mon, 17 Apr 2023 12:25:05 +0100
On Mon, Apr 17, 2023 at 12:09 PM Frederick Virchanza Gotham
<cauldwell.thomas_at_[hidden]> wrote:
>
> Also maybe it would be helpful if the return address were available too,
> something like:
>
> namespace std {
> void (*return_address(void))(void) noexcept;
> }
>
> The contents of "return_address.S" on x86_64:
>
> return_address:
> mov rax,[rsp] ; return address is at top of stack
> ret
Also if we had a boolean to say whether or not the current invocation
is a recursive call, i.e.:
namespace std {
bool is_recursive_call(void) noexcept;
}
The assembler for this function would look at the return address on
the stack and determine
whether or not the return address is inside the code space for the
current function.
Of course though it would only be able to detect direct recursion, not
indirect recursion. An
example of indirect recursion would be where FuncA calls FuncB calls
FuncA, it won't be
able to detect that recursion. But it can detect FuncA calls FuncA.
<cauldwell.thomas_at_[hidden]> wrote:
>
> Also maybe it would be helpful if the return address were available too,
> something like:
>
> namespace std {
> void (*return_address(void))(void) noexcept;
> }
>
> The contents of "return_address.S" on x86_64:
>
> return_address:
> mov rax,[rsp] ; return address is at top of stack
> ret
Also if we had a boolean to say whether or not the current invocation
is a recursive call, i.e.:
namespace std {
bool is_recursive_call(void) noexcept;
}
The assembler for this function would look at the return address on
the stack and determine
whether or not the return address is inside the code space for the
current function.
Of course though it would only be able to detect direct recursion, not
indirect recursion. An
example of indirect recursion would be where FuncA calls FuncB calls
FuncA, it won't be
able to detect that recursion. But it can detect FuncA calls FuncA.
Received on 2023-04-17 11:25:17