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.  */
> +extern int dwfl_process_tracker_find_elf (Dwfl_Module *mod, void **userdata,
> +                                  const char *module_name, Dwarf_Addr base,
> +                                  char **file_name, Elf **);
In the reworked patchset I'm trying to expand this api a bit
to allow other find_elf callbacks to be used with caching.

I'm thinking to introduce a pair of functions for more direct cache access:

bool dwfl_process_tracker_find_cached_elf (tracker, module_name, file_name, 
elfp, &fd);
bool dwfl_process_tracker_cache_elf (tracker, module_name, file_name, elf, fd);

Then the dwfl_process_tracker_find_elf callback would be implemented by:

Dwfl_Process_Tracker *tracker = mod->dwfl->tracker;
if (tracker != NULL
    && dwfl_process_tracker_find_cached_elf (tracker, module_name, file_name, 
elfp, &fd))
    return fd;
fd = INTUSE(dwfl_linux_proc_find_elf) (...);
if (tracker != NULL && fd >= 0 && *file_name != NULL)
    dwfl_process_tracker_cache_elf (tracker, module_name, file_name, elfp, fd);
return fd;

Also, is it ok to call the existing callback dwfl_process_tracker_find_elf?
dwfl_process_tracker_linux_proc_find_elf would be more exact
but also very verbose. Or dwfl_linux_proc_find_elf_cached?
Not sure I'm on my top inspiration in terms of function naming.

Might come up with a better idea after thinking a bit more today, but this is 
the best I have so far.

-- 
All the best,
    Serhei
    http://serhei.io

Reply via email to