This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: dwarf_edit_output testcase sanity checking
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Wed, 27 Oct 2010 16:30:32 +0200
- Subject: Re: dwarf_edit_output testcase sanity checking
On Fri, 2010-10-22 at 09:29 -0400, Roland McGrath wrote:
> Yes, I think that is correct to report as equal.
> So the question is indeed why dwarf_output fails to consolidate them together.
I found a smaller case, which I added to the dwarf_edit_output testcase:
*small_circular_structs*
dwarf_edit:
<compile_unit offset=[0xcb2060]>
<pointer_type offset=[0xcb20f0] type=[0xcb2180]/>
<structure_type offset=[0xcb2180] name="list">
<member offset=[0xcb22a0] name="next" type=[0xcb20f0]/>
</structure_type>
</compile_unit>
<compile_unit offset=[0xcb24c0]>
<structure_type offset=[0xcb2550] name="list">
<member offset=[0xcb2670] name="next" type=[0xcb2790]/>
</structure_type>
<pointer_type offset=[0xcb2790] type=[0xcb2550]/>
</compile_unit>
[...]
dwarf_output:
<compile_unit offset=[0xcb2b90]>
<pointer_type offset=[0xcb3d60] type=[0xcb4ac0]/>
<structure_type offset=[0xcb4ac0] name="list">
<member offset=[0xcb4720] name="next" type=[0xcb3d60]/>
</structure_type>
</compile_unit>
<compile_unit offset=[0xcb2b50]>
<structure_type offset=[0xcb5300] name="list">
<member offset=[0xcb63b0] name="next" type=[0xcb65e0]/>
</structure_type>
<pointer_type offset=[0xcb65e0] type=[0xcb5300]/>
</compile_unit>
[...]
tests/dwarf_edit_output: dwarf_comparator fail pointer_type test #12
'small_circular_structs'
So we have a pointer_type to the struct defined before/after the
structure_type that uses it.
What seems to be happening is that in the first case we detect the
pointer_type as having a circular_reference, and in the second case we
detect the structure_type has a circular_reference. Which means that
depending on which we detect first they will have a different hash since
the one circular_reference will have an hash of zero, while otherwise it
will have the referent's identity as hash value.
We should mark all references in the circular chain as
circular_references. But I don't yet see how I can easily do that in the
code.
A workaround would be to hash all references to zero:
--- a/libdw/c++/dwarf_output
+++ b/libdw/c++/dwarf_output
@@ -411,7 +411,7 @@ namespace elfutils
for the circular_reference case, below. */
virtual size_t hash () const
{
- return ref->identity ();
+ return 0;
}
};
That seems to make all the testcases in dwarf_edit_output happy.
Does the above make sense? Is it horribly inefficient?
Cheers,
Mark