]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl [2/12]: expose setfunc callback for libdwflP+libebl clients
authorSerhei Makarov <serhei@serhei.io>
Fri, 25 Apr 2025 14:55:44 +0000 (10:55 -0400)
committerAaron Merey <amerey@redhat.com>
Fri, 25 Apr 2025 15:54:12 +0000 (11:54 -0400)
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.

Signed-off-by: Serhei Makarov <serhei@serhei.io>
libdwfl/libdwflP.h
libdwfl/linux-pid-attach.c

index 6ec5c96643a9c2265a48e2329b94632d816081d5..150d26f953800481efe3cd92287b24d053be78c1 100644 (file)
@@ -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;
index 0eec1e886975ede0c1db83b6774b78cdda62cca1..a6e4e41ad3f491df70514877779a3cd00eecbac6 100644 (file)
@@ -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