<dwarf>: iteration over attributes swallows the last one
Petr Machata
pmachata at redhat.com
Wed Mar 25 23:54:48 UTC 2009
Roland McGrath wrote:
>> The changes that you requested, and the testcase, are on pmachata/dwarf.
>
> Thanks.
>
> @@ -637,7 +637,7 @@ namespace elfutils
>
> inline attribute operator* () const
> {
> - if (unlikely (_m_offset == 1))
> + if (unlikely (_m_offset == 1 && _m_attr.valp == NULL))
> throw std::runtime_error ("dereferencing end iterator");
> return attribute (_m_die, _m_attr);
> }
>
> We don't really need the _m_offset check here, do we?
We do, that's the new end iterator condition. offset==1 valp!=NULL is
valid iterator pointing to the last element.
> Why do we need the new dwarf-attributes test program instead of testing the
> expected output of dwarf-print? I guess its output is kind of long on any
> nontrivial file. Perhaps just tweak dwarf-print with an optional less
> verbose mode rather than cut&paste most of it?
To test the fix, all that is necessary is to pick the first CU DIE and
iterate its attributes, and that's what the test does. The goal is for
the test to remain valid as long as the tested condition holds.
dwarf-print output will change in all kinds of ways as we change the
library. But I pushed another way of doing this that doesn't involve
duplicate code, and does involve sed, which is my favourite combination.
PM
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
Url : https://fedorahosted.org/pipermail/elfutils-devel/attachments/20090326/fd08745f/attachment.bin
More information about the elfutils-devel
mailing list