This is the mail archive of the mailing list for the elfutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] libdw: Make dwarf_getfuncs find all (defining) DW_TAG_subprogram DIEs.

On 09/20/2013 07:11 PM, Josh Stone wrote:
> On 09/20/2013 12:13 AM, Mark Wielaard wrote:
>> I had been pondering exposing a public DIE tree walk function, since
>> there are some tricky corner cases to take care of. If you have a
>> particular need/design it would be interesting to compare notes. Would
>> something like the __libdw_visit_scopes interface be generic enough?
> I think a function *like* that would be nice, but it's current form is a
> bit ugly for public consumption.  :)

I spent a little time thinking about *why* visit_scopes is ugly to me.
I think it comes down to the fact that it's trying to provide lots of
help for recursion, but still gives you knobs for controlling that
recursion.  It has to have two callbacks in case you need to do your
work before or after recursion.  It also gives the ability to prune
stuff you don't want recursed, but there's no way to recurse extra
things if you wanted more than just "scopes".

I think a better public API might just visit children of a DIE.  It
would basically be a simple dwarf_child(); dwarf_siblingof()... but it
can also transparently dig into imported DIEs.  Isn't that most of the
"tricky" part that you'd want to hide?

The interface can be a lot like dwarf_getfuncs, but perhaps don't bother
with an offset, since we know that's problematic.

  dwarf_getchildren(Dwarf_Die *parent,
                    int (*callback) (Dwarf_Die *, void *),
                    void *arg);

Leave it to the callback to decide whether it wants to recurse on a
child, and this way pre/post visiting is within its control too.

Some of the internal child-walking could convert to this interface too.

The other possibly-interesting part of visit_scopes is its static
function classify_die().  If you want to expose that knowledge, it could
be a simple boolean function, just whether a DIE might have scoped children:

  dwarf_can_has_scopes(Dwarf_Die *parent);

but do bikeshed the lolcats out of that... :)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]