On Thu, Apr 24, 2025 at 5:48 PM Serhei Makarov <ser...@serhei.io> wrote:
>
> Changes for v2:
>
> - No longer exposing this in public libdwfl.h api.
>
> * * *
>
> Renaming pid_set_initial_registers to
> __libdwfl_set_initial_registers_thread and adding to libdwflP.h.
>
> This callback was private to one file, but now we need to access it
> from the perf_events sampling code as well.
>
> * libdwfl/libdwflP.h (__libdwfl_set_initial_registers_thread): New function.
> * libdwfl/linux-pid-attach.c (__libdwfl_set_initial_registers_thread):
>   Renamed from pid_thread_state_registers_cb.
>   (pid_set_initial_registers): Pass the newly renamed callback.
> ---
>  libdwfl/libdwflP.h         | 11 ++++++++++-
>  libdwfl/linux-pid-attach.c | 12 +++++++-----
>  2 files changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h
> index 6ec5c966..2b7eb8da 100644
> --- a/libdwfl/libdwflP.h
> +++ b/libdwfl/libdwflP.h
> @@ -1,5 +1,5 @@
>  /* Internal definitions for libdwfl.
> -   Copyright (C) 2005-2015, 2018, 2024 Red Hat, Inc.
> +   Copyright (C) 2005-2015, 2018, 2024-2025 Red Hat, Inc.
>     This file is part of elfutils.
>
>     This file is free software; you can redistribute it and/or modify
> @@ -591,6 +591,15 @@ extern Dwfl_Module *__libdwfl_report_offline (Dwfl 
> *dwfl, const char *name,
>  extern void __libdwfl_process_free (Dwfl_Process *process)
>    internal_function;
>
> +/* Basic implementation of Dwfl_Thread_Callbacks.set_initial_registers.
> +   ARG must be a Dwfl_Thread *.  Calls dwfl_thread_state_register_pc
> +   if firstreg is -1 (indicating arch PC), dwfl_thread_state_registers
> +   otherwise.  */
> +extern bool __libdwfl_set_initial_registers_thread (int firstreg,
> +                                            unsigned nregs,
> +                                            const Dwarf_Word *regs,
> +                                            void *arg);
> +

Some missing whitespace.

>  /* Update STATE->unwound for the unwound frame.
>     On error STATE->unwound == NULL
>     or STATE->unwound->pc_state == DWFL_FRAME_STATE_ERROR;
> diff --git a/libdwfl/linux-pid-attach.c b/libdwfl/linux-pid-attach.c
> index 0eec1e88..a6e4e41a 100644
> --- a/libdwfl/linux-pid-attach.c
> +++ b/libdwfl/linux-pid-attach.c
> @@ -1,5 +1,5 @@
>  /* Get Dwarf Frame state for target live PID process.
> -   Copyright (C) 2013, 2014, 2015, 2018 Red Hat, Inc.
> +   Copyright (C) 2013, 2014, 2015, 2018, 2025 Red Hat, Inc.
>     This file is part of elfutils.
>
>     This file is free software; you can redistribute it and/or modify
> @@ -304,9 +304,11 @@ pid_getthread (Dwfl *dwfl __attribute__ ((unused)), 
> pid_t tid,
>
>  /* Implement the ebl_set_initial_registers_tid setfunc callback.  */
>
> -static bool
> -pid_thread_state_registers_cb (int firstreg, unsigned nregs,
> -                              const Dwarf_Word *regs, void *arg)
> +bool
> +/* XXX No internal_function annotation,
> +   as this function gets passed as ebl_tid_registers_t *.  */
> +__libdwfl_set_initial_registers_thread (int firstreg, unsigned nregs,
> +                                  const Dwarf_Word *regs, void *arg)
>  {
>    Dwfl_Thread *thread = (Dwfl_Thread *) arg;
>    if (firstreg == -1)
> @@ -338,7 +340,7 @@ pid_set_initial_registers (Dwfl_Thread *thread, void 
> *thread_arg)
>    Dwfl_Process *process = thread->process;
>    Ebl *ebl = process->ebl;
>    return ebl_set_initial_registers_tid (ebl, tid,
> -                                       pid_thread_state_registers_cb, 
> thread);
> +                                       
> __libdwfl_set_initial_registers_thread, thread);
>  }
>
>  static void
> --
> 2.47.0
>

With the formatting change mentioned above, LGTM.

Aaron

Reply via email to