Don't share types across TUs when DW_TAG_partial_unit are involved

* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir):
	Clear the part of the context that needs to be per TU.
	(build_ir_node_from_die): Assert that this should not be called
	for partial and imported unit because for now our practical
	assumption is that DIEs under partial unit are lazily read only
	when referenced by DIEs that are under DW_TAG_compile_unit.
	* tests/Makefile.am: Add the new test files to the build system.
	* tests/data/test-read-dwarf/test2.so.abi: Fix the reference
	output here to avoid sharing types across TUs, making the output
	valid for bilint.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2014-05-19 21:35:56 +02:00
parent c469546e45
commit c91461a8c8
3 changed files with 23 additions and 2 deletions

View File

@ -3692,6 +3692,13 @@ build_translation_unit_and_add_to_ir(read_context& ctxt,
return result;
assert(dwarf_tag(die) == DW_TAG_compile_unit);
// Clear the part of the context that is depends on the translation
// unit we are reading.
ctxt.die_decl_map().clear();
while (!ctxt.scope_stack().empty())
ctxt.scope_stack().pop();
ctxt.var_decls_to_re_add_to_tree().clear();
ctxt.cur_tu_die(die);
string path = die_string_attribute(die, DW_AT_name);
@ -5026,6 +5033,13 @@ build_ir_node_from_die(read_context& ctxt,
case DW_TAG_enumerator:
break;
case DW_TAG_partial_unit:
case DW_TAG_imported_unit:
// For now, the DIEs under these are read lazily when they are
// referenced by a public decl DIE that is under a
// DW_TAG_compile_unit, so we shouldn't get here.
abort();
// Other declaration we don't really intend to support yet.
case DW_TAG_dwarf_procedure:
case DW_TAG_imported_declaration:
@ -5050,8 +5064,6 @@ build_ir_node_from_die(read_context& ctxt,
case DW_TAG_try_block:
case DW_TAG_variant_part:
case DW_TAG_imported_module:
case DW_TAG_partial_unit:
case DW_TAG_imported_unit:
case DW_TAG_condition:
case DW_TAG_type_unit:
case DW_TAG_template_alias:

View File

@ -168,6 +168,11 @@ data/test-read-dwarf/test0.cc \
data/test-read-dwarf/test1 \
data/test-read-dwarf/test1.abi \
data/test-read-dwarf/test1.cc \
tests/data/test-read-dwarf/test2.h \
tests/data/test-read-dwarf/test2-0.cc \
tests/data/test-read-dwarf/test2-1.cc \
tests/data/test-read-dwarf/test2.so \
tests/data/test-read-dwarf/test2.so.abi \
\
data/test-diff-filter/test0-v0.cc \
data/test-diff-filter/test0-v1.cc \

View File

@ -41,6 +41,10 @@
</function-decl>
</member-function>
</class-decl>
<type-decl name='int' size-in-bits='32' alignment-in-bits='32' id='type-id-11'/>
<typedef-decl name='integer' type-id='type-id-11' id='type-id-8'/>
<type-decl name='unsigned char' size-in-bits='8' alignment-in-bits='8' id='type-id-12'/>
<typedef-decl name='character' type-id='type-id-12' id='type-id-9'/>
<pointer-type-def type-id='type-id-7' size-in-bits='64' alignment-in-bits='64' id='type-id-10'/>
<namespace-decl name='a'>
<function-decl name='build_second_type' mangled-name='_ZN1a17build_second_typeEv' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test2-1.cc' line='13' column='1' visibility='default' binding='global' size-in-bits='64' alignment-in-bits='64'>