public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mjw@redhat.com>
To: elfutils-devel@lists.fedorahosted.org
Subject: Re: [PATCH 2/2] Add C++ iterators
Date: Thu, 16 Apr 2015 17:06:08 +0200	[thread overview]
Message-ID: <1429196768.31971.76.camel@bordewijk.wildebeest.org> (raw)
In-Reply-To: 87oamomb98.fsf@redhat.com

[-- Attachment #1: Type: text/plain, Size: 3193 bytes --]

On Thu, 2015-04-16 at 15:52 +0200, Petr Machata wrote:
> Mark Wielaard <mjw@redhat.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)
>     ;

O, that is pretty nice. I hadn't thought of that.

> > 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.

My problem is that I am not yet so fluent in my C++ thinking to know
whether that would fit the current design or that it would need a
completely different class and implementation. I would very much like to
avoid adding code that we then have to maintain but that we cannot
easily extend to similar use cases and end up with lots of interfaces
and implementations.

But given the nice idea above of defining a "next iterator as end" for
another. Would adding that functionality just be introducing a new
constructor that takes a Dwarf_Die and a next_sibling () method that
returns an iterator that one can use as above in a for loop to test
whether one has walked a subtree?

The only disadvantage of that seems to be that it would immediately
introduce a v2 variant if we do it after a public release.

> > 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.

I was thinking just doing it on the C++ level. But yes, it would be nice
to also have that on the C level libdw interface. That was this
discussion where you came up with a pretty nice plan:
https://lists.fedorahosted.org/pipermail/elfutils-devel/2014-October/004204.html

Again my worry is about whether retrofitting such a design into the
current class is possible or not. Would it be as simple as adding a new
constructor, a boolean field and using the new C functions (and updating
the version) or would we need a whole new class/interface for it?

So my only worry about just adding this code as is now, is that I don't
have a good feeling for how to evolve this C++ code without creating an
unmaintainable mess or abandoning the current code/design. If you could
handwave a plausible path forward to add these things then I would agree
with adding the code as is.

Thanks,

Mark

             reply	other threads:[~2015-04-16 15:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-16 15:06 Mark Wielaard [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-04-20  9:28 Mark Wielaard
2015-04-17 16:54 Petr Machata
2015-04-16 19:23 Mark Wielaard
2015-04-16 15:42 Petr Machata
2015-04-16 14:07 Frank Ch. Eigler
2015-04-16 13:52 Petr Machata
2015-04-16 13:29 Mark Wielaard
2015-04-14 14:47 Petr Machata
2015-04-14 13:53 Petr Machata
2015-04-14 13:52 Petr Machata
2015-04-03 21:34 Petr Machata
2015-04-03 13:39 Petr Machata
2015-04-03 12:56 Mark Wielaard
2015-04-03 11:27 Petr Machata
2015-04-03  8:51 Petr Machata

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429196768.31971.76.camel@bordewijk.wildebeest.org \
    --to=mjw@redhat.com \
    --cc=elfutils-devel@lists.fedorahosted.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).