Hi Serhei,
On Fri, Mar 13, 2026 at 11:11:34AM -0400, Serhei Makarov wrote:
> {alternate option to my prior PR33974 patch}
>
> libdwfl_stacktrace uses __libdwfl_set_initial_registers_thread but it
> is wrapped by #ifdef __linux__, causing build errors on non-Linux
> platforms.
>
> * linux-pid-attach.c (__libdwfl_set_initial_registers_thread):
> Remove from inside the '#ifdef __linux__'.
> * dwfl_frame_regs.c (__libdwfl_set_initial_registers_thread):
> Move here.
I like variant over the v1 version.
__libdwfl_set_initial_registers_thread is a "generic" (callback)
function with no special architecture/os issues, so it feels better to
define it in the generic dwfl_frame_regs.c instead of "hiding" inside
linux-pid-attach.c.
One "comment" on an (already existing) comment below.
> ---
> libdwfl/dwfl_frame_regs.c | 26 ++++++++++++++++++++++++++
> libdwfl/linux-pid-attach.c | 25 -------------------------
> 2 files changed, 26 insertions(+), 25 deletions(-)
>
> diff --git a/libdwfl/dwfl_frame_regs.c b/libdwfl/dwfl_frame_regs.c
> index 572ac676..fd76605a 100644
> --- a/libdwfl/dwfl_frame_regs.c
> +++ b/libdwfl/dwfl_frame_regs.c
> @@ -77,3 +77,29 @@ dwfl_frame_reg (Dwfl_Frame *state, unsigned regno,
> Dwarf_Word *val)
> return res;
> }
> INTDEF(dwfl_frame_reg)
> +
> +/* Implement the ebl_set_initial_registers_tid setfunc callback. */
> +
> +bool
> +/* XXX No internal_function annotation,
> + as this function gets passed as ebl_tid_registers_t *
> + by linux-pid-attach.c and libdwfl_stacktrace. */
This is correct, but the XXX makes it look like it is something that
might still need change/inspection. So please remove it.
And maybe add the explanation that __internal_function may change the
calling convention (but currently only on i386) and so cannot be used
for functions that are passed as callback functions because those need
to use standard calling convention.
Thanks,
Mark