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;
}
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;
}
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
if (show_output)
{
- // c.stats();
+ c.stats();
print_file ("dwarf_output", out, 0);
}
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;
}