[PATCH] debuginfod-find.1: note on how to find a comp_dir

2023-01-10 Thread Serhei Makarov
ewbies figuring out what a CU compilation-directory is. Signed-off-by: Serhei Makarov --- doc/debuginfod-find.1 | 13 + 1 file changed, 13 insertions(+) diff --git a/doc/debuginfod-find.1 b/doc/debuginfod-find.1 index 957ec7e7..7d577bab 100644 --- a/doc/debuginfod-find.1 +++ b/doc/de

eu-stacktrace: roadmap and discussion thread

2023-05-08 Thread Serhei Makarov
cope given the amount of code that would need to be written to handle profile data other than stack traces. Usage instructions will be kept up-to-date in README.eu-stacktrace on the topic branch: - https://sourceware.org/cgit/elfutils/tree/README.eu-stacktrace?h=users/serhei/eu-stacktrace

Re: eu-stacktrace: roadmap and discussion thread

2023-05-11 Thread Serhei Makarov
On Mon, May 8, 2023, at 5:50 PM, Christian Hergert wrote: > First off, this all sounds great! > ... > > From a consumption standpoint, it would be nice if Sysprof could get a > perf stream where the PERF_SAMPLE_STACK are transparently converted to > PERF_SAMPLE_CALLCHAIN. I don't think eu-stackt

Re: eu-stacktrace: roadmap and discussion thread

2023-05-11 Thread Serhei Makarov
On Tue, May 9, 2023, at 2:02 PM, Milian Wolff wrote: > Hey Serhey, > > sounds like a fun project. If you want to see some prior art in that area, do > have a look at perfparser [1], esp. [2], and [3]. We solved quite a few of > the > problems you might encounter in this area. Esp. for good perfo

Re: eu-stacktrace: roadmap update

2024-07-03 Thread Serhei Makarov
On Mon, May 8, 2023, at 8:33 AM, Serhei Makarov wrote: > Usage instructions will be kept up-to-date in README.eu-stacktrace on > the topic branch: > > - > https://sourceware.org/cgit/elfutils/tree/README.eu-stacktrace?h=users/serhei/eu-stacktrace Hello, I wanted to send an up-

[PATCH 1/4] eu-stacktrace: add eu-stacktrace tool

2024-10-15 Thread Serhei Makarov
new tool. Signed-off-by: Serhei Makarov --- src/stacktrace.c | 1566 ++ 1 file changed, 1566 insertions(+) create mode 100644 src/stacktrace.c diff --git a/src/stacktrace.c b/src/stacktrace.c new file mode 100644 index ..ebd914e5 --- /dev/null

[PATCH 2/4] eu-stacktrace: configury for initial version (x86/sysprof only)

2024-10-15 Thread Serhei Makarov
. * configure.ac: Add configure checks and conditionals for stacktrace tool. * src/Makefile.am: Add stacktrace tool conditional on ENABLE_STACKTRACE. Signed-off-by: Serhei Makarov --- configure.ac| 66 - src/Makefile.am | 9 ++- 2 files changed

[PATCH 3/4] eu-stacktrace: add unwind origin diagnostics

2024-10-15 Thread Serhei Makarov
d_source to the data displayed in the final summary table. Signed-off-by: Serhei Makarov --- libdw/libdw.map| 2 ++ libdwfl/dwfl_frame.c | 31 ++- libdwfl/frame_unwind.c | 14 +++--- libdwfl/libdwfl.h | 20 +++- libdwfl/li

[PATCH 4/4] eu-stacktrace: add unwind origin diagnostics to eu-stack

2024-10-15 Thread Serhei Makarov
. (parse_opt): Add --cfi-type,-c option to set show_unwound_source. (main): Ditto. * tests/run-stack-i-test.sh: Add testcase for --cfi-type. Signed-off-by: Serhei Makarov --- libdwfl/dwfl_frame.c | 2 ++ libdwfl/libdwfl.h | 1 + src/stack.c | 31

[PATCH v2 3/5] libdwfl: add unwind origin diagnostics

2024-10-17 Thread Serhei Makarov
in): Add unwind_source to the data displayed in the final summary table. Signed-off-by: Serhei Makarov --- libdw/libdw.map| 2 ++ libdwfl/dwfl_frame.c | 31 ++- libdwfl/frame_unwind.c | 14 +++--- libdwfl/libdwfl.h | 22 +- libdwfl/li

[PATCH v2 4/5] src: add unwind origin diagnostics to eu-stack

2024-10-17 Thread Serhei Makarov
ion to set show_unwound_source. (main): Ditto. * tests/run-stack-i-test.sh: Add testcase for --cfi-type. Signed-off-by: Serhei Makarov --- src/stack.c | 30 +++--- tests/run-stack-i-test.sh | 15 ++- 2 files changed, 37 insertions(+), 8 deletions(-) diff -

[PATCH v2 5/5] NEWS: add entry for eu-stacktrace

2024-10-17 Thread Serhei Makarov
Signed-off-by: Serhei Makarov --- NEWS | 7 +++ 1 file changed, 7 insertions(+) diff --git a/NEWS b/NEWS index 410bccc1..01909c0c 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,13 @@ debuginfod: Add per-file signature verification for integrity debuginfod: New API for metadata queries: file

