Caching behaviour is improving. The commented assert still catches
some cases where a redundant Elf * is being created.
* dwfl_module_getdwarf.c (open_elf): Cache file->elf in Dwfl_Process_Tracker.
if (error != DWFL_E_NOERROR)
return error;
+ /* Cache file->elf in Dwfl_Process_Tracker if available: */
+ if (mod->dwfl->tracker != NULL && file->name != NULL)
+ {
+ dwfltracker_elftab_ent *ent = __libdwfl_process_tracker_elftab_find (mod->dwfl->tracker, file->name, false/* should_resize */);
+ if (ent != NULL)
+ {
+ /* assert(ent->elf == NULL || ent->elf == file->elf); */ /* TODO(PRERELEASE): Guard against redundant/leaked Elf *. */
+ assert(ent->fd == file->fd); /* TODO(PRERELEASE): Guard against redundant open. */
+ ent->elf = file->elf;
+ }
+ }
+
GElf_Ehdr ehdr_mem, *ehdr = gelf_getehdr (file->elf, &ehdr_mem);
if (ehdr == NULL)
{
/* XXX fd < 0 implies elf_from_remote_memory, uses base, not cacheable */
if (tracker != NULL && ent != NULL && fd >= 0 && *file_name != NULL)
{
- /* TODO(WIP): *elfp may be NULL here, need to be populated later. */
ent->elf = *elfp;
ent->fd = fd;
rc = fstat(fd, &sb);