This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: <dwarf>: iteration over attributes swallows the last one
- From: Roland McGrath <roland at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Tue, 24 Mar 2009 15:32:06 -0700
- Subject: Re: <dwarf>: iteration over attributes swallows the last one
As a general thing, please also push to some private branch when you post.
(One-offs are good for this, you can remove them later with push :user/foo.)
That way approvers can merge it directly rather than either telling you to
push it or using git-am. (In this case, I think I want a different version
merged instead. But this is a note for general procedure.)
> The scenario goes like this.
> * end iterator has an offset of 1
> * begin iterator has an offset of 0
Actually that's the pre-begin iterator.
inline const_iterator begin () const
{
const_iterator i = const_iterator (_m_die, 0);
return ++i;
}
The initialized-to-0 iterator is never seen anywhere else. Hence:
> inline const_iterator (const debug_info_entry &die, ptrdiff_t offset)
> - : _m_die (die), _m_offset (offset) {}
> + : _m_die (die), _m_offset (offset)
> + {
> + _m_attr.valp = NULL;
> + }
No need for that, given:
inline const_iterator &operator++ () // prefix
{
_m_attr.valp = NULL;
...
> As a fix for that, I propose to consider also NULL-ness of _m_attr.value
> when doing the iterator comparison.
I think you can just do valp == valp comparison and drop the offset
comparison. The pointers will match when the offsets match, and two NULLs
are two end iterators.
Can you also please write a test case for this? I'd guess a trivial program
using .to_string () does it since the busted iterator is used by that.
I've just pushed makefile cleanups that should make it simpler to copy the
src/Makefile.am magic into tests/Makefile.am to compile C++ cases there.
Thanks,
Roland