[PATCH v2 1/5] src: add eu-stacktrace tool

2024-10-17 Thread Serhei Makarov
gnome.sysprof3.profile is not registered" error will result. * src/stacktrace.c: Add new tool. Signed-off-by: Serhei Makarov --- src/stacktrace.c | 1571 ++ 1 file changed, 1571 insertions(+) create mode 100644 src/stacktrace.c diff --git a/src

[PATCH v2 2/5] configure.ac: eu-stacktrace initial version (x86/sysprof only)

2024-10-17 Thread Serhei Makarov
released Sysprof version we can point to for the patches. * configure.ac: Add configure checks and conditionals for stacktrace tool. * src/Makefile.am: Add stacktrace tool conditional on ENABLE_STACKTRACE. Signed-off-by: Serhei Makarov --- configure.ac| 56

Re: [PATCH] sparc_attrs.c: Prevent buffer overflow in sparc_check_object_attribute

2024-11-05 Thread Serhei Makarov
On Tue, Nov 5, 2024, at 9:25 AM, Anton Moryakov wrote: > Record Length Limit: We use strncat to add a line indicating the > available remaining_size. This prevents writing beyond the allocated > memory. > Remaining space update: remaining_size is updated after each entry to > ensure that row

Re: Preparing for the 0.192 release on Friday October 18

2024-10-15 Thread Serhei Makarov
On Thu, Oct 3, 2024, at 12:22 PM, Aaron Merey wrote: > If your patch is still under review [1] or you have other patches you'd > like merged before the release, please let us know. I posted a cleaned-up patch series for eu-stacktrace this morning [2]. Hoping that can make it in. [2]: https://pa

Re: [PATCH 1/4] eu-stacktrace: add eu-stacktrace tool

2024-10-17 Thread Serhei Makarov
On Wed, Oct 16, 2024, at 11:37 PM, Aaron Merey wrote: > Please add an eu-stacktrace entry to NEWS. Ok, will do. > I tried to run this but I kept getting: > Failed to complete recording: GDBus.Error[...]: Action > org.gnome.sysprof3.profile is not registered Right. To have sysprof work requ

Re: [PATCH 3/4] eu-stacktrace: add unwind origin diagnostics

2024-10-17 Thread Serhei Makarov
On Wed, Oct 16, 2024, at 11:39 PM, Aaron Merey wrote: > Hi Serhei, > > On Tue, Oct 15, 2024 at 11:28 AM Serhei Makarov wrote: >> >> Track the method used to unwind each Dwfl_Frame using an enum field >> unwound_source; provide access to the field. Then use that in

Re: [PATCH 2/4] eu-stacktrace: configury for initial version (x86/sysprof only)

2024-10-17 Thread Serhei Makarov
On Wed, Oct 16, 2024, at 11:38 PM, Aaron Merey wrote: > Using less wide indentation throughout would help make the configure.ac > changes more readable. Otherwise this patch LGTM. Ok, my code imitated the offset for the debuginfod configury immediately above, but I'll update the patch to use 3

Re: [PATCH 1/4] eu-stacktrace: add eu-stacktrace tool

