* src/abg-dwarf-reader.cc (get_scope_for_die): If the DIE has a
DW_AT_specification or DW_AT_abstract_origin attribute, get the
scope of the referred-to DIE.
(build_ir_node_from_die): For a variable DIE that has a
DW_AT_{specification,abstract_origin} attribute, do not add the
built variable IR node to its scope because it is already in a
scope. It's in a scope because that built variable is for the DIE
that is referred-to by the DW_AT_{specification,abstract_origin}
attribute. Likewise for member functions. Also, now,
get_scope_for_die can return a class for a function DIE because
get_scope_for_die now returns the *logical* scope of the DIE; that
is, it follows DW_AT_{specification,abstract_origin} attributes.
* tests/data/test-read-dwarf/test1.abi: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Declare new accessors.
(corpus::lookup_{variable,function}_symbol): Declare new member
functions.
* src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Define new accessors.
(corpus::lookup_{variable,function}_symbol): Define new member
functions.
* include/abg-ir.h (string_elf_symbol_sptr_map_type)
(string_elf_symbol_sptr_map_sptr, elf_symbols)
(string_elf_symbols_map_type, string_elf_symbols_map_sptr): New
convenience typedefs.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Declare new member
functions.
* src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol,
get_next_alias, has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Define new member
functions.
* include/abg-reader.h (read_corpus_from_file): Take a shared
pointer to corpus.
* src/abg-reader.cc (read_context::{g,s}et_corpus): Define these.
(build_elf_symbol_db, build_elf_symbol_from_reference)
(read_symbol_db_from_input): Define new functions.
(read_corpus_from_input): Adjust. Make it read symbol databases.
(build_elf_symbol): Harden this.
(build_{var,function}_decl): Read the symbol reference. Do not
read the local symbol serialization anymore.
(read_corpus_from_archive): Adjust.
(read_corpus_from_file): Take a reference to a shared pointer to
corpus, rather than a reference to the corpus.
(read_corpus_from_native_xml): Only keep the overload that returns
a corpus. Set the current context with the corpus.
* src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type)
(addr_elf_symbol_sptr_map_sptr): New convenience typedefs.
(read_context::{fun_sym_addr_sym_index_map_,
var_sym_addr_sym_index_map_): Remove.
(read_context::{fun,var}_addr_sym_map_): New. Replace the above
that got removed.
(read_context::{var,fun}_syms_): New.
(read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust.
(read_context::{fun,var}_addr_sym_map{_sptr}): New.
(read_context::{fun,var}_syms{_sptr}): New.
(read_context::load_symbol_maps): Replace
read_context::load_symbol_addr_to_index_maps. Adjust to load all
the new maps.
(read_context::maybe_load_symbol_maps): New.
(read_debug_info_into_corpus): Renamed build_corpus into this.
Update to load symbol maps and set it to the corpus.
* src/abg-writer.cc (write_context::get_fun_symbol_map): New
accessor.
(write_elf_symbol_aliases, write_elf_symbol_reference)
(write_elf_symbols_table): Define new static functions.
(write_var_decl): Write the reference to the underlying symbol of
the variable. Do not write the full symbol here anymore.
(write_function_decl): Likewise, write the reference to the
underlying symbol of the function. Do not write the full symbol
here anymore.
(write_corpus_to_native_xml): Write the symbol databases at the
beginning of the corpus document.
* src/abg-comparison.cc
(corpus_diff::priv::ensure_lookup_tables_populated): Now that the
corpus has symbols, check if a the symbol of an allegedly deleted
function (resp. variable) is deleted; if not, then do not report
the function (resp. variable) as deleted. Similarly, check if the
symbol of an allegedly added function (resp. variable) is added.
if not, the do not report the function (resp. variable) as added.
* tests/test-write-read-archive.cc (main): Adjust.
* tools/biar.cc (extract_tus_from_archive): Likewise.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
* tests/data/test-read-dwarf/test0.abi: Likewise.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (build_ir_node_from_die): Do not try to
add the cloned function/variable to the current scope because
cloning should have added the decl into the scope of the cloned
target.
* src/abg-ir.cc ({var,function}_decl::clone): Insert the clone
decl into the scope of the cloned decl. My understanding is that
it's where they belong.
* tests/data/test-read-dwarf/test1.abi: Update this to incorporate
all the abstract constructors/destructors *and* their clones into
the classes where they belong.
* tests/data/test-read-dwarf/test1.abi: Adjust for the abstract
cdtor being added to the class, as well as their cloned concrete
instances.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* 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>
* src/abg-dwarf-reader.cc (read_context::cur_tu_die_): New member.
(read_context::read_context): Initialize the new member.
(read_context::cur_tu_die): New accessors.
(find_last_import_unit_point_before_die): New static function.
(get_parent_die): Take a logical current die offset parameter. If
the die we want the parent for is a partial unit, then find the
last DW_TAG_imported_unit that imports that partial unit before
the logical current die and return the parent of that
DW_TAG_imported_unit die.
(get_scope_for_die): Take a logical current die offset parameter.
Adjust.
(build_translation_unit_and_add_to_ir): Set/unset the current
translation unit DIE in the context. Adjust.
(build_namespace_decl_and_add_to_ir)
(build_class_type_and_add_to_ir, build_qualified_type)
(build_pointer_type_def, build_reference_type, build_typedef_type)
(build_var_decl, build_function_decl, build_ir_node_from_die):
Take a logical current die offset parameter. Adjust.
(build_corpus): Accept that we can have DIE that are not
DW_TAG_compile_unit at the top level, because, well, we can now
have DW_TAG_partial_unit too.
* tests/data/test-read-dwarf/test2-{0,1}.cc: New test source
files.
* tests/data/test-read-dwarf/test2.h: Likewise.
* tests/data/test-read-dwarf/test2.so: New input binary to read.
* tests/data/test-read-dwarf/test2.so.abi: New reference test to
compare against.
* tests/test-read-dwarf.cc: Adjust to launch the new test.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* abg-ir.h (string_to_elf_symbol_type, string_to_elf_symbol_binding):
Declare new entry points.
* src/abg-ir.cc (string_to_elf_symbol_type)
(string_to_elf_symbol_binding): Define new entry points.
* include/abg-libxml-utils.h (xml_char_sptr_to_string): Declare
new entry points.
* src/abg-libxml-utils.cc (xml_char_sptr_to_string): Define new
entry points.
* src/abg-reader.cc (read_elf_symbol_type)
(read_elf_symbol_binding, build_elf_symbol): Define new static
functions.
(build_function_decl, build_var_decl): Use the new
build_elf_symbol and set the symbol to the function. Flag the
function as having a public symbol in the symbol table if the
symbol is public.
* src/abg-writer.cc (write_elf_symbol_type)
(write_elf_symbol_binding, write_elf_symbol): Define new static
functions.
(write_var_decl, write_function_decl): Use the new
write_elf_symbol to serialize the symbol for the decl.
* tests/data/test-read-dwarf/test[01].abi: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (build_function_decl): Change signature
to take function_decl to which one shall add properties that got
added by subsequent DIEs later.
(build_class_type_and_add_to_ir): Adjust.
(build_function_decl): Allow adding new properties to an existing
function_decl. Add the mangled name in particular.
* tests/data/test-read-dwarf/test1.abi: Update test.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Do not
declare classes before defining them because both the declaration
and the definition now compare equal.
* tests/data/test-read-dwarf/test1.abi: Update test.
* tests/data/test-read-write/test20.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (class_decl::is_struct_): New member.
(class_decl::class_decl): Take an additional is_struct member.
(class_decl::is_struct): New getter.
* src/abg-ir.cc (class_decl::class_decl): Initialize the new
is_struct_ data member.
(class_decl::get_pretty_representation): Tell struct and class
apart.
* abg-reader.cc (read_is_struct): New static function.
(build_class_decl): Capture the struct-ness of the class.
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir):
Likewise.
* src/abg-writer.cc (write_is_struct): New static function.
(write_class_decl): Write the struct-ness of the class.
* tests/data/test-read-dwarf/test1.abi: Update test.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (die_is_artificial): New static
function.
(build_class_type_and_add_to_ir, build_ir_node_from_die): Use the
die_is_artificial function to test if the function DIE is
artificial and then skip it.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (build_ir_node_from_die): Insert
reference, pointers and qualified types at the point where we see
them, in their scope, rather than under the scope of their
underlying type. This is because their might be first declared as
member types and we don't want to loose that information.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (insert_decl_into_ir_under_scope)
(build_namespace_decl_and_add_to_ir, build_enum_type)
(build_class_type_and_add_to_ir, build_ir_node_from_die)
(build_ir_node_from_die): Remove.
* tests/data/test-read-dwarf/test0.abi: Update because now type
IDs can be used before they are defined.
* tests/data/test-read-dwarf/test1.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tests/data/test-read-dwarf/test0.cc: Define a member function
out-of-line, outside of its namespace.
* tests/data/test-read-dwarf/test0.abi: Update the .abi file.
* tests/data/test-read-dwarf/test0: Update the resulting binary.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>