This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: Some elfutils/libdw/cfi comments
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Tue, 08 Jun 2010 16:02:20 +0200
- Subject: Re: Some elfutils/libdw/cfi comments
On Tue, 2010-06-01 at 13:50 -0700, Roland McGrath wrote:
> > - dwarf_next_cfi () has the following comment:
> > "On success, returns 0 and fills in *ENTRY; use dwarf_cfi_cie_p to
> > see whether ENTRY->cie or ENTRY->fde is valid."
> > But dwarf_cfi_cie_p is only defined in the private cfi.h header.
>
> Hmm. That was probably just an oversight.
> I think your change to move it is fine.
I pushed it, thanks.
> > - There is dwarf_next_cfi () which you can use to walk through the raw
> > section data, which gives you a Dwarf_CFI_Entry. And there is
> > dwarf_cfi_addrframe () which you can use to query an address for the
> > corresponding Dwarf_Frame for an address. Ideally I would like to
> > get a dwarf_cfi_frame_next () to walk through all the FDEs.
>
> You can use dwarf_addrframe on the end PC of the last one.
> But I guess that doesn't help you when there are gaps.
Indeed, that is my problem, I want to iterate through all the FDEs (and
CIEs, but that is secondary).
> > And
> > something like a dwarf_frame_cie () and dwarf_frame_fde () that
> > provided the info in the the cfi.h dwarf_cie and dwarf_fde structs.
> > This is probably a bit specific to the systemtap use case, where we
> > want to preprocess the frame data. But I think it could be useful
> > in other cases.
>
> I'm not sure that is sufficiently useful to bother with. I modelled the
> two levels of interface on the other libdw interfaces, where dwarf_nextcu
> deals in raw stuff without keeping state and everything else is higher-level.
But there is dwarf_offdie, which you can feed a "raw" Dwarf_Off. So you
can iterate with dwarf_nextcu and get the actual Dwarf_Die through
dwarf_offdie. It would be convenient (at least for my little hacking
project) to have something similar for CFI. Something like:
/* Compute what's known about a call frame for a FDE at a given offset.
Returns 0 for success or -1 for errors.
On success, *FRAME is a malloc'd pointer. */
extern int dwarf_cfi_offframe (Dwarf_CFI *cache, Dwarf_Off offset,
Dwarf_Frame **frame)
__nonnull_attribute__ (3);
If that makes sense, I could try to hack up something.
Cheers,
Mark