This is the mail archive of the
mailing list for the elfutils project.
Re: [PATCH 2/2] Add C++ iterators
- From: Petr Machata <pmachata at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Thu, 16 Apr 2015 15:52:03 +0200
- Subject: Re: [PATCH 2/2] Add C++ iterators
Mark Wielaard <email@example.com> writes:
> Is that a common use case? I would have imagined that you would iterate
> over just the Dwarf_Dies of one particular unit separately or given a
That would be along these lines:
for (die_tree_iterator it (uit), end (++uit); it != end; ++it)
> particular Dwarf_Die would like it to iterate over just the die_tree
> under that DIE. Given the current design of the die_tree_iterator how
> would one do that?
This is not implemented, though I admit it would be a useful feature.
At this point however I would very much like to keep the scope of the
patch as it is now.
> Also I think that we really should provide an easy way to walk the
> logical DIE tree. Which means resolving DW_TAG_imported_unit DIEs and
> just continue with the children of the imported unit at that point.
> There should of course also be an option to walk the "raw" DIE tree. But
> it feels wrong to let the user do logical walks on their own, checking
> for imported_unit tags, walking the imported_unit children tree, keep
> their own parent stack, etc.
I agree, this would be tremendously useful--we discussed this recently
on this list after all. But it should be implemented in C libdw, and
only then (optionally) reused in the C++ wrappers.
> That of course does mean the current internal tracking using just a
> Dwarf_Off is not enough, because resolving imported_units might cross
One option would be to build the logical iterator on top of the raw
iterator, and track import history in a vector of raw iterators. That's
essentially what dwgrep does.