summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhei Makarov <[email protected]>2025-01-28 12:27:34 -0500
committerSerhei Makarov <[email protected]>2025-04-25 10:10:01 -0400
commitbf2ef65fb5ccbd145776a1cc242d201d73687820 (patch)
tree07edd92a8ddbddb551d559d6e2fdec52ac4022ba
parent343dcb44be11649339c8debb9c916408ecd7ee5b (diff)
eu-stacktrace [7/12]: use Dwflst_Process_Tracker for Elf * caching
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_dwfl): Use dwflst_tracker_dwfl_begin. (main): Initialize and clean up tracker.
-rw-r--r--src/Makefile.am3
-rw-r--r--src/stacktrace.c12
2 files changed, 11 insertions, 4 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 6d713e88..4a3fb957 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,7 +23,8 @@ DEFS += $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \
DEFAULT_INCLUDES =
AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
-I$(srcdir)/../libdw -I$(srcdir)/../libdwelf \
- -I$(srcdir)/../libdwfl -I$(srcdir)/../libasm -I../debuginfod
+ -I$(srcdir)/../libdwfl -I$(srcdir)/../libdwfl_stacktrace \
+ -I$(srcdir)/../libasm -I../debuginfod
AM_LDFLAGS = -Wl,-rpath-link,../libelf:../libdw $(STACK_USAGE_NO_ERROR)
diff --git a/src/stacktrace.c b/src/stacktrace.c
index 3f5950fb..c0c9929d 100644
--- a/src/stacktrace.c
+++ b/src/stacktrace.c
@@ -98,6 +98,7 @@
#include "../libdwfl/libdwflP.h"
/* XXX: Private header needed for find_procfile, sysprof_init_dwfl,
sample_set_initial_registers. */
+#include ELFUTILS_HEADER(dwfl_stacktrace)
/*************************************
* Includes: sysprof data structures *
@@ -657,6 +658,8 @@ static const Dwfl_Thread_Callbacks sample_thread_callbacks =
* Dwfl and statistics table for multiple processes *
****************************************************/
+Dwflst_Process_Tracker *tracker = NULL;
+
/* This echoes lib/dynamicsizehash.* with some necessary modifications. */
typedef struct
{
@@ -889,7 +892,7 @@ static char *debuginfo_path = NULL;
static const Dwfl_Callbacks sample_callbacks =
{
- .find_elf = dwfl_linux_proc_find_elf,
+ .find_elf = dwflst_tracker_linux_proc_find_elf,
.find_debuginfo = dwfl_standard_find_debuginfo,
.debuginfo_path = &debuginfo_path,
};
@@ -915,7 +918,7 @@ nop_find_debuginfo (Dwfl_Module *mod __attribute__((unused)),
static const Dwfl_Callbacks sample_callbacks =
{
- .find_elf = dwfl_linux_proc_find_elf,
+ .find_elf = dwflst_tracker_linux_proc_find_elf,
.find_debuginfo = nop_find_debuginfo, /* work with CFI only */
};
@@ -1038,7 +1041,7 @@ sysprof_init_dwfl (struct sysprof_unwind_info *sui,
cached = true;
goto reuse;
}
- dwfl = dwfl_begin (&sample_callbacks);
+ dwfl = dwflst_tracker_dwfl_begin (tracker);
int err = dwfl_linux_proc_report (dwfl, pid);
if (err < 0)
@@ -1532,6 +1535,7 @@ https://sourceware.org/cgit/elfutils/tree/README.eu-stacktrace?h=users/serhei/eu
(void)maxframes;
#else
fprintf(stderr, "\n=== starting eu-stacktrace ===\n");
+ tracker = dwflst_tracker_begin (&sample_callbacks);
/* TODO: For now, code the processing loop for sysprof only; generalize later. */
assert (input_format == FORMAT_SYSPROF);
@@ -1615,5 +1619,7 @@ https://sourceware.org/cgit/elfutils/tree/README.eu-stacktrace?h=users/serhei/eu
if (output_fd != -1)
close (output_fd);
+ dwflst_tracker_end (tracker);
+
return EXIT_OK;
}