From: Mark Wielaard Date: Mon, 18 Oct 2010 21:35:04 +0000 (+0200) Subject: Expand dwarf_edit_output.cc testcases. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1b7590cf13abb03b0e284c555ac61bc4f692e5a4;p=thirdparty%2Felfutils.git Expand dwarf_edit_output.cc testcases. --- diff --git a/tests/dwarf_edit_output.cc b/tests/dwarf_edit_output.cc index 9c9417d14..135a5a0d7 100644 --- a/tests/dwarf_edit_output.cc +++ b/tests/dwarf_edit_output.cc @@ -166,6 +166,10 @@ circular_struct (dwarf_edit &in) struct_ptr_ref->attributes ()[DW_AT_type].reference () = list_ptr; + dwarf_edit::debug_info_entry &var = *cu.add_entry (DW_TAG_variable); + var.attributes ()[DW_AT_name].identifier () = "var"; + var.attributes ()[DW_AT_type].reference () = struct_ptr_ref; + return in; } @@ -201,6 +205,10 @@ circular_struct2 (dwarf_edit &in) mn.attributes ()[DW_AT_type].reference () = struct_ptr_ref; + dwarf_edit::debug_info_entry &var = *cu.add_entry (DW_TAG_variable); + var.attributes ()[DW_AT_name].identifier () = "var"; + var.attributes ()[DW_AT_type].reference () = struct_ptr_ref; + return in; } @@ -220,6 +228,72 @@ two_circular_structs2 (dwarf_edit &in) return in; } +dwarf_edit & +var_struct_ptr_type (dwarf_edit &in) +{ + /* A variable referencing the struct pointer type "directly", + and through its "own" definition of the structure pointer type, + should be considered equal. Some discussion in: + https://fedorahosted.org/pipermail/elfutils-devel/2010-July/001480.html + */ + + // CU1 + dwarf_edit::compile_unit &cu1 = in.add_unit (); + cu1.attributes ()[DW_AT_producer].string () = "CU1"; + + dwarf_edit::debug_info_entry::pointer list_ptr1 + = cu1.add_entry (DW_TAG_structure_type); + dwarf_edit::debug_info_entry &list1 = *list_ptr1; + list1.attributes ()[DW_AT_name].identifier () = "list"; + list1.attributes ()[DW_AT_byte_size].constant () = 12; + + dwarf_edit::debug_info_entry &mn1 = *list1.add_entry (DW_TAG_member); + mn1.attributes ()[DW_AT_name].identifier () = "next"; + + dwarf_edit::debug_info_entry::pointer struct_ptr_ref1 + = cu1.add_entry (DW_TAG_pointer_type); + struct_ptr_ref1->attributes ()[DW_AT_byte_size].constant () = 8; + struct_ptr_ref1->attributes ()[DW_AT_type].reference () = list_ptr1; + + mn1.attributes ()[DW_AT_type].reference () = struct_ptr_ref1; + + dwarf_edit::debug_info_entry &var1 = *cu1.add_entry (DW_TAG_variable); + var1.attributes ()[DW_AT_name].identifier () = "var"; + + dwarf_edit::debug_info_entry::pointer struct_ptr_ref_b + = cu1.add_entry (DW_TAG_pointer_type); + struct_ptr_ref_b->attributes ()[DW_AT_byte_size].constant () = 8; + struct_ptr_ref_b->attributes ()[DW_AT_type].reference () = list_ptr1; + + var1.attributes ()[DW_AT_type].reference () = struct_ptr_ref_b; + + // CU2 + dwarf_edit::compile_unit &cu2 = in.add_unit (); + cu2.attributes ()[DW_AT_producer].string () = "CU2"; + + dwarf_edit::debug_info_entry::pointer list_ptr2 + = cu2.add_entry (DW_TAG_structure_type); + dwarf_edit::debug_info_entry &list2 = *list_ptr2; + list2.attributes ()[DW_AT_name].identifier () = "list"; + list2.attributes ()[DW_AT_byte_size].constant () = 12; + + dwarf_edit::debug_info_entry &mn2 = *list2.add_entry (DW_TAG_member); + mn2.attributes ()[DW_AT_name].identifier () = "next"; + + dwarf_edit::debug_info_entry::pointer struct_ptr_ref2 + = cu2.add_entry (DW_TAG_pointer_type); + struct_ptr_ref2->attributes ()[DW_AT_byte_size].constant () = 8; + struct_ptr_ref2->attributes ()[DW_AT_type].reference () = list_ptr2; + + mn2.attributes ()[DW_AT_type].reference () = struct_ptr_ref2; + + dwarf_edit::debug_info_entry &var2 = *cu2.add_entry (DW_TAG_variable); + var2.attributes ()[DW_AT_name].identifier () = "var"; + var2.attributes ()[DW_AT_type].reference () = struct_ptr_ref2; + + return in; +} + static int show_input, show_output; void @@ -236,7 +310,7 @@ test_run (int n, const char *name, dwarf_edit &in) if (show_output) { - // c.stats(); + c.stats(); print_file ("dwarf_output", out, 0); } @@ -317,9 +391,14 @@ main (int argc, char **argv) test_run (9, "two_circular_structs", two_circular_structs (in9)); // Won't merge CUs since order of children different. + // XXX but also structs and var aren't considered equal. Why not? dwarf_edit in10; if (RUNTEST (10)) - test_run (10, "two_circular_structs2", two_circular_structs2 (in9)); + test_run (10, "two_circular_structs2", two_circular_structs2 (in10)); + + dwarf_edit in11; + if (RUNTEST (11)) + test_run (11, "var_struct_ptr_type", var_struct_ptr_type (in11)); return 0; }