[PATCH 4/5] libdwfl: cache Dwfl_Module and Dwarf_Frame for Dwfl_Frame

Omar Sandoval osandov@osandov.com
Wed Oct 30 23:55:00 GMT 2019


On Wed, Oct 30, 2019 at 02:04:42PM +0100, Mark Wielaard wrote:
> Hi Omar,
> 
> On Mon, 2019-10-07 at 02:05 -0700, Omar Sandoval wrote:
> > The next change will need to have the Dwarf_Frame readily available, so
> > rather than finding it again every time, let's cache it for reuse. The
> > CFI frame can also be useful to clients of libdwfl, so add
> > dwfl_frame_dwarf_frame to get it. Similarly, the Dwfl_Module is also
> > frequently needed in conjunction with the frame, so cache it and add
> > dwfl_frame_module.
> 
> I can see how this is useful. But it seems the Dwarf_Frame is only
> cached when __libdwfl_frame_unwind is called. Which I believe isn't
> done for the initial frame. Also it isn't clear how to propagate any
> errors when NULL is returned. Maybe dwfl_frame_dwarf_frame () should
> check first to see if frame is NULL and then call lookup the CFI and
> call dwarf_cfi_addrframe if not?

Yes, that makes sense. Rather than doing the lookups in
__libdwfl_frame_unwind and handle_cfi, I can move the lookups to
dwfl_frame_module and dwfl_frame_dwarf_frame, have those functions cache
it internally, and make __libdwfl_frame_unwind and handle_cfi call those
functions.

Thanks,
Omar



More information about the Elfutils-devel mailing list