]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libdwfl_stacktrace [11/12]: add dwflst_perf_sample_getframes
authorSerhei Makarov <serhei@serhei.io>
Fri, 25 Apr 2025 14:55:53 +0000 (10:55 -0400)
committerAaron Merey <amerey@redhat.com>
Fri, 25 Apr 2025 15:55:37 +0000 (11:55 -0400)
commitd315c09d3d3a104caf861ebf9615fb66ad84a4b7
tree69556b7f2ab4cf82f618c1c13a9f44a99dbeba4e
parent54aab7cfd3008b8fc814a8673f1f6dcb4b2be182
libdwfl_stacktrace [11/12]: add dwflst_perf_sample_getframes

This is a new interface for unwinding that doesn't require the Dwfl to
be attached to a live process (via ptrace) or via corefile. Instead,
data from a perf_events stack sample is provided along with an Elf
struct used to identify the architecture. Based on code from
eu-stacktrace.

* libdwfl_stacktrace/libdwfl_stacktrace.h (dwflst_perf_sample_getframes):
  New function.
* libdwfl_stacktrace/dwflst_perf_frame.c
  (struct __libdwfl_stacktrace_perf_sample_info): New struct, based on
  src/stacktrace.c struct sample_arg.
  (sample_next_thread): New function, based on src/stacktrace.c.
  (sample_getthread): Ditto.
  (copy_word_64): New macro, based on src/stacktrace.c.
  (copy_word_32): Ditto.
  (copy_word): Ditto.
  (elf_memory_read): New function, based on src/stacktrace.c.
  (sample_memory_read): Ditto.
  (sample_set_initial_registers): Ditto.
  (sample_detach): Ditto.
  (sample_thread_callbacks): New struct, set of callbacks based on
  src/stacktrace.c sample_thread_callbacks.
  (dwflst_perf_sample_getframes): New function, based on parts of
  src/stacktrace.c sysprof_find_dwfl. If the Dwfl is not attached,
  attaches it with sample_thread_callbacks and
  __libdwfl_stacktrace_perf_sample_info. Populates the
  __libdwfl_stacktrace_perf_sample_info with data from the stack
  sample and calls dwfl_getthread_frames to unwind it using the
  sample_thread_callbacks.
* libdw/libdw.map (ELFUTILS_0.193_EXPERIMENTAL): Add
  dwflst_perf_sample_getframes.

Signed-off-by: Serhei Makarov <serhei@serhei.io>
libdw/libdw.map
libdwfl_stacktrace/dwflst_perf_frame.c
libdwfl_stacktrace/libdwfl_stacktrace.h