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]

dwarf_edit_output testcase sanity checking


Hi,

On the dwarf branch I added a bunch of "simple" small dwarf_edit
examples to tests/dwarf_edit_output.cc. The testcases are then used to
compare some DIEs with dwarf_comparator, to create a dwarf_output
object, check whether expected DIEs have been merged and whether the
dwarf_edit and dwarf_output objects are still comparable.

If you #define _DWARF_OUTPUT_DEBUG_SPEW 1 in dwarf_output it is a nice
way to follow the dwarf_output copier logic.

There is one testcase for which dwarf_comparator and dwarf_output don't
agree on whether they are equal/sharable. Lets run it with:
$ tests/dwarf_edit_output 10 inout
(Runs test number 10, shows both input, the dwarf_edit object, as
output, the dwarf_output object. run with --offsets to see the raw
offsets.)

*two_circular_structs2*
dwarf_edit:
 <compile_unit producer="dwarf_edit_output_test">
  <base_type ref="ref2" name="int" byte_size=0x4/>
  <pointer_type ref="ref3" byte_size=0x8 type="#ref1"/>
  <structure_type ref="ref1" name="list" byte_size=0x10>
   <member name="i" type="#ref2"/>
   <member name="next" type="#ref3"/>
  </structure_type>
  <variable name="var" type="#ref3"/>
 </compile_unit>
 <compile_unit producer="dwarf_edit_output_test">
  <base_type ref="ref4" name="int" byte_size=0x4/>
  <structure_type ref="ref6" name="list" byte_size=0x10>
   <member name="i" type="#ref4"/>
   <member name="next" type="#ref5"/>
  </structure_type>
  <pointer_type ref="ref5" byte_size=0x8 type="#ref6"/>
  <variable name="var" type="#ref5"/>
 </compile_unit>

[At this point there will be a check that both vars in the two CUs
 dwarf_comparator equal, and they do. But...]

dwarf_output:
 <compile_unit producer="dwarf_edit_output_test">
  <base_type ref="ref8" name="int" byte_size=0x4/>
  <pointer_type ref="ref9" byte_size=0x8 type="#ref7"/>
  <structure_type ref="ref7" name="list" byte_size=0x10>
   <member name="i" type="#ref8"/>
   <member name="next" type="#ref9"/>
  </structure_type>
  <variable name="var" type="#ref9"/>
 </compile_unit>
 <compile_unit producer="dwarf_edit_output_test">
  <base_type ref="ref10" name="int" byte_size=0x4/>
  <structure_type ref="ref12" name="list" byte_size=0x10>
   <member name="i" type="#ref10"/>
   <member name="next" type="#ref11"/>
  </structure_type>
  <pointer_type ref="ref11" byte_size=0x8 type="#ref12"/>
  <variable name="var" type="#ref11"/>
 </compile_unit>
offset last var cu1: 0x871800
offset last var cu2: 0x873860
tests/dwarf_edit_output: fail test_last_two_var_dies #10
'two_circular_structs2'

So dwarf_output doesn't think so.

Now logically they seem to be the same. So I think dwarf_comparator is
correct. But a case could be made that although they are semantically
the same, they aren't really structurally equal. In this context the
order of the DIEs doesn't matter (top-level CU children). But in theory
the order of children DIEs does matter in some contexts. So, is the
above testcase something where we really want to mark both vars as
equal?

Thanks,

Mark


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