* 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(-)
diff --git a/src/stacktrace.c b/src/stacktrace.c index 7b498e40..a6866bd5 100644 --- a/src/stacktrace.c +++ b/src/stacktrace.c @@ -611,6 +611,8 @@ static const Dwfl_Thread_Callbacks sample_thread_callbacks = * Dwfl and statistics table for multiple processes * ****************************************************/ +Dwfl_Process_Tracker *tracker = NULL; + /* This echoes lib/dynamicsizehash.* with some necessary modifications. */ typedef struct { @@ -843,7 +845,7 @@ static char *debuginfo_path = NULL; static const Dwfl_Callbacks sample_callbacks = { - .find_elf = dwfl_linux_proc_find_elf, + .find_elf = dwfl_process_tracker_find_elf, .find_debuginfo = dwfl_standard_find_debuginfo, .debuginfo_path = &debuginfo_path, }; @@ -869,7 +871,7 @@ nop_find_debuginfo (Dwfl_Module *mod __attribute__((unused)), static const Dwfl_Callbacks sample_callbacks = { - .find_elf = dwfl_linux_proc_find_elf, + .find_elf = dwfl_process_tracker_find_elf, .find_debuginfo = nop_find_debuginfo, /* work with CFI only */ }; @@ -992,7 +994,7 @@ sysprof_init_dwfl (struct sysprof_unwind_info *sui, cached = true; goto reuse; } - dwfl = dwfl_begin (&sample_callbacks); + dwfl = dwfl_begin_with_tracker (tracker); int err = dwfl_linux_proc_report (dwfl, pid); if (err < 0) @@ -1486,6 +1488,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 = dwfl_process_tracker_begin (&sample_callbacks); /* TODO: For now, code the processing loop for sysprof only; generalize later. */ assert (input_format == FORMAT_SYSPROF); @@ -1569,5 +1572,7 @@ https://sourceware.org/cgit/elfutils/tree/README.eu-stacktrace?h=users/serhei/eu if (output_fd != -1) close (output_fd); + dwfl_process_tracker_end (tracker); + return EXIT_OK; } -- 2.47.0