{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.
---
 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. */
+__libdwfl_set_initial_registers_thread (int firstreg, unsigned nregs,
+                                  const Dwarf_Word *regs, void *arg)
+{
+  Dwfl_Thread *thread = (Dwfl_Thread *) arg;
+  if (firstreg == -1)
+    {
+      assert (nregs == 1);
+      INTUSE(dwfl_thread_state_register_pc) (thread, *regs);
+      return true;
+    }
+  else if (firstreg == -2)
+    {
+      assert (nregs == 1);
+      INTUSE(dwfl_thread_state_registers) (thread, firstreg, nregs, regs);
+      return true;
+     }
+  assert (nregs > 0);
+  return INTUSE(dwfl_thread_state_registers) (thread, firstreg, nregs, regs);
+}
diff --git a/libdwfl/linux-pid-attach.c b/libdwfl/linux-pid-attach.c
index a6e4e41a..9472b041 100644
--- a/libdwfl/linux-pid-attach.c
+++ b/libdwfl/linux-pid-attach.c
@@ -302,31 +302,6 @@ pid_getthread (Dwfl *dwfl __attribute__ ((unused)), pid_t 
tid,
   return true;
 }
 
-/* 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 *.  */
-__libdwfl_set_initial_registers_thread (int firstreg, unsigned nregs,
-                                  const Dwarf_Word *regs, void *arg)
-{
-  Dwfl_Thread *thread = (Dwfl_Thread *) arg;
-  if (firstreg == -1)
-    {
-      assert (nregs == 1);
-      INTUSE(dwfl_thread_state_register_pc) (thread, *regs);
-      return true;
-    }
-  else if (firstreg == -2)
-    {
-      assert (nregs == 1);
-      INTUSE(dwfl_thread_state_registers) (thread, firstreg, nregs, regs);
-      return true;
-     }
-  assert (nregs > 0);
-  return INTUSE(dwfl_thread_state_registers) (thread, firstreg, nregs, regs);
-}
-
 static bool
 pid_set_initial_registers (Dwfl_Thread *thread, void *thread_arg)
 {
-- 
2.52.0

Reply via email to