This is the mail archive of the elfutils-devel@sourceware.org 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: <dwarf>: iteration over attributes swallows the last one


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

Attachment: signature.asc
Description: PGP signature


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