diff options
author | Serhei Makarov <[email protected]> | 2025-04-02 17:09:09 -0400 |
---|---|---|
committer | Serhei Makarov <[email protected]> | 2025-04-25 10:09:58 -0400 |
commit | bbd862311497093067e49621cc3f723cebb407ee (patch) | |
tree | 5d5bbbb6c40a763100edd2d3d59759e6c6a8de80 | |
parent | fcdadfa27be027e988de1dcd67344e4a5faf0c39 (diff) |
libdwfl [2/12]: expose setfunc callback for libdwflP+libebl clients
Changes for v6:
- Minor fixes as requested.
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.
-rw-r--r-- | libdwfl/libdwflP.h | 11 | ||||
-rw-r--r-- | 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..150d26f9 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); + /* 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 |