2024-10-17 Thread Serhei Makarov
On Thu, Oct 17, 2024, at 12:18 PM, Aaron Merey wrote: > I'm seeing eu-stacktrace built by default on x86 with no > --enable-stacktrace given to configure. Now I'm waffling back and forth on what to do. Mark wants to enable eu-stacktrace build on one of the buildbots. The current behaviour (whic

Re: [PATCH 4/4] eu-stacktrace: add unwind origin diagnostics to eu-stack

2024-10-17 Thread Serhei Makarov
On Thu, Oct 17, 2024, at 1:00 PM, Mark Wielaard wrote: > This part looks a little iffy IMHO. > It feels like a layering violation. > The meaning of DWFL_UNWOUND_INLINE is also different from the others. > There is no worst/best ordering here. > They are not connected to frames. > > Is there a wa

Re: [PATCH 4/4] eu-stacktrace: add unwind origin diagnostics to eu-stack

2024-10-17 Thread Serhei Makarov
On Thu, Oct 17, 2024, at 1:22 PM, Mark Wielaard wrote: > I think (but haven't tried) only print_frame has to have a char * > argument, print_inline_frames and print_frames can still pass around an > Dwfl_Unwound_Source. Both print_frames and print_inline_frames can then > call print_frame with t

Re: [RFC] sketch of an unwinder cache interface for elfutils libdwfl

2024-12-11 Thread Serhei Makarov
On Wed, Dec 11, 2024, at 9:46 AM, William Cohen wrote: > Hi Serhei, > > The dwfl_report_proc_map() will handle when things are added to the > memory map. Is there anything to handle the inverse event when memory > is removed from the process memory map, such as a dlcose()? > Interestingly, li

[RFC] sketch of an unwinder cache interface for elfutils libdwfl

2024-12-10 Thread Serhei Makarov
This email sketches an 'unwinder cache' interface for libdwfl, derived from recent eu-stacktrace code [1] and based on Christian Hergert's adaptation of eu-stacktrace as sysprof-live-unwinder [2]. The intent is to remove the need for a lot of boilerplate code that would be identical among profil

Re: [RFC] sketch of an unwinder cache interface for elfutils libdwfl

2024-12-13 Thread Serhei Makarov
On Wed, Dec 11, 2024, at 6:24 AM, Milian Wolff wrote: > On Dienstag, 10. Dezember 2024 22:42:25 Mitteleuropäische Normalzeit Serhei > Makarov wrote: >> This email sketches an 'unwinder cache' interface for libdwfl, derived from >> recent eu-stacktrace code [1] and

Re: [PATCH 01/13] libebl [1/13]: api for perf register handling, start with x86_64

2025-03-18 Thread Serhei Makarov
On Tue, Mar 18, 2025, at 10:04 AM, Mark Wielaard wrote: > In some other situations that is "solved" with marking the function > arguments with __attribute__ ((unused)) (which isn't true for x86_64, > but the compiler is fine with that). The other hack (that I'd go with, if there's no style objec

[PATCH 01/13] libebl [1/13]: api for perf register handling, start with x86_64

2025-03-16 Thread Serhei Makarov
First patch of a series that reworks eu-stacktrace functionality into a library interface for other profiling tools. * * * As it happens, Linux perf_events and DWARF can prescribe completely different layouts for the register file, requiring non-obvious code for translation. This makes sense to p

[PATCH 02/13] libdwfl [2/13]: expose setfunc callback for libdwfl+libebl clients

2025-03-16 Thread Serhei Makarov
Renaming to dwfl_set_initial_registers_thread. This callback was private to one file, but now that other tools (eu-stacktrace, sysprof via the dwfl_perf_sample_getframes) are invoking the ebl set_initial_registers_sample api, we need to expose it. Otherwise, clients would need to reimplement this

[PATCH 07/13] eu-stacktrace [7/13]: use Dwfl_Process_Tracker for Elf * caching

2025-03-16 Thread Serhei Makarov
* src/stacktrace.c (tracker): New global variable. (sample_callbacks): Use dwfl_process_tracker_find_elf for caching. (sysprof_init_dwfl): Use dwfl_begin_with_tracker. (main): Initialize and clean up tracker. --- src/stacktrace.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions

[PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-03-16 Thread Serhei Makarov
Since libebl is a private interface, subsequent patches in the series introduce another api wrapping the libebl perf register handling. In this patch, add an interface to access the preferred set of registers that libdwfl would like to see to allow proper unwinding of stack sample data. * libdwfl

[PATCH 08/13] libdwfl [8/13]: Dwfl* caching via dwfl_process_tracker

2025-03-16 Thread Serhei Makarov
The Dwfl_Process_Tracker also includes a dynamicsizehash cache which maps process ids to Dwfl * (or rather, dwfltracker_dwfl_info * allowing the table entry to be replaced). Dwfls created from the tracker are automatically added to it, and removed on dwfl_end(). * libdwfl/libdwflP.h (dwfltracker_

[PATCH 09/13] libdwfl [9/13]: add dwfl_process_tracker_find_pid

2025-03-16 Thread Serhei Makarov
New function that retrieves the Dwfl for a particular PID, or, if the Dwfl is absent, creates it via a provided callback and adds it to the table later, when the PID is confirmed via dwfl_attach_state. * libdwfl/libdwfl.h (dwfl_process_tracker_find_pid): New function. * libdwfl/dwfl_process_tracke

[PATCH 13/13] eu-stacktrace [13/13]: use dwfl_perf_sample_getframes

2025-03-16 Thread Serhei Makarov
Remove the code from src/stacktrace.c that is now covered by libdwfl/dwfl_perf_frame.c and dwfl_perf_sample_getframes. * src/stacktrace.c (show_memory_reads): Remove this verbose option as the relevant code is inside libdwfl now. (struct __sample_arg): Remove, handled by libdwfl/dwfl_perf_fram

[PATCH 12/13] libdwfl [12/13]: add dwfl_perf_sample_getframes

2025-03-16 Thread Serhei Makarov
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/libdw

[PATCH 11/13] libebl [11/13]: provide access to register file pc, sp

2025-03-16 Thread Serhei Makarov
These additional libebl hooks are needed to extract the location of the stack frame in-memory from the perf_events register sample, when dwfl_perf_sample_getframes is implemented in the next patch. Implementing x86_64 for now, just as with the earlier ebl patches. * libebl/libebl.h (ebl_sample_ba

[PATCH 10/13] eu-stacktrace [10/13]: use dwfl_process_tracker_find_pid

2025-03-16 Thread Serhei Makarov
Initial minimal change to ensure dwfl_process_tracker_find_pid is tested. For now, we keep the additional dwfltab code in stacktrace.c, since it's used to track statistics. In future follow-ups, it will be good to switch to storing eu-stacktrace statistics in dwfl->process->callbacks_arg. This req

[PATCH 03/13] libebl [3/13]: eu-stacktrace: use new register handling api

2025-03-16 Thread Serhei Makarov
Change the sample_set_initial_registers callback in eu-stacktrace to use the proper libebl ebl_set_initial_registers_sample function. * src/Makefile.am (stacktrace_LDADD): Add libebl. * src/stacktrace.c (sample_registers_cb): New function, though identical to pid_thread_state_registers_cb. (sa

[PATCH 05/13] libdwfl [5/13]: introduce Dwfl_Process_Tracker

2025-03-16 Thread Serhei Makarov
New data structure to coordinate caching Elf data among multiple Dwfl structs attached to different processes. Meant to reduce the overhead for profilers that use elfutils for unwinding. The caching is well-justified, as the prior approach (e.g. in eu-stacktrace, sysprof-live-unwinder) of creating

[PATCH 06/13] libdwfl [6/13]: Elf* caching via dwfl_process_tracker

2025-03-16 Thread Serhei Makarov
The Dwfl_Process_Tracker includes a dynamicsizehash cache which maps file paths to Elf * (or rather, dwfl_tracker_elf_info * storing fd and Elf *). We provide a dwfl_process_tracker_find_elf callback which checks the cache for an already-loaded Elf * and, if missing, populates the cache with the f

Re: [PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-03-20 Thread Serhei Makarov
On Wed, Mar 19, 2025, at 5:36 PM, Mark Wielaard wrote: > Hi Serhei, > > On Sun, Mar 16, 2025 at 07:14:11PM -0400, Serhei Makarov wrote: >> Since libebl is a private interface, subsequent patches in the series >> introduce another api wrapping the libebl perf register handli

Re: [PATCH 05/13] libdwfl [5/13]: introduce Dwfl_Process_Tracker

2025-04-05 Thread Serhei Makarov
On Thu, Mar 20, 2025, at 8:01 AM, Mark Wielaard wrote: > Hi Serhei, > > On Sun, 2025-03-16 at 19:14 -0400, Serhei Makarov wrote: > I am wondering whether this isn't too abstract. libdwfl Dwfl's are > already super abstract so they can be used for running processes and &

[RFC v2] sketch of an unwinder cache interface for elfutils libdwfl

2025-04-05 Thread Serhei Makarov
On Tue, Dec 10, 2024, at 4:42 PM, Serhei Makarov wrote: > This email sketches an 'unwinder cache' interface for libdwfl, derived > from recent eu-stacktrace code [1] and based on Christian Hergert's > adaptation of eu-stacktrace as sysprof-live-unwinder [2]. The intent

Re: [PATCH 01/13] libebl [1/13]: api for perf register handling, start with x86_64

2025-04-01 Thread Serhei Makarov
On Wed, Mar 19, 2025, at 11:53 AM, Mark Wielaard wrote: > Also the libebl interface is very verbose for this mask. > Clearly copied from how frame_nregs is done. > So fine for now. But we might want to look into something simpler for > both of these. Both fetching frame_nregs and perf_frame_regs

Re: [PATCH 01/13] libebl [1/13]: api for perf register handling, start with x86_64

2025-03-17 Thread Serhei Makarov
On Sun, Mar 16, 2025, at 7:12 PM, Serhei Makarov wrote: > +bool > +x86_64_set_initial_registers_sample (const Dwarf_Word *regs, uint32_t > n_regs, > + uint64_t regs_mask, uint32_t abi, > + ebl_tid_regis

Re: [PATCH 06/13] libdwfl [6/13]: Elf* caching via dwfl_process_tracker

2025-04-04 Thread Serhei Makarov
On Thu, Apr 3, 2025, at 1:19 PM, Serhei Makarov wrote: > On Sun, Mar 16, 2025, at 7:15 PM, Serhei Makarov wrote: >> +/* The same callback, except this first attempts to look up a cached >> + Elf* and fd from the Dwfl_Module's Dwfl_Process_Tracker (if any). >> +

Re: [PATCH 06/13] libdwfl [6/13]: Elf* caching via dwfl_process_tracker

2025-04-03 Thread Serhei Makarov
On Sun, Mar 16, 2025, at 7:15 PM, Serhei Makarov wrote: > +/* The same callback, except this first attempts to look up a cached > + Elf* and fd from the Dwfl_Module's Dwfl_Process_Tracker (if any). > + If a new Elf* has to be created, this saves it to the cache. */

[PATCH v2 05/12] libdwfl [5/12]: introduce Dwfl_Process_Tracker

2025-04-04 Thread Serhei Makarov
New data structure to coordinate caching Elf data among multiple Dwfl structs attached to different processes. Meant to reduce the overhead for profilers that use elfutils for unwinding. The caching is well-justified, as the prior approach (e.g. in eu-stacktrace, sysprof-live-unwinder) of creating

[PATCH v2 02/12] libdwfl [2/12]: expose setfunc callback for libdwfl+libebl clients

2025-04-04 Thread Serhei Makarov
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. * libd

[PATCH v2 10/12] eu-stacktrace [10/12]: use dwfl_process_tracker_find_pid

2025-04-04 Thread Serhei Makarov
Initial minimal change to ensure dwfl_process_tracker_find_pid is tested. For now, we keep the additional dwfltab code in stacktrace.c, since it's used to track statistics. In future follow-ups, it will be good to switch to storing eu-stacktrace statistics in dwfl->process->callbacks_arg. This req

[PATCH v2 09/12] libdwfl [9/12]: add dwfl_process_tracker_find_pid

2025-04-04 Thread Serhei Makarov
Changes for v2: - Add locking for dwfltab. * * * New function that retrieves the Dwfl for a particular PID, or, if the Dwfl is absent, creates it via a provided callback and adds it to the table later, when the PID is confirmed via dwfl_attach_state. * libdwfl/libdwfl.h (dwfl_process_tracker_fi

[PATCH v2 03/12] libebl [3/12]: eu-stacktrace: use new register handling api

2025-04-04 Thread Serhei Makarov
Change the sample_set_initial_registers callback in eu-stacktrace to use the proper libebl ebl_set_initial_registers_sample function. * src/Makefile.am (stacktrace_LDADD): Add libebl. * src/stacktrace.c (sample_registers_cb): New function, though identical to pid_thread_state_registers_cb. (sa

[PATCH v2 06/12] libdwfl [6/12]: Elf* caching via dwfl_process_tracker

2025-04-04 Thread Serhei Makarov
Changes for v2: - Add locking for elftab. This is needed in addition to the intrinsic locking in dynamicsizehash_concurrent to avoid having cache_elf expose an incomplete dwfltracker_elf_info* entry to other threads while its data is being populated / replaced. - Tidy dwfl_process_tracker

[PATCH v2 08/12] libdwfl [8/12]: Dwfl* caching via dwfl_process_tracker

2025-04-04 Thread Serhei Makarov
The Dwfl_Process_Tracker also includes a dynamicsizehash cache which maps process ids to Dwfl * (or rather, dwfltracker_dwfl_info * allowing the table entry to be replaced). Dwfls created from the tracker are automatically added to it, and removed on dwfl_end(). * libdwfl/libdwflP.h (dwfltracker_

[PATCH v2 04/12] libdwfl [4/12]: add dwfl_perf_sample_preferred_regs_mask

2025-04-04 Thread Serhei Makarov
Changes for v2: - guard the linux/perf_events.h include properly with an #if defined __linux__ * * * Since libebl is a private interface, subsequent patches in the series introduce another api wrapping the libebl perf register handling. In this patch, add an interface to access the preferred se

[PATCH v2 07/12] eu-stacktrace [7/12]: use Dwfl_Process_Tracker for Elf * caching

2025-04-04 Thread Serhei Makarov
* src/stacktrace.c (tracker): New global variable. (sample_callbacks): Use dwfl_process_tracker_find_elf for caching. (sysprof_init_dwfl): Use dwfl_begin_with_tracker. (main): Initialize and clean up tracker. --- src/stacktrace.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions

[PATCH v2 01/12] libebl [1/12]: api for perf register handling, start with x86_64

2025-04-04 Thread Serhei Makarov
Changes for v2: - Merged commit 11 into commit 1 (both sample_base_addr/sample_pc and set_initial_registers_sample make sense to introduce in the same commit). - Added i386 backend and factored out common code. * * * First patch of a series that reworks eu-stacktrace functionality into a li

[PATCH v2 12/12] eu-stacktrace [12/12]: use dwfl_perf_sample_getframes

2025-04-04 Thread Serhei Makarov
Remove the code from src/stacktrace.c that is now covered by libdwfl/dwfl_perf_frame.c and dwfl_perf_sample_getframes. * src/stacktrace.c (show_memory_reads): Remove this verbose option as the relevant code is inside libdwfl now. (struct __sample_arg): Remove, handled by libdwfl/dwfl_perf_fram

[PATCH v2 11/12] libdwfl [11/12]: add dwfl_perf_sample_getframes

2025-04-04 Thread Serhei Makarov
Changes for v2: - use renamed __libdwfl_set_initial_registers_thread - oops, should use provided sample_arg->perf_regs_mask in sample_set_initial registers * * * 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.

Re: [PATCH v2 06/12] libdwfl [6/12]: Elf* caching via dwfl_process_tracker

2025-04-15 Thread Serhei Makarov
On Tue, Apr 15, 2025, at 2:15 PM, Christian Hergert wrote: > On 4/15/25 09:12, Serhei Makarov wrote: >> Option 2: expose one function, treat file_name and fd as optional input >> parameters. >> >> // normal use case >> module_name = "/usr/lib/whatever.

Re: [PATCH v2 06/12] libdwfl [6/12]: Elf* caching via dwfl_process_tracker

2025-04-15 Thread Serhei Makarov
On Fri, Apr 4, 2025, at 5:04 PM, Serhei Makarov wrote: > Changes for v2: > > - Add locking for elftab. This is needed in addition to the > intrinsic locking in dynamicsizehash_concurrent to avoid > having cache_elf expose an incomplete dwfltracker_elf_info* > entry to o

[PATCH v3 01/12] libebl [1/12]: api for perf register handling, start with x86_64

2025-04-17 Thread Serhei Makarov
Changes for v2: - Merged commit 11 into commit 1 (both sample_base_addr/sample_pc and set_initial_registers_sample make sense to introduce in the same commit). - Added i386 backend and factored out common code. * * * First patch of a series that reworks eu-stacktrace functionality into a li

[PATCH v3 02/12] libdwfl [2/12]: expose setfunc callback for libdwfl+libebl clients

2025-04-17 Thread Serhei Makarov
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. * libd

[PATCH v3 09/12] libdwfl [9/12]: add dwfl_process_tracker_find_pid

2025-04-17 Thread Serhei Makarov
Changes for v2: - Add locking for dwfltab. * * * New function that retrieves the Dwfl for a particular PID, or, if the Dwfl is absent, creates it via a provided callback and adds it to the table later, when the PID is confirmed via dwfl_attach_state. * libdwfl/libdwfl.h (dwfl_process_tracker_fi

[PATCH v3 03/12] libebl [3/12]: eu-stacktrace: use new register handling api

2025-04-17 Thread Serhei Makarov
Change the sample_set_initial_registers callback in eu-stacktrace to use the proper libebl ebl_set_initial_registers_sample function. * src/Makefile.am (stacktrace_LDADD): Add libebl. * src/stacktrace.c (sample_registers_cb): New function, though identical to pid_thread_state_registers_cb. (sa

[PATCH v3 07/12] eu-stacktrace [7/12]: use Dwfl_Process_Tracker for Elf * caching

2025-04-17 Thread Serhei Makarov
* src/stacktrace.c (tracker): New global variable. (sample_callbacks): Use dwfl_process_tracker_find_elf for caching. (sysprof_init_dwfl): Use dwfl_begin_with_tracker. (main): Initialize and clean up tracker. --- src/stacktrace.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions

[PATCH v3 06/12] libdwfl [6/12]: Elf* caching via dwfl_process_tracker

2025-04-17 Thread Serhei Makarov
Changes for v3: - Reworked elftab to incorporate dev/ino into the caching key (to allow caching modules from different filesystems e.g. a main filesystem and a container filesystem) and guard more carefully against collisions. - Add external API for implementing a custom find_elf callback

[PATCH v3 04/12] libdwfl [4/12]: add dwfl_perf_sample_preferred_regs_mask

2025-04-17 Thread Serhei Makarov
Changes for v2: - guard the linux/perf_events.h include properly with an #if defined __linux__ * * * Since libebl is a private interface, subsequent patches in the series introduce another api wrapping the libebl perf register handling. In this patch, add an interface to access the preferred se

[PATCH v3 10/12] eu-stacktrace [10/12]: use dwfl_process_tracker_find_pid

2025-04-17 Thread Serhei Makarov
Initial minimal change to ensure dwfl_process_tracker_find_pid is tested. For now, we keep the additional dwfltab code in stacktrace.c, since it's used to track statistics. In future follow-ups, it will be good to switch to storing eu-stacktrace statistics in dwfl->process->callbacks_arg. This req

[PATCH v3 11/12] libdwfl [11/12]: add dwfl_perf_sample_getframes

2025-04-17 Thread Serhei Makarov
Changes for v3: - use const void *stack, not void *, to allow users to pass a const stack sample Changes for v2: - use renamed __libdwfl_set_initial_registers_thread - oops, should use provided sample_arg->perf_regs_mask in sample_set_initial registers * * * This is a new interface for un

[PATCH v3 12/12] eu-stacktrace [12/12]: use dwfl_perf_sample_getframes

2025-04-17 Thread Serhei Makarov
Changes for v3: - Fix initialization of elf in sysprof_init_dwfl (previously triggered -Wmaybe-uninitialized). * * * Remove the code from src/stacktrace.c that is now covered by libdwfl/dwfl_perf_frame.c and dwfl_perf_sample_getframes. * src/stacktrace.c (show_memory_reads): Remove this verbo

Re: [PATCH v2 06/12] libdwfl [6/12]: Elf* caching via dwfl_process_tracker

2025-04-17 Thread Serhei Makarov
On Tue, Apr 15, 2025, at 3:32 PM, Serhei Makarov wrote: > it should not necessary to duplicate the FD on the Sysprof side, > unless Sysprof wants to use the FD for its own purposes independently > of what Elfutils is doing with it. Updated the Sysprof side of the code again to match

[PATCH v3 05/12] libdwfl [5/12]: introduce Dwfl_Process_Tracker

2025-04-17 Thread Serhei Makarov
New data structure to coordinate caching Elf data among multiple Dwfl structs attached to different processes. Meant to reduce the overhead for profilers that use elfutils for unwinding. The caching is well-justified, as the prior approach (e.g. in eu-stacktrace, sysprof-live-unwinder) of creating

[PATCH v3 08/12] libdwfl [8/12]: Dwfl* caching via dwfl_process_tracker

2025-04-18 Thread Serhei Makarov
Changes for v3: - Handle dwfl->process == NULL case in __libdwfl_remove_dwfl_from_tracker. * * * The Dwfl_Process_Tracker also includes a dynamicsizehash cache which maps process ids to Dwfl * (or rather, dwfltracker_dwfl_info * allowing the table entry to be replaced). Dwfls created from the t

Re: [PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-04-22 Thread Serhei Makarov
On Tue, Apr 22, 2025, at 10:17 AM, Aaron Merey wrote: >> One question this raises re: the Dwfl_Process_Tracker structure and where >> its implementation should be located. In the patches, the Dwfl struct >> implementation includes a pointer to a Dwfl_Process_Tracker. I’m not sure if >> elfuti

Re: [PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-04-22 Thread Serhei Makarov
On Mon, Apr 21, 2025, at 12:29 AM, Aaron Merey wrote:. > > I know we're close to the next release and I do want this work to be > included. My proposal is to move the current API out of libdwfl and > into a new library, as-is but clearly marked as experimental and > subject to possible API/ABI

Re: [PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-04-22 Thread Serhei Makarov
On Tue, Apr 22, 2025, at 9:45 AM, Aaron Merey wrote: > Hi Serhei, > > On Tue, Apr 22, 2025 at 9:27 AM Serhei Makarov wrote: >> >> On Mon, Apr 21, 2025, at 12:29 AM, Aaron Merey wrote:. >> > >> > I know we're close to the next release and I do want th

[PATCH v4 02/12] libdwfl [2/12]: expose setfunc callback for libdwflP+libebl clients

2025-04-23 Thread Serhei Makarov
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. * libd

[PATCH v4 06/12] libdwfl_stacktrace [6/12]: Elf* caching via dwflst_process_tracker

2025-04-23 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. - dwfl_module_getdwarf.c now uses the dwflst_tracker_cache_elf() interface instead of editing the elftab directly. Changes for v3: - Reworked elftab to incorporate dev/ino into the caching key (to allow caching modules from di

Re: [PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-04-22 Thread Serhei Makarov
On Tue, Apr 22, 2025, at 10:17 AM, Aaron Merey wrote: > dwfl_st or dwflst prefixes work for me. I think I slightly prefer > dwfl_st. As for where to define Dwfl_Process_tracker let's try to keep > it to the new dwfl_stacktraceP.h and if possible use forward > declarations to avoid circular depen

Re: [PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-04-22 Thread Serhei Makarov
On Tue, Apr 22, 2025, at 6:26 PM, Frank Ch. Eigler wrote: > Hi - > >> CCLD libdw.so >> /usr/bin/ld: ../libdwfl/libdwfl_pic.a(dwfl_module_getdwarf.os): in function >> `open_elf': >> Calling a public function across the library boundary should be no problem, >> but we run into this -- circu

Re: [PATCH v5 03/12] libebl [3/12]: eu-stacktrace: use new register handling api

2025-04-25 Thread Serhei Makarov
On Fri, Apr 25, 2025, at 1:54 AM, Aaron Merey wrote: > This commit could probably be merged with 2 or 12 with the > sample_set_initial_registers design decisions explained in the commit > message. But this patch as-is is harmless so if you prefer to keep it > this way that's ok with me. I'm incl

Re: [PATCH v5 06/12] libdwfl_stacktrace [6/12]: Elf* caching via dwflst_process_tracker

2025-04-25 Thread Serhei Makarov
On Fri, Apr 25, 2025, at 1:57 AM, Aaron Merey wrote: > Also if you haven't done so already, please run any manual tests under > valgrind memcheck (and helgrind if you are able to test this with > multithreading). Ran eu-stacktrace through valgrind; the content of the cache is marked as 'leaked'

[PATCH v6 04/12] libdwfl_stacktrace [4/12]: intro library, add dwflst_perf_sample_preferred_regs_mask

2025-04-25 Thread Serhei Makarov
Changes for v5: - Separate ELFUTILS_0.193_EXPERIMENTAL namespace, mark library experimental. Changes for v4: - Separate out libdwfl_stacktrace, as requested. Changes for v2: - guard the linux/perf_events.h include properly with an #if defined __linux__ * * * Subsequent patches in the series

[PATCH v6 02/12] libdwfl [2/12]: expose setfunc callback for libdwflP+libebl clients

2025-04-25 Thread Serhei Makarov
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

[PATCH v6 09/12] libdwfl_stacktrace [9/12]: add dwflst_tracker_find_pid

2025-04-25 Thread Serhei Makarov
Changes for v6: - Minor fixes as requested. Changes for v4: - Separate out libdwfl_stacktrace, as requested. Changes for v2: - Add locking for dwfltab. * * * New function that retrieves the Dwfl for a particular PID, or, if the Dwfl is absent, creates it via a provided callback and adds it t

[PATCH v6 07/12] eu-stacktrace [7/12]: use Dwflst_Process_Tracker for Elf * caching

2025-04-25 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. * * * * src/Makefile.am (AM_CPPFLAGS): Include headers from ../libdwfl_stacktrace. * src/stacktrace.c (tracker): New global variable. (sample_callbacks): Use dwflst_tracker_linux_proc_find_elf for caching. (sysprof_init_dwf

[PATCH v6 03/12] libebl [3/12]: eu-stacktrace: use new register handling api

2025-04-25 Thread Serhei Makarov
Changes for v4: - Since __libdwfl_set_initial_registers_thread is now private to libdwfl, the modified code in this patch has been disabled. * * * Dummy commit to show how the sample_set_initial_registers callback in eu-stacktrace would use the proper libebl ebl_set_initial_registers_sample fu

[PATCH v6 11/12] libdwfl_stacktrace [11/12]: add dwflst_perf_sample_getframes

2025-04-25 Thread Serhei Makarov
Changes for v6: - Minor fixes as requested. Changes for v4: - Separate out libdwfl_stacktrace, as requested. Changes for v3: - use const void *stack, not void *, to allow users to pass a const stack sample Changes for v2: - use renamed __libdwfl_set_initial_registers_thread - oops, should

[PATCH v6 06/12] libdwfl_stacktrace [6/12]: Elf* caching via dwflst_process_tracker

2025-04-25 Thread Serhei Makarov
Changes for v6: - Minor fixes as requested. Changes for v5: - Bugfixes in dwflst_tracker_find_elf.c. Changes for v4: - Separate out libdwfl_stacktrace, as requested. - dwfl_module_getdwarf.c now uses the dwflst_tracker_cache_elf() interface instead of editing the elftab directly. Changes f

[PATCH v6 08/12] libdwfl_stacktrace [8/12]: Dwfl* caching via Dwflst_Process_Tracker

2025-04-25 Thread Serhei Makarov
Changes for v6: - Minor fixes as requested. Changes for v4: - Separate out libdwfl_stacktrace, as requested. Changes for v3: - Handle dwfl->process == NULL case in __libdwfl_remove_dwfl_from_tracker. * * * The Dwflst_Process_Tracker also includes a dynamicsizehash cache which maps process id

[PATCH v6 10/12] eu-stacktrace [10/12]: use dwflst_tracker_find_pid

2025-04-25 Thread Serhei Makarov
Changes for v6: - Minor fixes as requested. Changes for v4: - Separate out libdwfl_stacktrace, as requested. * * * Initial minimal change to ensure dwflst_tracker_find_pid is tested. For now, we keep the additional dwfltab implementation in stacktrace.c, since it's being used to track statisti

[PATCH v6 12/12] eu-stacktrace [12/12]: use dwflst_perf_sample_getframes

2025-04-25 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. Changes for v3: - Fix initialization of elf in sysprof_init_dwfl (previously triggered -Wmaybe-uninitialized). * * * Remove the code from src/stacktrace.c that is now covered by libdwfl_stacktrace/dwflst_perf_frame.c and dwflst

[PATCH v6 05/12] libdwfl_stacktrace [5/12]: introduce Dwflst_Process_Tracker

2025-04-25 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. * * * New data structure to coordinate caching Elf data among multiple Dwfl structs attached to different processes. Meant to reduce the overhead for profilers that use elfutils for unwinding. The caching is well-justified, as the

[PATCH v5 01/12] libebl [1/12]: api for perf register handling, start with x86_64

2025-04-24 Thread Serhei Makarov
Changes for v2: - Merged commit 11 into commit 1 (both sample_base_addr/sample_pc and set_initial_registers_sample make sense to introduce in the same commit). - Added i386 backend and factored out common code. * * * First patch of a series that reworks eu-stacktrace functionality into a li

[PATCH v5 03/12] libebl [3/12]: eu-stacktrace: use new register handling api

2025-04-24 Thread Serhei Makarov
Changes for v4: - Since __libdwfl_set_initial_registers_thread is now private to libdwfl, the modified code in this patch has been disabled. * * * Dummy commit to show how the sample_set_initial_registers callback in eu-stacktrace would use the proper libebl ebl_set_initial_registers_sample fu

[PATCH v5 02/12] libdwfl [2/12]: expose setfunc callback for libdwflP+libebl clients

2025-04-24 Thread Serhei Makarov
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. * libd

[PATCH v5 10/12] eu-stacktrace [10/12]: use dwflst_tracker_find_pid

2025-04-24 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. * * * Initial minimal change to ensure dwflst_tracker_find_pid is tested. For now, we keep the additional dwfltab implementation in stacktrace.c, since it's being used to track statistics. In future follow-ups, it will be good to

[PATCH v5 07/14] libdwfl_stacktrace [6/12]: Elf* caching via dwflst_process_tracker

2025-04-24 Thread Serhei Makarov
Changes Changes for v4: - Separate out libdwfl_stacktrace, as requested. - dwfl_module_getdwarf.c now uses the dwflst_tracker_cache_elf() interface instead of editing the elftab directly. Changes for v3: - Reworked elftab to incorporate dev/ino into the caching key (to allow caching module

[PATCH v5 05/12] libdwfl_stacktrace [5/12]: introduce Dwflst_Process_Tracker

2025-04-24 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. * * * New data structure to coordinate caching Elf data among multiple Dwfl structs attached to different processes. Meant to reduce the overhead for profilers that use elfutils for unwinding. The caching is well-justified, as the

[PATCH v5 04/12] libdwfl_stacktrace [4/12]: intro library, add dwflst_perf_sample_preferred_regs_mask

2025-04-24 Thread Serhei Makarov
Changes for v5: - Separate ELFUTILS_0.193_EXPERIMENTAL namespace, mark library experimental. Changes for v4: - Separate out libdwfl_stacktrace, as requested. Changes for v2: - guard the linux/perf_events.h include properly with an #if defined __linux__ * * * Subsequent patches in the series

  1   2   >