* tests/data/test-alt-dwarf-file/test0-debug-dir/.build-id/16/7088580c513b439c9ed95fe6a8b29496495f26.debug:
Make this be a real file, no more a symlink to
../../../test0-common-dwz.debug.
* tests/data/test-alt-dwarf-file/test0-report.txt: Now that the
file above is no more a symlink the message emitted by the test
changes. It now says that the file found is the base name of the
real file. So change the reference report accordingly.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* configure.ac (ENABLE_ZIP_ARCHIVE_AND_CXX11): Define this
automake condition variable that is true if both the zip archive
and c++11 features are enabled. This is important to know if the
test runtestdot is going to be compiled. That test needs both
c++11 and the zip archive features.
* tests/Makefile.am: Do not nest automake conditional statements.
It does not work. Rather, use the new
ENABLE_ZIP_ARCHIVE_AND_CXX11 condition variable.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (struct changed_type_or_decl_comp, struct
changed_vars_comp): New comparison functors.
(sort_changed_type_or_decl, sort_changed_vars): New static
functions.
(scope_diff::report): Use the above to sort changed declarations,
and types in a given scope.
(corpus_diff::report): Likewise for the changed variables.
* tests/data/test-abidiff/test-struct1-report.txt: Adjust.
* tests/data/test-diff-suppr/test7-var-suppr-report-0.txt:
Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-8.txt:
Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-corpus.h (corpus::{get_sorted_fun_symbols,
get_sorted_var_symbols}): Declare new member functions.
* src/abg-corpus.cc (corpus_priv::{sorted_var_symbols,
sorted_fun_symbols}): New data members.
(struct elf_symbol_comp_functor): Define new comparison functor.
(corpus::{get_sorted_fun_symbols, get_sorted_var_symbols}): Define
new member functions.
* src/abg-writer.cc (write_elf_symbols_table): Take a sorted
vector of symbols in parameters, rather than an unsorted map.
(write_corpus_to_native_xml): Write a sorted vector of symbols,
rather than an unsorted map of symbols.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
* tests/data/test-read-dwarf/test3.so.abi: Likewise.
* tests/data/test-read-dwarf/test6.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter:#️⃣:operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl:#️⃣:operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }:#️⃣:operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* configure.ac: Define a new --enable-cxx11 switch to control the
use of the C++-11 compiler. Define a WITH_CXX11 C macro and an
automake ENABLE_CXX11 variable.
* config.h.in: Initialize the new WITH_CXX11 C macro.
* src/Makefile.am: Include the files coded in C++-11 only if the
ENABLE_CXX11 automake variable is defined.
* tests/Makefile.am: Likewise, build the runtestsvg test program
only if C++-11 usage is enabled.
* include/abg-diff-utils.h (class d_path_vec): Remove useless
usage of the 'typename' keyword.
* include/abg-fwd.h (is_enum_type): Renamed is_enum into this,
because of a name clash with a tr1 function when not using C++-11.
(is_pointer_type): Likewise, renamed is_pointer into this because
of a name clash with a tr1 function when not using C++-11.
* src/abg-comp-filter.cc (has_harmless_name_change): Adjust for
the is_enum -> is_enum_type change.
* src/abg-comparison.cc (type_suppression::suppresses_diff):
Likewise.
(class function_suppression::priv): Add a missing "class" keyword
in friend declaration.
(diff_context::diff_has_been_traversed)
(diff_context::mark_diff_as_traversed): Do not use the C++-11
specific type uintptr_t.
* src/abg-dwarf-reader.cc (create_default_dwfl): Do not use
designated initializers. Sigh. This is handy though.
(expr_result::abs): Cast the argument of std::abs to avoid
ambiguous call.
(finish_member_function_reading): Adjust for the is_pointer ->
is_pointer_type renaming.
* src/abg-hash.cc (scope_decl:#️⃣:operator)
(class_decl::base_spec:#️⃣:operator)
(type_composition:#️⃣:operator): Use std::tr1::hash string,
rather than the C++-11 specific std::hash function.
* src/abg-ini.cc (read_sections, write_sections): Make
std::ifstream constructor take a const char* rather than a string.
* src/abg-ir.cc (is_enum_type, is_pointer_type): Renamed is_enum
into is_enum_type and is_pointer into is_pointer_type.
* src/abg-writer.cc (write_translation_unit): Remove useless
typename keyword. Make ofstream take a const char* rather than a
string.
(write_namespace_decl): Remove useless typename keyword.
(write_corpus_to_native_xml_file): Make ofstream take a const
char* rather than a string.
* tests/test-abidiff.cc (main): Make ofstream take a const char*
rather than a string.
* tests/test-diff-dwarf.cc (main): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h (variable_suppression_sptr)
(variable_suppressions_type): New convenience typedefs.
(class variable_suppression): Declare new type.
* src/abg-comparison.cc (is_var_diff): New predicate.
(read_variable_suppression): Define new static function.
(class variable_suppression::priv): Define type for the private
data of the variable_suppression type.
(variable_suppression::{variable_suppression,
~variable_suppression, get_name, set_name, get_name_regex_str,
set_name_regex_str, get_symbol_name, set_symbol_name,
get_symbol_name_regex_str, set_symbol_name_regex_str,
get_symbol_version, set_symbol_version,
get_symbol_version_regex_str, set_symbol_version_regex_str,
get_type_name, set_type_name, get_type_name_regex_str,
set_type_name_regex_str, suppresses_diff}): Define new member
functions for the variable_suppression type.
* tests/data/test-diff-suppr/libtest7-var-suppr-v0.so: Add new
test input.
* tests/data/test-diff-suppr/libtest7-var-suppr-v1.so: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-1.suppr: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-2.suppr: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-3.suppr: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-4.suppr: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-5.suppr: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-6.suppr: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-7.suppr: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-8.suppr: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-1.txt: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-2.txt: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-3.txt: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-4.txt: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-5.txt: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-6.txt: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-7.txt: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-report-8.txt:
Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-version-script: Likewise.
* tests/data/test-diff-suppr/test7-var-suppr-v0.cc: Source code
for the librairie above.
* tests/data/test-diff-suppr/test7-var-suppr-v1.cc: Source code
for the librairie above.
* tests/Makefile.am: Add the new test input data to the source
distribution.
* tests/test-diff-suppr.cc: Update to make this harness to run
over the new test input above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (corpus_diff::report): Show the full
representation of the variable, rather than just its name. Also,
show the new representation of the variable only if it has
changed.
* tests/data/test-diff-dwarf/test9-report.txt: Adjust test.
* tests/data/test-diff-filter/test15-0-report.txt: Likewise.
* tests/data/test-diff-filter/test15-1-report.txt: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-ir.cc (elf_symbol::get_aliases_id_string): Separate
alias targets by a comma.
* tests/data/test-diff-dwarf/test18-alias-sym-v1.cc: Update test
to add more than one alias to a given symbol.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h (enum visiting_kind): Change the
meaning of this. It was to determine if traversal was to be done
in a pre or post manner. But with the recent addition of
diff_node_visitor::visit_{begin,end}() notifiers, the pre/post
handling is taken care of in a different way. So now the meaning
of this enum is changed to handle whether diff node children
should be visited or not. So the enumerators are now
DEFAULT_VISITING_KIND, and SKIP_CHILDREN_VISITING_KIND. And it's
a bit-field.
(operator{&,~}): Declare more bit manipulation operators for the
enum visiting_kind.
(function_suppression_sptr, function_suppressions_type): New
typedefs.
(function_suppression, function_suppression::parameter_spec):
Declare new types.
(read_function_suppressions): Declare new function.
(diff_node_visitor::diff_node_visitor): Adjust for the enum
visiting_kind change. Value-initialize the visiting_kind_ data
member.
* src/abg-comparison.cc (operator{&,~}): Define these operators
for enum visiting_kind.
(read_type_suppressions): Forward declare this static function.
(read_function_suppression, read_parameter_spec_from_string):
Define new static functions.
(read_suppressions): Update to read function suppressions too,
using the new read_function_suppression function above.
(class function_suppression::parameter_spec::priv): Define new
type.
(function_suppression::parameter_spec::*): Define the member
functions of the new function_suppression::parameter_spec type.
(class function_suppression::priv): Define new type.
(function_suppression::*): Define the member functions of the new
function_suppression type.
(diff::traverse): There is no more {PRE,POST}_VISITING_KIND
enumerator. So nuke the code that was dealing with it.
(redundancy_marking_visitor::skip_children_nodes_): New data
member flag.
(redundancy_marking_visitor::visit_begin): If the current diff
node is not be reported (is filtered out), do not bother visit its
children nodes for the purpose of marking redundant nodes. So use
the new skip_children_nodes_ flag above to know we are in that case.
(redundancy_marking_visitor::visit_end): Unset the new
skip_children_nodes_ flag above when appropriate.
* include/abg-fwd.h (is_function_decl): Declare new function.
* include/abg-ir.h
(function_type::get_parm_at_index_from_first_non_implicit_parm):
Declare new member function.
* src/abg-ir.cc (is_function_decl): Define new function.
(function_type::get_parm_at_index_from_first_non_implicit_parm):
Define new member function.
* src/abg-comp-filter.cc (apply_filter): Adjust for the enum
visiting_kind change. No need to set it for filters anymore
* doc/suppr-doc.txt: Update examples of function suppression.
* doc/manuals/libabigail-concepts.rst: Update the manual for the
function suppression addition.
* tests/data/test-diff-suppr/libtest5-fn-suppr-v0.so: New test input.
* tests/data/test-diff-suppr/libtest5-fn-suppr-v1.so: New test input.
* tests/data/test-diff-suppr/libtest6-fn-suppr-v0.so: New test input.
* tests/data/test-diff-suppr/libtest6-fn-suppr-v1.so: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-0.suppr: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-1.suppr: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-2.suppr: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-3.suppr: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-4.suppr: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-v0.cc: Source code for
new test input.
* tests/data/test-diff-suppr/test5-fn-suppr-v1.cc: Source code for
new test input.
* tests/data/test-diff-suppr/test6-fn-suppr-0.suppr: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-1.suppr: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-2.suppr: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-3.suppr: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-report-4.txt: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-v0.cc: Source code for
new test input.
* tests/data/test-diff-suppr/test6-fn-suppr-v1.cc: Source code for
new test input.
* tests/data/test-diff-suppr/test6-fn-suppr-version-script: New
test input.
* tests/Makefile.am: Add the new files above to source
the distribution.
* tests/test-diff-suppr.cc (in_out_specs): Add the test inputs
above to the list of tests to be run by this harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* doc/manuals/abidiff.rst: Adjust intro to mention that w/o debug
info, abidiff now works but just report about added/removed
symbols. Add documentation about the new
--no-unreferenced-symbols option.
* include/abg-comparison.h (string_elf_symbol_map): New typedef.
(diff_context::show_symbols_unreferenced_by_debug_info): Declare
new accessors.
* src/abg-comparison.cc
(diff_context::priv::show_syms_unreferenced_by_di_): New data
member.
(diff_context::priv::priv): Adjust.
(diff_context::show_symbols_unreferenced_by_debug_info): Implement
these accessors.
(corpus_diff::priv::{unrefed_fn_syms_edit_script_,
unrefed_var_syms_edit_script_, added_unrefed_fn_syms_,
deleted_unrefed_fn_syms_, added_unrefed_var_syms_,
deleted_unrefed_var_syms_}): New data members.
(corpus_diff::priv::diff_stats::{num_func_syms_removed,
num_func_syms_added, num_var_syms_removed, num_var_syms_added}):
New data members.
(corpus_diff::priv::diff_stats::diff_stats): Adjust.
(corpus_diff::ensure_lookup_tables_populated): Populate lookup
tables for added/removed symbols that are not referenced by any
debug info.
(corpus_diff::priv::apply_filters_and_compute_diff_stats): Compute
stats for the added/removed symbols not referenced by any debug
info.
(corpus_diff::priv::emit_diff_stats): Emit stats about
added/removed symbols that are not referenced by any debug info.
(corpus_diff::length): Adjust to take in account added/removed
symbols not referenced by any debug info.
(show_linkage_name_and_aliases): New static function.
(corpus_diff::report): When emitting a symbol name, emit its
version too, and tell if it aliases other symbols. Avoid emitted
extra new lines. Report added/removed symbols not referenced by
any debug info.
(compute_diff): In the overload for corpus_sptr, compute the diffs
for symbols not referenced by debug info.
* include/abg-corpus.h
(corpus::get_unreferenced_{function,variable}_symbols): Declare
new member functions.
* src/abg-corpus.cc (corpus_priv::{unrefed_fun_symbols,
unrefed_var_symbols}): New data members.
(corpus_priv::build_unreferenced_symbols_tables): Define new
member function.
(struct comp_elf_symbols_functor): New functor.
(corpus::is_empty): Adjust to take in account added/removed
symbols not referenced by debug info.
(corpus::{get_unreferenced_function_symbols,
corpus::get_unreferenced_variable_symbols}): Define these
accessors.
* include/abg-dwarf-reader.h (enum status): Transform this into
bitfields. Add a STATUS_UNKNOWN value that has the value 0.
(operator|(status, status), operator&(status, status))
(operator|=(status&, status), operator&=(status, status)): New
bit-wise operators to manipulate instances of the status bit-field.
* src/abg-dwarf-reader.cc (get_version_for_symbol): Fix this to
avoid returning garbage version sometimes.
(read_debug_info_into_corpus): Fix this to return a non-null but
empty corpus_sptr when there is no debug info available.
(operator|(status, status), operator&(status, status))
(operator|=(status&, status), operator&=(status, status)): Define
these new bitwise operators to manipulate instances of the status
bit-field.
(read_corpus_from_elf): Now that the abigail::dwarf_reader::status
is a bit-field, set it to reflect if debug info and/or symbol
tables have been found. Do not bail out if debug info hasn't been
found. Rather, keep going, and go look for symbols-only; this is
a kind of operating in degraded mode.
* include/abg-ir.h (elf_symbol::get_aliases_id_string): Add a flag
that says if the current instance of elf_symbol should be included
in the list of aliases or not.
* src/abg-ir.cc (elf_symbol::get_aliases_id_string): Define it.
* tests/data/test-diff-dwarf/test16-syms-only-v{0,1}.o: New test
input.
* tools/abidiff.cc
(options::show_symbols_not_referenced_by_debug_info): New data
member.
(options:options): Adjust.
(display_usage): Add an info string for the new
--no-unreferenced-symbols command line option.
(parse_command_line): Parse the new --no-unreferenced-symbols
command line.
(set_diff_context_from_opts): Set the diff_context according to
the presence of --no-unreferenced-symbols.
(main): Adjust for the fact that abigail::dwarf_reader::status is
now a bit-field.
* tools/abilint.cc (main): Adjust for the fact that
abigail::dwarf_reader::status is now a bit-field..
():
* tests/data/test-diff-dwarf/test16-syms-only-report.txt: New test
reference output.
* tests/data/test-diff-dwarf/test16-syms-only-v{0,1}.cc: Source code
for new test input.
* tests/data/test-diff-dwarf/test17-non-refed-syms-v{0,1}.o: New
test input.
* tests/data/test-diff-dwarf/test17-non-refed-syms-v{0,1}.cc: New
source code for test input.
* tests/data/test-diff-dwarf/libtest18-alias-sym-v{0,1}.so: New
test input.
* tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt:
Reference output for new test input.
* tests/data/test-diff-dwarf/test18-alias-sym-v{0,1}.cc: Source
code for new test input.
* tests/data/test-diff-dwarf/test18-alias-sym-version-script:
Source code for new test input.
* tests/Makefile.am: Add the new test materials to the source
distribution.
* tests/test-diff-dwarf.cc(in_out_specs): Add the new input tests
above to the array of tests to run by this harness.
(main): Emit empty reports for empty resulting diffs.
* tests/data/test-diff-dwarf/test{0,8,9,12,14-inline-report,}-report.txt:
Adjust.
* tests/data/test-diff-filter/test{0,01,2,4,5,7,8,9,10,12,13,15-0,15-1}-report.txt:
Likewise.
* tests/data/test-diff-filter/test{19-enum,20-inline,}-report-0.txt:
Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-report-{1,2}.txt:
Likewise.
* tests/data/test-diff-suppr/test{1,2}-typedef-suppr-report-1.txt:
Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-fwd.h (is_pointer, is_qualified_type): Declare new
functions.
* src/abg-ir.cc (is_pointer, is_qualified_type): Implement these
new functions.
* src/abg-dwarf-reader.cc (finish_member_function_reading):
Sometimes, the this pointer of a non-static method can point to a
*qualified* version of its containing type. I am seeing that when
comparing libstdc++.so from RHEL 6.5 and RHEL 7. Take that in
account when trying to detect that the first parameter of a member
function is the this pointer, and thus detect that the function is
a non static member function.
* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi:
New test input.
* tests/data/test-read-dwarf/test8-qualified-this-pointer.so: New
test input.
* tests/data/test-read-dwarf/test8-qualified-this-pointer.cc:
Source code of new test input.
* tests/test-read-dwarf.cc: Update copyright year.
(in_out_spec): Add the new test inputs to this array, so that this
test harness runs on them.
* tests/Makefile.am: Add the new test inputs to the source
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc
(suppression_categorization_visitor::visit_end): If a diff node
carries local changes, then, even if all of its children node have
been suppressed, this diff node shall not be categorized as
suppressed by way of propagation.
(redundancy_marking_visitor::visit_end): If a diff node carries
local changes, then, even if all of its children nodes are
redundant, this diff node shall not be categorized as being
redundant by way of propagation.
* tests/data/test-diff-suppr/libtest4-local-suppr-v{0,1}.so: New test
inputs.
* tests/data/test-diff-suppr/test4-local-suppr-0.suppr: Likewise.
* tests/data/test-diff-suppr/test4-local-suppr-report-{0,1}.txt:
Likewise.
* tests/data/test-diff-suppr/test4-local-suppr-v{0,1}.{c,h}:
Source code of the new tests inputs.
* tests/Makefile.am: Add the new test material to the source
distribution.
* tests/test-diff-suppr.cc (in_out_spec): Run this test harness
over the new test input above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (type_suppression::suppresses_diff): Do
not crash on diff nodes that are not about struct/classes, when
"type_kind = struct" has been specified.
* tests/data/test-diff-suppr/test2-struct-suppr-{0,1}.suppr: New test input.
* tests/data/test-diff-suppr/test2-struct-suppr-report-{0,1}.txt:
Likewise.
* tests/data/test-diff-suppr/test2-struct-suppr-v{0,1}.o: Likewise
* tests/data/test-diff-suppr/test2-struct-suppr-v{1,0}.cc: Source code
for binary test input.
* tests/test-diff-suppr.cc (in_out_spec): Run this harness on the
new test input above.
* tests/Makefile.am: Add the new test input files to source
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* doc/suppr-doc.txt: Add type_kind property "documentation" in the
type suppression.
* include/abg-comparison.h (type_suppression::type_kind): New
enum.
(type_suppression::{get_consider_typedefness,
set_consider_typedefness, get_is_typedef, set_is_typedef}):
Remove.
(type_suppression::{get_consider_type_kind,
set_consider_type_kind, get_type_kind, set_type_kind}): Declare
new methods.
* Include/abg-fwd.h (is_type_decl): Declare new function.
(is_enum): Declare new overload that takes a type_base_sptr.
* src/abg-comparison.cc
(type_suppression::priv::{consider_typedefness_, is_typedef_}):
Remove these data members.
(type_suppression::priv::{consider_type_kind_, type_kind_}): New
data members.
(type_suppression::priv::priv): Adjust.
(type_suppression::{get_consider_typedefness,
set_consider_typedefness, get_is_typedef, set_is_typedef}): Remove
these member functions.
(type_suppression::{get_consider_type_kind,
set_consider_type_kind, get_type_kind, set_type_kind}): Define
these new member functions.
(type_suppression::suppresses_diff): Adjust to consider the kind
of types more generally than just considering typedef-ness.
(read_type_kind_string): New static function.
(read_type_suppression): Use the above to parse the value of the
new type_kind property. Adjust the creation of the resulting
type_suppression object.
* src/abg-ir.cc (is_type_decl): Define new function.
* tests/data/test-diff-suppr/test1-typedef-suppr-0.suppr: Adjust.
* tests/data/test-diff-suppr/test1-typedef-suppr-1.suppr: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h (diff_category::SUPPRESSED_CATEGORY):
New enumerator.
(diff_category::{SIZE_OR_OFFSET_CHANGE_CATEGORY,
VIRTUAL_MEMBER_CHANGE_CATEGORY): Update the enumerator values for
these.
(diff::EVERYTHING_CATEGORY): Adjust.
(suppression_base, type_suppression): Declare new types.
(suppression_ptr, suppressions_type, type_suppression_sptr)
(type_suppressions_type): New typedefs.
(read_type_suppressions, read_suppressions): Declare new
functions.
(diff_context::{suppressions, add_suppression, add_suppressions}):
Declare new methods.
(diff::is_suppressed): Declare new member function.
(apply_suppressions): Declare new function & overloads.
* src/abg-comparison.cc (is_type_diff): Define new static
function.
({suppression_base, type_suppression}::priv): Define new types.
({suppression_base, type_suppression}::*): Define the methods of the new
suppression_base, type_suppressions types.
(read_type_suppression, read_type_suppressions, read_suppressions)
(read_type_suppressions): Define new static functions.
(diff_context::priv::supprssions_): New data member.
(diff_context::{suppressions, add_suppression, add_suppressions}):
New methods.
(diff::is_filtered_out): Consider that a diff node that is in the
SUPPRESSED_CATEGORY is filtered out.
(diff::is_suppressed): Define new member function.
(operator<<(ostream& o, diff_category c)): Support the
SUPPRESSED_CATEGORY category.
(corpus_diff::report): Apply suppressions before reporting
anything.
(category_propagation_visitor::visit_end): Do not propagate
SUPPRESSED_CATEGORY. This is just like what we do for
REDUNDANT_CATEGORY.
(struct suppression_categorization_visitor): New visitor.
(apply_suppressions): Define function & overloads.
* include/abg-ini.h (config::section::find_property): New method.
(config::section): Fix end of class comment.
* src/abg-ini.cc (config::section::find_property): Define new
method.
* tests/data/test-diff-suppr/test0-type-suppr-{0,1,2}.suppr: New
test input files.
* tests/data/test-diff-suppr/test0-type-suppr-report-{0,1,2,3}.txt:
Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-v{0,1}.o: Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-v{0,1}.cc: Source code
for new test input.
* tests/data/test-diff-suppr/test1-typedef-suppr-v{0,1}.o: New test
input files.
* tests/data/test-diff-suppr/test1-typedef-suppr.h: Source code
for new test input files.
* tests/data/test-diff-suppr/test1-typedef-suppr-v{0,1}.c: Likewise
* tests/data/test-diff-suppr/test1-typedef-suppr-{0,1}.suppr: New
test input files.
* tests/data/test-diff-suppr/test1-typedef-suppr-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test1-typedef-suppr-report-1.txt: Likewise.
* tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Likewise.
* tests/test-diff-suppr.cc: New test harness to run type suppression tests
using the input files above.
* tests/data/test-diff-suppr/test3-struct-suppr-0.suppr: New test input.
* tests/data/test-diff-suppr/test3-struct-suppr-1.suppr: Likewise.
* tests/data/test-diff-suppr/test3-struct-suppr-report-0.txt: Likewise.
* tests/data/test-diff-suppr/test3-struct-suppr-report-1.txt: Likewise.
* tests/data/test-diff-suppr/test3-struct-suppr-report-2.txt: Likewise.
* tests/data/test-diff-suppr/test3-struct-suppr-v0.cc: Likewise.
* tests/data/test-diff-suppr/test3-struct-suppr-v0.o: Likewise.
* tests/data/test-diff-suppr/test3-struct-suppr-v1.cc: Likewise.
* tests/data/test-diff-suppr/test3-struct-suppr-v1.o: Likewise.
* tests/Makefile.am: Build the new runtestdiffsuppr test harness
from the test-diff-filter.cc file. Add the new test files to the
build system and source distribution.
* tools/bidiff.cc (options::suppressions): New data member.
(display_usage): Add a help string for the new
--suppressions command line switch.
(parse_command_line): Parse the --suppressions command line
switch.
(set_diff_context_from_opts): Read the suppressions provided by
the --suppression command line switch and stuff them into the diff
context.
* include/abg-comp-filter.h (apply_filter): Declare new overload
that takes a corpus_diff_sptr ...
* src/abg-comp-filter.cc (apply_filter): ... and define it. On
the existing overload for diff_sptr, make sure to traverse all
diff nodes, even those that have already been traversed.
* include/abg-comparison.h (enum diff_category): Remove
NOT_REDUNDANT_CATEGORY, add REDUNDANT_CATEGORY.
(operator&=, +operator<<): Declare new operators for enum diff_category.
(diff_context::{forbid_traversing_a_node_twice,
traversing_a_node_twice_is_forbidden):
(diff_context::categorizing_redundancy): Remove this declaration.
(diff_context::maybe_apply_filters): Declare a new overload that
takes a corpus_diff_sptr. And a take a new flag that says if it
should visit all nodes including those that have already been
visited.
(diff::priv_): Make this data member protected.
(diff::{begin_traversing, is_traversing, end_traversing,
finish_diff_type, children_nodes, append_child_node,
get_pretty_representation, chain_into_hierarchy, traverse}):
Declare new member functions.
(distinct_diff::{finish_diff_type, get_pretty_representation,
chain_into_hierarchy}): Likewise.
(distinct_diff::traverse): Remove.
(pointer_diff::pointer_diff): Take the underlying type diff in
parameter.
(pointer_diff::{finish_diff_type, get_pretty_representation,
chain_into_hierarchy}): Declare new member functions.
(pointer_diff::traverse): Remove.
(reference_type_def::reference_type_def): Take the underlying type
diff in parameter.
({array_type_def, reference_type_def}::{finish_diff_type,
get_pretty_representation, chain_into_hierarchy}): Declare new
member functions.
({array_type_diff, reference_type_def}::traverse): Remove.
(qualified_type_diff::qualified_type_diff): Take the underlying
type diff in parameter.
({enum_diff, qualified_type_diff, class_diff}::{finish_diff_type,
get_pretty_representation, chain_into_hierarchy}): Declare new
member functions.
({enum_diff, qualified_type_diff, class_diff}::traverse): Remove.
(is_class_diff): Declare new function.
(base_diff::base_diff): Take the underlying type diff in
parameter.
({scope_diff, base_diff}::{finish_diff_type, get_pretty_representation,
chain_into_hierarchy}): Declare new member functions.
({scope_diff, base_diff}::traverse): Remove.
(function_decl_diff::function_decl_diff): Take the return type
diff as parameter.
({function_decl_diff, type_decl_diff}::{finish_diff_type,
get_pretty_representation, chain_into_hierarchy}): Declare new
member functions.
({function_decl_diff, type_decl_diff}::traverse): Remove.
(typedef_diff::typedef_diff): Take the underlying type diff as
parameter.
(typedef::{finish_diff_type, get_pretty_representation,
chain_into_hierarchy}): Declare new member functions.
({typedef, translation_unit_diff}::traverse): Remove member
function.
(corpus_diff::{finish_diff_type, children_nodes,
append_child_node, changed_variables, get_pretty_representation,
chain_into_hierarchy}): Declare new member functions.
(class diff_node_visitor::{visit_begin, visit_end}): Declare new
member functions.
(propagate_categories, print_diff_tree, categorizing_redundancy)
(clear_redundancy_categorization, apply_filters): New functions
and function overloads.
* src/abg-comparison.cc (TRY_PRE_VISIT, TRY_PRE_VISIT_CLASS_DIFF)
(TRY_POST_VISIT, TRY_POST_VISIT_CLASS_DIFF)
(CATEGORIZE_REDUNDANCY_FROM_CHILD_NODE)
(UPDATE_REDUNDANCY_CATEGORIZATION_FROM_NODE_SUBTREE)
(TRAVERSE_DIFF_NODE_AND_PROPAGATE_CATEGORY)
(TRAVERSE_MEM_DIFF_NODE_AND_PROPAGATE_CATEGORY)
(TRAVERSE_MEM_FN_DIFF_NODE_AND_PROPAGATE_CATEGORY)
(ENSURE_DIFF_NODE_TRAVERSED_ONCE)
(ENSURE_MEM_DIFF_NODE_TRAVERSED_ONCE): Remove these macros.
Hurrah.
(diff_context::priv::categorizing_redundancy_): Remove.
(diff_context::priv::forbid_traversing_a_node_twice_): Add new
data member.
(diff_context::priv::priv): Adjust.
(diff_context::{forbid_traversing_a_node_twice,
traversing_a_node_twice_is_forbidden}): Define new member
functions.
(diff_context::maybe_apply_filters): Once filters are applied (and
categories are set to the relevant diff tree nodes, run a pass
over the diff tree to propagate the categories to the relevant
diff tree parent nodes. Add an overload for corpus_diff_sptr.
(diff_context::categorizing_redundancy): Remove member function.
(diff_context::maybe_apply_filters): Define a new overload for
corpus_diff_sptr
(struct diff::priv::{finished_, traversing_, children_,
pretty_representation_}): New data members.
(diff::priv::priv): Adjust.
(diff::{begin_traversing, is_traversing, end_traversing,
finish_diff_type, children_nodes, append_child_node, traverse,
set_category, get_pretty_representation, chain_into_hierarchy}):
Define new member functions.
(diff::is_filtered_out): Do not refer to NOT_REDUNDANT_CATEGORY
anymore. Rather, use the new REDUNDANT_CATEGORY.
({distinct_diff, var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, function_decl_diff, type_decl_diff,
typedef_diff}::{get_pretty_representation, chain_into_hierarchy,
finish_diff_type}): Define new member functions.
({distinct_diff, var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, function_decl_diff, type_decl_diff,
typedef_diff, translation_unit_diff}::traverse): Remove member
functions.
(operator&=, operator<<): Define new operators for diff_category.
({function_decl_diff, typedef_diff}::priv::priv): Add a new
constructor.
(pointer_diff::{priv::priv, pointer_diff})
(reference_diff::{priv::priv, reference_diff})
(qualified_type_diff::{priv::priv, qualified_type_diff})
(enum_diff::{priv::priv, enum_diff}, base_diff::{priv::priv,
base_diff}, function_decl_diff::function_decl_diff): Take the
underlying type diff in parameter.
(compute_diff): Adjust the pointer_diff, reference_diff,
qualified_type_diff, base_diff, function_decl_diff overloads.
(class_diff::priv::{count_filtered_bases,
count_filtered_subtype_changed_dm, count_filtered_changed_dm,
count_filtered_changed_mem_fns, count_filtered_inserted_mem_fns,
count_filtered_deleted_mem_fns}): Adjust for the call to
diff_context::maybe_apply_filters.
(corpus_diff::priv::{finished_, pretty_representation_}): New data
member.
(corpus_diff::priv::priv): New constructor.
(corpus_diff::priv::clear_redundancy_categorization): Define new
member function.
(corpus_diff::priv::apply_filters_and_compute_diff_stats):
Adjust for call to diff_context::maybe_apply_filters. Also, call
clear_redundancy_categorization at the end.
(corpus_diff::priv::categorize_redundant_changed_sub_nodes):
Revisit logic.
(corpus_diff::{chain_into_hierarchy, finish_diff_type,
children_nodes, append_child_node, changed_variables,
get_pretty_representation}): Define new member functions.
(corpus_diff::report): Categorize redundancy for every top level
function/variable diff.
(corpus_diff::traverse): Adjust to the new traversing interface.
(diff_node_visitor::{visit_begin, visit_end}): Define new member
functions.
(struct category_propagation_visitor, struct diff_node_printer)
(struct redundancy_marking_visitor, struct
redundancy_clearing_visitor): New diff tree node visitors.
(propagate_categories, print_diff_tree, categorize_redundancy)
(clear_redundancy_categorization, apply_filters): Define new
functions.
* tests/Makefile.am: Add the new tests/print-diff-tree.cc to the
source distribution. Build it into a tests/printdifftree binary.
* tools/abidiff.cc (print_diff_tree): Add debugging functions to
call from within the debugger. By default, this function and its
overloads are not compiled.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (represent): When a virtual member
function has no associated elf symbol, do not emit garbage in lieu
of the linkage name. Just emit no linkage name;
* tests/data/test-abidiff/test-struct1-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-fwd.h (get_member_function_is_virtual): Declare new
overload for pointers.
* src/abg-ir.cc (get_member_function_is_virtual): Define it.
(function_decl::get_pretty_representation): Print virtual-ness of
the function_decl being pretty printed.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tests/data/test-bidiff: Rename this directory to
tests/data/test-abidiff.
* tests/test-bidiff.cc: Renamed this to tests/test-abidiff.cc.
* tools/biar.cc: Renamed to tools/abiar.cc
* tools/bidiff.cc: Renamed to tools/abidiff.cc
* tools/bidw.cc: Renamed to tools/abidw.cc
* tools/bilint.cc: Renamed to tools/abilint.cc
* tools/bisym.cc: Renamed to tools/abisym.cc
* tests/test-alt-dwarf-file.cc: Renamed references to bidw* to abidw*.
* tests/test-diff-filter.cc: Renamed references to bidiff to abidiff.
* tests/test-lookup-syms.cc: Renamed references to bisym to abisym.
* tools/Makefile.am: Adjust.
* tests/Makefile.am: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h
(diff_category::HARMLESS_SYMBOL_ALIAS_CHANGE_CATEORY): New
enumerator.
(diff_category::EVERYTHING_CATEGORY): Adjust.
* include/abg-ir.h (elf_symbol::get_aliases_id_string)
(elf_symbol::does_alias, elf_symbols_alias)
(compute_aliases_for_elf_symbol): Declare new functions ...
* src/abg-ir.cc (elf_symbol::get_aliases_id_string)
(elf_symbol::does_alias, elf_symbols_alias)
(compute_aliases_for_elf_symbol): ... and define them.
(function_decl::operator==): Take in account elf symbol aliases.
* src/abg-comp-filter.cc (function_name_changed_but_not_symbol):
Define new static functions.
(harmless_filter::visit): Categorize function name changes that
n doesn't impact underlying elf symbols (or the fact that two
symbols were aliases and are not anymore) as harmless.
* src/abg-comparison.cc (function_decl_diff::report): Properly
report function name changes, or symbol aliases changes for that
matter. Also report inline-ness declaration changes.
* src/abg-dwarf-reader.cc (die_is_declared_inline): New static
function.
(build_function_decl): Use the above.
* tools/bidiff.cc (set_diff_context_from_opts): Add
abigail::comparison::HARMLESS_SYMBOL_ALIAS_CHANGE_CATEORY into the
harmless change camp.
* tests/data/test-diff-dwarf/test14-inline-report.txt: New test
input.
* tests/data/test-diff-dwarf/test14-inline-v0.o: Likewise.
* tests/data/test-diff-dwarf/test14-inline-v1.o: Likewise.
* tests/data/test-diff-dwarf/test14-inline-v0.cc: Source code for
test input.
* tests/data/test-diff-dwarf/test14-inline-v1.cc: Source code for
test input.
* tests/test-diff-dwarf.cc: Run this test harness over the new
input above.
* tests/data/test-diff-filter/test20-inline-report-0.txt: Likewise.
* tests/data/test-diff-filter/test20-inline-report-1.txt:
Likewise.
* tests/data/test-diff-filter/test20-inline-v0.o: New test input.
* tests/data/test-diff-filter/test20-inline-v1.o: New test input.
* tests/data/test-diff-filter/test20-inline-v0.cc: Source code for
test input.
* tests/data/test-diff-filter/test20-inline-v1.cc: Likewise.
* tests/test-diff-filter.cc: Run this test harness over the new
input above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h (changed_enumerator_type): New typedef.
(diff_category::{HARMLESS_ENUM_CHANGE_CATEGORY}): New enumerator.
* src/abg-comp-filter.cc (has_type_size_change)
(has_enumerator_insertion, has_enumerator_removal_or_change)
(has_harmful_enum_change): New functions.
(harmless_filter::visit): Categorize enumerator insertions that
don't change the size of the type into HARMLESS_ENUM_CHANGE_CATEGORY.
(harmful_filter::visit): Categorize enumerator removal or any enum
change that changes the size of the type into
SIZE_OR_OFFSET_CHANGE_CATEGORY.
* src/abg-comparison.cc (enumerator_value_comp)
(changed_enumerator_comp): New types.
(sort_enumerators, sort_changed_enumerators): New static
functions.
(enum_diff::report): Sort enum related reports by the value of the
enumerators.
* src/abg-dwarf-reader.cc (build_enum_type): Name anonymous enums
as __anonymous_enum__.
* tools/bidiff.cc (set_diff_context_from_opts): Add
abigail::comparison::HARMLESS_ENUM_CHANGE_CATEGORY into the harmless
stuff camp.
* tests/data/test-diff-dwarf/test15-enum-report.txt: New test
input.
* tests/data/test-diff-dwarf/test15-enum-v1.o: Likewise.
* tests/data/test-diff-dwarf/test15-enum-v0.o: Likewise.
* tests/data/test-diff-dwarf/test15-enum-v0.cc: Source code for
test input.
* tests/data/test-diff-dwarf/test15-enum-v1.cc: Likewise.
* tests/data/test-diff-filter/test19-enum-report-0.txt: New test input.
* tests/data/test-diff-filter/test19-enum-report-1.txt: Likewise.
* tests/data/test-diff-filter/test19-enum-v0.o: Likewise.
* tests/data/test-diff-filter/test19-enum-v1.o: Likewise.
* tests/data/test-diff-filter/test19-enum-v0.cc: Source code for
test input.
* tests/data/test-diff-filter/test19-enum-v1.cc: Likewise.
* tests/test-diff-dwarf.cc: Run this test harness on the new test
inputs above.
* tests/test-diff-filter.cc: Likewise.
* tests/Makefile.am: Add the new files above to the source distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* configure.ac(AM_INIT_AUTOMAKE): Set the subdir-object option
here ..
* src/Makefile.am: ... not here.
* tests/Makefile.am: Likewise.
* tools/Makefile.am: Likewise.
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
* include/abg-comparison.h (changed_type_or_decl_vector): New
typedef.
* include/abg-fwd.h (is_data_member): Change the overload that
takes a decl_base_sptr to make it return the real var_decl_sptr
rather than just a bool.
* src/abg-comparison.cc (ChangedDataMemberComp, DataMemberComp):
New comparison functors.
(sort_changed_data_members, sort_data_members): Sorting functions
for changed data members and data members.
(class_diff::report): Sort reports for deleted, inserted and
change data members by the increasing value of the offsets of said
data members.
* src/abg-ir.cc (is_data_member): Change the overload that takes a
decl_base_sptr to make it return the real var_decl_sptr rather
than just a bool.
* tests/data/test-bidiff/test-struct1-report.txt: Adjust.
* tests/data/test-diff-dwarf/test13-report.txt: New test input.
* tests/data/test-diff-dwarf/test13-v0.cc: Source code for new
test input.
* tests/data/test-diff-dwarf/test13-v0.o: New test input.
* tests/data/test-diff-dwarf/test13-v1.cc: Source code for new
test input.
* tests/data/test-diff-dwarf/test13-v1.o: New test input.
* tests/Makefile.am: Add the new test inputs above to the source
distribution.
* tests/test-diff-dwarf.cc: Run this test harness on the new test
input.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (diff::is_filtered_out): If a diff not is
only in the NOT_REDUNDANT_CATEGORY category consider it as not
being filtered.
* tests/data/test-diff-filter/test18-report.txt: New test input.
* tests/data/test-diff-filter/test18-v0.cc: Source code for new
test input.
* tests/data/test-diff-filter/test18-v0.o: New test input.
* tests/data/test-diff-filter/test18-v1.cc: Source code for new
test input.
* tests/data/test-diff-filter/test18-v1.o: New test input.
* tests/Makefile.am: Add the new test inputs to the source distribution.
* tests/test-diff-filter.cc: Run this test harness on the new test
input above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER{2,3}): New
macros.
({pointer_diff, array_diff, reference_diff, qualified_type_diff,
class_diff, typedef_diff}::report): Use the new macros above.
* tests/data/test-bidiff/test-qual-type0-report.txt: Adjust
because type pretty representation are now always quoted.
* tests/data/test-bidiff/test-struct1-report.txt: Adjust likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* configure.ac: Support a new --enable-zip-archive option. By
default its value is set to the 'auto', meaning that if libzip is
installed, that turns the option on -- just like if
--enable-zip-archive was called with the value 'yes'; if libzip is
not installed, that turns the option off -- just like if
--enable-zip-archive was called with the value 'no'. If libzip is
detected, the pre-processor macro HAVE_LIBZIP is set to 1. If
--enable-zip-archive is turned on, the pre-processor macro
WITH_ZIP_ARCHIVE is set to 1.
* config.h.in (HAVE_LIBZIP, WITH_ZIP): New define.
* src/abg-corpus.cc: Include config.h. Guard the inclusion of
abg-libzip-utils.h with the WITH_ZIP_ARCHIVE macro. Likewise for
the use of declarations coming from abg-libzip-utils.h.
* src/abg-libzip-utils.cc: Include config.h. Guard the file's
content with the WITH_ZIP_ARCHIVE macro.
* src/abg-reader.cc: Include config.h. Guard the inclusion of
abg-libzip-utils.h with the WITH_ZIP_ARCHIVE. Likewise for the
use of declarations coming from abg-libzip-utils.h.
* src/abg-writer.cc: Likewise.
* tests/Makefile.am: Build runtestwritereadarchive and runtestdot
only if zip archives are supported.
* tools/Makefile.am: The biar program is built only if
zip archives are supported.
* tools/bidiff.cc: Handle zip archives only if the
WITH_ZIP_ARCHIVE macros is defined.
* tools/bilint.cc: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (ENSURE_DIFF_NODE_TRAVERSED_ONCE): If the
diff node is being traversed for the first time, mark it as being
in the NOT_REDUNDANT_CATEGORY. I don't know why I was doing this
only for classes and basic types. Update comments.
* tests/data/test-diff-filter/test16-report.txt: New test input.
* tests/data/test-diff-filter/test16-v0.cc: Source code of new
test input.
* tests/data/test-diff-filter/test16-v0.o: New test input.
* tests/data/test-diff-filter/test16-v1.cc: Source code of new
test input.
* tests/data/test-diff-filter/test16-v1.o: New test input.
* tests/data/test-diff-filter/test17-0-report.txt: Likewise.
* tests/data/test-diff-filter/test17-1-report.txt: Likewise.
* tests/data/test-diff-filter/test17-v0.cc: Source code of new
test input.
* tests/data/test-diff-filter/test17-v0.o: Likewise.
* tests/data/test-diff-filter/test17-v1.cc: Source code of new
test input.
* tests/data/test-diff-filter/test17-v1.o: Likewise.
* tests/Makefile.am: Add the new files to the source distribution.
* tests/test-diff-filter.cc (in_out_spec): Run this test harness
over the new test inputs.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tools/bidiff.cc (display_usage): Change--no-linkage-names -o
--no-linkage-name in the help string.
(parse_command_line): Adjust the command line parsing accordingly.
* tests/test-diff-filter.cc (in_out_specs): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-corpus.h
(corpus::lookup_{function,variable}_symbol): Add an overload
declaration that takes the version of the symbol to lookup.
* src/abg-comparison.cc
(corpus_diff::priv::ensure_lookup_tables_populated): So when looking
up the corpora for symbols, take their versions in account.
* src/abg-corpus.cc (corpus::lookup_{function,variable}_symbol):
Add an overload definition that takes the version of the symbol to
lookup.
(symtab_build_visitor_type::build_id): New
member functions.
(corpus::priv::build_public_decl_table): Use the new member
functions above.
* src/abg-ir.cc (elf_symbol::version::operator==): Do not take the
is_default flag in account when comparing two symbol versions.
* libtest12-v{0,1}.so: New test input files.
* libtest12-v{0,1}.c: Source code for the test input files.
* test12-version-script: Version script to build the files above.
* test12-report.txt: Test input file.
* tests/Makefile.am: Add the new test input files above to the
source distribution.
* tests/test-diff-dwarf.cc (in_out_specs[]): Add an entry to this
table for the new test input files.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comp-filter.h (has_harmless_name_change): New
function declaration.
* include/abg-comparison.h
(diff_category::DECL_NAME_CHANGE_CATEGORY): Renamed this into
HARMLESS_DECL_NAME_CHANGE_CATEGORY.
(diff_category::EVERYTHING_CATEGORY): Update.
* include/abg-fwd.h (is_enum): New function declaration.
(is_var_decl): Return the shared_ptr<var_decl> rather than a bool.
(is_data_member): New overload that takes a shared_ptr<decl_base>.
* src/abg-comp-filter.cc (decl_name_changed): Consider the
qualified name here.
(has_harmless_name_change): Define new function declaration.
(harmless_filter::visit): Use the new has_harmless_name_change
function.
* src/abg-comparison.cc (represent)
(report_name_size_and_alignment_changes, enum_diff::report)
(typedef_diff::report, is_data_member): Use the new
filtering::has_harmless_name_change function to simplify logic of
emitting the name change related diff
* tools/bidiff.cc (set_diff_context_from_opts): Adjust
DECL_NAME_CHANGE_CATEGORY -> HARMLESS_DECL_NAME_CHANGE_CATEGORY.
* src/abg-ir.cc (is_data_member, is_enum): New function definitions.
(is_var_decl): Return the var_decl_sptr rather than just a bool.
* tests/data/test-diff-filter/test13-report.txt: Adjust.
* tests/data/test-diff-filter/test6-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h (array_diff): Declare new class.
(array_diff_sptr): Shared pointer to type array_diff.
(compute_diff): Overload the function to take type
array_diff_sptr as the first two arguments.
* include/abg-fwd.h (array_type_def): Declare new class.
(subrange_type): Likewise.
(is_array_def): Declare new function.
* include/abg-ir.h (array_type_def_sptr): Shared pointer
to type array_type_def.
(array_type_def): Declare new class.
(ir_node_visitor::visit): Declare a new virtual function
taking a pointer to type array_type_def as an argument.
* src/abg-comparison.cc (compute_diff_for_types): Add
try_to_diff for two instances of type array_type_def.
(array_diff::priv): declare struct for holding private members
of type array_diff.
(array_diff::array_diff): Define constructor.
(array_diff::{first,second}_array):Define new
member functions.
(array_diff::element_type_diff): Likewise.
(array_diff::{length,report,traverse}): Likewise.
(compute_diff): Define function overloaded in
include/abg-comparison.h.
* src/abg-dwarf-reader.cc (build_array_type): Define new
function. Handle DW_TAG_array_type and DW_TAG_subrange type.
(build_ir_node_from_die): Amend case DW_TAG_array_type with
a call to build_array_type.
* src/abg-hash.cc (array_type_def::hash): Declare new struct.
(type_base::dynamic_hash::operator()): Attempt to dynamic_cast
the argument to type array_type_def as well.
(array_type_def::hash): Declare new struct.
* src/abg-ir.cc (array_type_def::array_type_def): Define
constructors.
(array_type_def::priv): declare struct for holding private members
of type array_type_def.
(array_type_def::operator==(const decl_base&):
Define new operator.
(array_type_def::operator==(const type_base&):
Likewise.
(array_type_def::append_subrange{,s}): Define
new functions.
(array_type_def::{set,get}_size_in_bits): Likewise.
(array_type_def::get_dimension_count): Likewise.
(array_type_def::get_qualified_name): Likewise.
(array_type_def::get_pretty_representation): Likewise.
(array_type_def::get_subrange_representation): Likewise.
(array_type_def::traverse): Likewise.
(array_type_def::get_{element_type,location,subranges}): Likewise.
(array_type_def::is_infinite): Likewise.
(array_type_def::~array_type_def): Define destructor.
(ir_node_visitor::visit): Define function, taking
pointer to array_type_def as an argument.
* src/abg-reader.cc (map_id_and_node): Check if node
is an array.
(is_array_def): Check if object is an array.
(handle_element_node): Handle array_type_def as well.
(build_subrange_type): Define new function.
(build_array_type_def): Likewise.
(build_type): Build type array_type_def as well.
(build_type_composition): Likewise.
(handle_array_type_def): Define new function.
* src/abg-writer.cc: (write_decl): Output arrays
as well.
(write_member_type): Likewise.
(write_type_composition): Likewise.
(write_array_type_def): Define new function.
* tests/data/test-diff-dwarf/test{10,11}-v{0,1}.{cc,o}: New test source
files
* tests/data/test-diff-dwarf/test{10,11}-report.txt: Likewise.
* tests/data/test-diff-dwarf/test10-report.txt: New test input.
* tests/data/test-read-dwarf/test7.cc: New test source
file.
* tests/data/test-read-dwarf/test7.so: New input binary
to read.
* tests/data/test-read-dwarf/test7.so.abi: New reference
test to compare against.
* tests/data/test-read-write/test25.xml: New test source
file.
* tests/test-diff-dwarf.cc: Adjust to launch the new test.
* tests/test-read-dwarf.cc: Likewise.
* tests/test-read-write.cc: Likewise.
* test/Makefile.am: Add the new test inputs to the source
distribution.
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-ir.cc (elf_symbol::is_variable): Accept TLS objects as
variables too.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr)
(die_location_address): Add an output parameter to say if the
resulting constant value is a tls address or not.
(lookup_public_variable_symbol_from_elf): Use the proper
elf_symbol::is_variable() method, rather than trying to figure out
the low levels of what a variable is here. Also, cleanup the
condition.
(read_context::load_symbol_maps): Consider symbols of type
STT_TLS, when loading symbols for variables. Also, to avoir
symbols that are for versions, filter out symbols of type
STT_OBJECT and with a SHN_ABS section index.
(read_context::get_variable_address): If the address is for a tls
variable, do no try to adjust the address to arrange for things
like prelink. As that doesn't seem to affect TLS variables.
(dwarf_expr_eval_context::set_tls_addr): New data member.
(dwarf_expr_eval_context::dwarf_expr_eval_context): Initialize it.
(dwarf_expr_eval_context::set_tls_address): New accessors.
(dwarf_expr_eval_context::op_manipulates_stack): Handle
DW_OP_GNU_push_tls_address, a bit like DW_OP_form_tls_address, but
then, its result is a constant. Set the
dwarf_expr_eval_context::set_tls_addr flag when these two OPs are
run.
(die_member_offset): Adjust to the new signature of
eval_last_constant_dwarf_sub_expr.
* tests/data/test-diff-dwarf/libtest9-v0.so: New test input.
* tests/data/test-diff-dwarf/libtest9-v1.so: Likewise.
* tests/data/test-diff-dwarf/test9-report.txt: Likewise
* tests/data/test-diff-dwarf/test9-v0.cc: Source code for the
first input.
* tests/data/test-diff-dwarf/test9-v1.cc: Source code for the
second input.
* tests/test-diff-dwarf.cc: Run this harness on the two new inputs
above.
* tests/Makefile.am: Add the new inputs to the source distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tests/data/test-alt-dwarf-file/test0-debug-dir/.build-id/16/7088580c513b439c9ed95fe6a8b29496495f26.debug:
Make this link be relative.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
ABGBZ#17193
* include/abg-dwarf-reader.h (class read_context)
(typedef read_context_sptr, create_read_context)
(has_alt_debug_info): Declare these.
(read_corpus_from_elf): Declare new overload.
* src/abg-dwarf-reader.cc (find_alt_debug_info)
(is_die_attribute_resolved_through_gnu_ref_alt)
(build_primary_die_parent_relations_under)
(build_alternate_die_parent_relations_under):
Define new static functions.
(read_context::{alt_dwarf_,
alt_debug_info_path_, alternate_die_decl_map_,
alternate_die_parent_map_}): New data members.
(read_context::{alt_dwarf, alt_debug_info_path,
alternate_die_decl_map, associate_die_to_decl_primary,
associate_die_to_decl_alternate, associate_die_to_decl,
lookup_decl_from_die_offset_primary,
lookup_decl_from_die_offset_alternate,
lookup_decl_from_die_offset, alternate_die_parent_map}): New
member functions.
(read_context::load_debug_info): Painfully Get a handle on the
alternate debug info section too. We shouldn't have to do all
this work; we could use the new dwarf_getalt() function from
libdw, but we cannot as we want to support supports that predate
that api. When a version of elfutils gets released with that api
though, we should conditionally use that instead.
(build_ir_node_from_die, get_parent_die, get_scope_for_die)
(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): Take a new parameter that
tells if the input DIE is from alternate debug info. Adjust their
code accordingly.
(die_die_attribute): Take a new output parameter that tells if the
resolved DIE is from alternate debug info. Also take a new
parameter that tells if the input DIE is from alternate debug info
sections.
(build_die_parent_relations_under): Take the DIE -> parent map to
act upon. Also, add a new overload that takes a flag saying if
the DIE is from alternate debug info or not, and act upon that.
(build_die_parent_maps): Renamed build_die_parent_map into this
and make it build DIE -> parent DIE relationship for the alternate
debug info file as well.
(find_last_import_unit_point_before_die, ): Adjust to use the
information about if the relevant DIEs are in alternate debug info
or not.
(build_translation_unit_and_add_to_ir): Clear the alternate DIE ->
decl map, that is per TU just as the primary DIE -> decl map.
Adjust to use the information about if the relevant DIEs are in
alternate debug info or not.
(read_debug_info_into_corpus): Build the two DIE -> DIE parent
maps (one for the primary debug info and one for the alternate
debug info).
(create_read_context, has_alt_debug_info): Define new public entry
points.
(read_corpus_from_elf): New entry point overload that takes a
read_context.
* tools/bidw.cc (options::{check_alt_debug_info_path,
show_base_name_alt_debug_info_path}): New data members.
(display_usage): Update for the two new options
--check-alternate-debug-info and
check-alternate-debug-info-base-name.
(parse_command_line): Parse the two options above.
(main) Handle the two new options above.
* tests/Makefile.am: Build the new runtestaltdwarf test. Add the
new data/test-alt-dwarf-file/* files to the build system.
* tests/test-alt-dwarf-file.cc: New test driver.
* tests/data/test-alt-dwarf-file/test0-common.cc: New test input
files.
* tests/data/test-alt-dwarf-file/libtest0-common.so: Likewise.
* tests/data/test-alt-dwarf-file/test0.cc: Likewise.
* tests/data/test-alt-dwarf-file/libtest0.so: Likewise.
* tests/data/test-alt-dwarf-file/test0.h: Likewise.
* tests/data/test-alt-dwarf-file/test0-common-dwz.debug: Likewise.
* tests/data/test-alt-dwarf-file/test0-debug-dir/.build-id/16/7088580c513b439c9ed95fe6a8b29496495f26.debug:
Likewise.
* tests/data/test-alt-dwarf-file/test0-debug-dir/test0-common-dwz.debug:
Likewise.
* tests/data/test-read-dwarf/test1.abi: Adjust. bidw doesn't emit
an abstract constructor/destructor anymore. It emits just the
functions matching the cdtor symbols found in the binary.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-ir.cc (is_public): Change in function to consider
symbols with STB_GNU_UNIQUE binding as public
* tests/data/test-read-dwarf/test6.cc: Test file to generate
STB_GNU_UNIQUE binding symbols
* tests/data/test-read-dwarf/test6.so: Test shared library having
STB_GNU_UNIQUE binding symbols
* tests/data/test-read-dwarf/test6.so.abi: XML file containing
dwarf information from test6.so
* tests/test-read-dwarf.cc (in_out_specs): Add the new test above
* tests/Makefile.am: Add tests/data/test-read-dwarf/test6.cc,
tests/data/test-read-dwarf/test6.so and
tests/data/test-read-dwarf/test6.so.abi to the distribution
Signed-off-by: Sinny Kumari <skumari@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (type_decl::get_void_type_decl): Declare new
static method.
* src/abg-ir.cc (type_decl::get_void_type_decl): Define it.
* src/abg-dwarf-reader.cc (build_ir_node_for_void_type): Define
new static function.
(build_pointer_type_def): Support void* type nodes here.
* tests/data/test-read-dwarf/test5.cc: Source code for new test
input.
* tests/data/test-read-dwarf/test5.o: New test input.
* tests/data/test-read-dwarf/test5.o.abi: Likewise.
* tests/Makefile.am: Add the above to the source distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/Makefile.am: Add the subdir-object automake option here.
Do not specify absolute paths for the input files as Automake now
takes care of that just fine.
* tests/Makefile.am: Likewise.
* tools/Makefile.am: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@seketeli.org>
* include/abg-comp-filter.h (class harmful_filter): Update
comment.
(class redundant_filter): Declare new filter.
* include/abg-comparison.h (enum
diff_category::NOT_REDUNDANT_CATEGORY): New category. Update the
values of the other enumerators.
(diff_context::{add_diff, diff_has_been_traversed}): New overloads.
(diff_context::{categorizing_redundancy, show_redundant_changes}):
Declare new methods.
(diff_context::remove_from_category): Define new inline method.
* src/abg-comparison.cc (noop_deleter::operator()): Constify the
parameter.
(CATEGORIZE_REDUNDANCY_FROM_CHILD_NODE)
(UPDATE_REDUNDANCY_CATEGORIZATION_FROM_NODE_SUBTREE): New macros.
(TRAVERSE_DIFF_NODE_AND_PROPAGATE_CATEGORY)
(TRAVERSE_MEM_DIFF_NODE_AND_PROPAGATE_CATEGORY)
(TRAVERSE_MEM_FN_DIFF_NODE_AND_PROPAGATE_CATEGORY): Use the new
CATEGORIZE_REDUNDANCY_FROM_CHILD_NODE and
UPDATE_REDUNDANCY_CATEGORIZATION_FROM_NODE_SUBTREE macros above.
(ENSURE_DIFF_NODE_TRAVERSED_ONCE)
(ENSURE_MEM_DIFF_NODE_TRAVERSED_ONCE): If the (type_decl or class)
node hasn't been yet traversed, mark it as non-redundant.
(diff_context::priv::categorizing_redundancy): New member.
(diff_context::priv::priv): Initialize it.
(diff_context::{add_diff, diff_has_been_traversed): Define new
overloads.
(diff_context::mark_diff_as_traversed): Intern a diff node that is
marked as being traversed.
(diff_context::{categorizing_redundancy, show_redundant_changes}):
Define new methods.
(diff::is_filtered_out): A redundant function or top-level
variable is considered filtered-out. Otherwise, the new
NOT_REDUNDANT_CATEGORY doesn't play any role when comparing
allowed categories with the set of categories a diff node belongs
to.
(corpus::priv::categorize_redundant_changed_sub_nodes): Define
new member function.
(corpus_diff::priv::apply_filters_and_compute_diff_stats): Change
this to first walk the changed functions and variables to apply
filters, then categorize redundant changed functions, and then
walk the changed functions and variables again to count
filtered-out diff nodes.
(filtering::redundant_filter::visit): Define new member function.
* tools/bidiff.cc (options::show_redundant_changes): New data
member.
(options::options): Initialize it.
(display_usage): Add help string for the --redundant command line
option.
(parse_command_line): Add support for the --redundant command line
option.
(set_diff_context_from_opts): Take the --redundant command line
option in account.
* tests/test-diff-filter.cc: Update this to add new test inputs.
* tests/data/test-diff-filter/test14-0-report.txt: New test input.
* tests/data/test-diff-filter/test14-1-report.txt: Likewise.
* tests/data/test-diff-filter/test14-v0.cc: Likewise.
* tests/data/test-diff-filter/test14-v0.o: Likewise.
* tests/data/test-diff-filter/test14-v1.cc: Likewise.
* tests/data/test-diff-filter/test14-v1.o: Likewise.
* tests/data/test-diff-filter/test15-0-report.txt: Likewise.
* tests/data/test-diff-filter/test15-1-report.txt: Likewise.
* tests/data/test-diff-filter/test15-v0.cc: Likewise.
* tests/data/test-diff-filter/test15-v0.o: Likewise.
* tests/data/test-diff-filter/test15-v1.cc: Likewise.
* tests/data/test-diff-filter/test15-v1.o: Likewise.
* tests/Makefile.am: Add the above to the build system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-writer.cc (write_elf_symbol_aliases): Changing function
to keep multiple symbol aliases within one alias attribute
* src/abg-reader.cc (build_elf_symbol_db): Changing function to read
symbol's alias attribute and split if multiple alias exist with comma(,)
asi a delimiter and add all aliases to main symbol
* tests/data/test-read-dwarf/test3.c: Test file to generate multiple aliases
* tests/data/test-read-dwarf/test3.so: Test shared library having multiple
aliases of a symbol
* tests/data/test-read-dwarf/test3.so.abi: XML file containing dwarf
information from test3.so
* tests/test-read-dwarf.cc (in_out_specs): Add the new test above
* tests/Makefile.am: Add tests/data/test-read-dwarf/test3.c,
tests/data/test-read-dwarf/test3.so and tests/data/test-read-dwarf/test3.so.abi
to the distribution
Signed-off-by: Sinny Kumari <skumari@redhat.com>
* include/abg-dwarf-reader.h (enum status): New enum.
(read_corpus_from_elf): Return an instance of status above, and
return the corpus by parameter.
* src/abg-dwarf-reader.cc (create_default_dwfl): Add a comment
about elfutils wanting the Dwfl_Callbacks::debuginfo_path to be an
absolute path.
(read_corpus_from_elf): Return an instance of status above, and
return the corpus by parameter.
* tools/abg-tools-utils.h (make_path_absolute): Declare new function.
* tools/abg-tools-utils.cc (make_path_absolute): New
implementation.
* tools/bidiff.cc (options::di_root_path[12]): Make these be
shared pointers.
(parse_command_line): ensure the debug info root paths are
absolute.
(main): Adjust. Give meaningful errors when the debug info or
symbol files couldn't be read.
* tools/bidw.cc (options::di_root_path): Make this be a shared
pointer.
(parse_command_line): Ensure the debug info root path is absolute.
(main): Adjust. Give meaningful errors when the debug info or
symbol files couldn't be read.
* tools/bilint.cc (options::di_root_path): Make this be a shared
pointer.
(parse_command_line): Ensure the debug info root path is absolute.
(main): Adjust. Give meaningful errors when the debug info or
symbol file couldn't be read.
* tests/test-diff-dwarf.cc (main): Adjust.
* tests/test-read-dwarf.cc (main): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tools/bidiff.cc (options::options): Initialize
options::show_linkage_names to true and
options::show_harmful_changes to false.
(parse_command_line): Change --linkage-names into
--no-linkage-names as the linkage names are now displayed by
default. Change --no-harmless into --harmless as harmless changes
are now filtered by default.
(display_usage): Update help string for the --linkage-names ->
--no-linkage-names and --no-harmful -> --harmful change.
* tests/test-diff-filter.cc: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* 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>
* include/abg-dwarf-reader.h (read_corpus_from_elf): Take a
debug_info_root_path parameter.
src/abg-dwarf-reader.cc (create_default_dwfl): Take a
debug_info_root_path. Use that to initialize the Dwfl_Callbacks
structure used by dwfl_begin.
(create_default_dwfl_sptr, read_corpus_from_elf): Likewise, Take a
debug_info_root_path parameter.
* tests/test-diff-dwarf.cc (main): Adjust.
* tests/test-read-dwarf.cc (main): Likewise.
* tools/bidiff.cc (options::dir_root_path[12]): New member.
(options::options): Initialize it.
(display_usage): Add help string for the --debug-info-dir[12]
options.
(parse_command_line): Handle the new --debug-info-dir[12] options.
(main): Pass the debug info directories to read_corpus_from_elf.
* bidw.cc (options::::di_root_path): New member.
(options::options): Initialize it.
(display_usage): Add help string for the new --debug-info-dir
option.
(parse_command_line): Handle the new --debug-info-dir.
(main): Pass the debug info root path to read_corpus_from_elf.
* tools/bilint.cc (options::di_root_path): New member.
(options::options): Initialize it.
(display_usage): Add help string for the new --debug-info-dir.
(parse_command_line): Handle --debug-info-dir command line option.
(main): Pass the debug info root path to read_corpus_from_elf.
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>
* src/abg-dwarf-reader.cc (find_symbol_table_section): Return the
.symtab if we are looking at an executable or relocatable file and
.dynsym if we are looking at a DSO.
(find_symbol_table_section_index): Likewise. Implement this in
terms of find_symbol_table_section.
(build_{function,var}_decl): Set the linkage_name to the symbol
name, if the symbol name is not empty.
* tests/data/test-diff-filter/test9-report.txt: 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-corpus.cc (corpus_priv::build_symbol_table): If a
function or variable symbol is not public (global or weak) and
present in an elf symbol table, drop it from the corpus symbol
table. As a result functions are variables (not present in the
elf symbol tables) that we were previously taking in account are
not dropped on the floor, leading to much less noise.
* tests/data/test-diff-dwarf/test0-v0.cc: Update to avoid
generating inline functions.
* tests/data/test-diff-dwarf/test0-v0.o: Likewise.
* tests/data/test-diff-dwarf/test0-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test0-v1.o: Likewise.
* tests/data/test-diff-dwarf/test7-v0.o: Likewise.
* tests/data/test-diff-dwarf/test7-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test7-v1.o: Likewise.
* tests/data/test-diff-dwarf/test8-v0.cc: Likewise.
* tests/data/test-diff-dwarf/test8-v0.o: Likewise.
* tests/data/test-diff-dwarf/test8-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test8-v1.o: Likewise.
* tests/data/test-diff-filter/test0-v0.cc: Likewise.
* tests/data/test-diff-filter/test0-v0.o: Likewise.
* tests/data/test-diff-filter/test0-v1.cc: Likewise.
* tests/data/test-diff-filter/test0-v1.o: Likewise.
* tests/data/test-diff-filter/test10-v0.cc: Likewise.
* tests/data/test-diff-filter/test10-v0.o: Likewise.
* tests/data/test-diff-filter/test10-report.txt: Likewise.
* tests/data/test-diff-filter/test10-v1.o: Likewise.
* tests/data/test-diff-filter/test13-v0.cc: Likewise.
* tests/data/test-diff-filter/test13-v0.o: Likewise.
* tests/data/test-diff-filter/test13-v1.cc: Likewise.
* tests/data/test-diff-filter/test13-v1.o: Likewise.
* tests/data/test-diff-filter/test2-v0.cc: Likewise.
* tests/data/test-diff-filter/test2-v0.o: Likewise.
* tests/data/test-diff-filter/test2-v1.cc: Likewise.
* tests/data/test-diff-filter/test2-v1.o: Likewise.
* tests/data/test-diff-filter/test4-v0.cc: Likewise.
* tests/data/test-diff-filter/test4-v0.o: Likewise.
* tests/data/test-diff-filter/test4-v1.cc: Likewise.
* tests/data/test-diff-filter/test4-v1.o: Likewise.
* tests/data/test-diff-filter/test9-v0.o: Likewise.
* tests/data/test-diff-filter/test9-v1.cc: Likewise.
* tests/data/test-diff-filter/test9-v1.o: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-dwarf-reader.h (symbol_type, symbol_binding): New
enums.
(operator<<): Declare new overloads for the new enums above.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Declare new entry points.
* src/abg-dwarf-reader.cc (lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Define new static
functions.
(read_context::elf_{module_, handle}_): New data members.
(read_context::{elf_module, elf_handle}): New accessors.
(read_context::load_debug_info): Store the elf module into
read_context::_elf_module_. Adjust.
(read_context::{lookup_symbol_from_elf,
lookup_public_function_symbol_from_elf,
lookup_public_variable_symbol_from_elf}): New member functions.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf)
(operator<<): Define public entry points.
* tools/bisym.cc: New tool to lookup a symbol in an elf file.
* tools/Makefile.am: Add the bisym.cc source file to the
distribution and arrange to compile it into a 'bisym' executable.
* tests/test-lookup-syms.cc: New test harness.
* tests/data/test-lookup-syms/test0-report.txt: New test input
for the harness above.
* tests/data/test-lookup-syms/test0.cc: Likewise.
* tests/data/test-lookup-syms/test0.o: Likewise
* tests/data/test-lookup-syms/test01-report.txt: Likewise.
* tests/data/test-lookup-syms/test02-report.txt: Likewise.
* tests/Makefile.am: Build the new runtestlookupsyms test and add
the new files to the distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h (class_diff::{deleted, inserted,
changed}_bases): Declare new member functions ...
* src/abg-comparison.cc ((class_diff::{deleted, inserted,
changed}_bases)): ... and define them.
* src/abg-comp-filter.cc (base_classes_added_or_removed): Define
new static functions.
(harmless_filter): Categorize base classes added or removed.
* tests/data/test-diff-dwarf/test8-report.txt: New test input.
* tests/data/test-diff-dwarf/test8-v0.cc: Likewise.
* tests/data/test-diff-dwarf/test8-v0.o: Likewise.
* tests/data/test-diff-dwarf/test8-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test8-v1.o: Likewise.
* tests/data/test-diff-filter/test13-report.txt: New test input.
* tests/data/test-diff-filter/test13-v0.cc: Likewise.
* tests/data/test-diff-filter/test13-v0.o: Likewise.
* tests/data/test-diff-filter/test13-v1.cc: Likewise.
* tests/data/test-diff-filter/test13-v1.o: Likewise.
* tests/Makefile.am: Add the new files above to the source distribution.
* tests/test-diff-dwarf.cc: Use the new relevant input above to
run more tests.
* tests/test-diff-filter.cc: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h
(diff_category::STATIC_DATA_MEMBER_CHANGE_CATEGORY): New category.
(diff_category::EVERYTHING_CATEGORY): Update
* src/abg-comp-filter.cc (static_data_member_type_size_changed)
(static_data_member_added_or_removed): Define new static
functions.
(harmless_filter::visit): Categorize changes to static data
members as STATIC_DATA_MEMBER_CHANGE_CATEGORY.
* tools/bidiff.cc (set_diff_context_from_opts):
STATIC_DATA_MEMBER_CHANGE_CATEGORY is falls into the harmless
group.
* tests/data/test-diff-filter/test12-report.txt: New test input.
* tests/data/test-diff-filter/test12-v0.cc: Likewise.
* tests/data/test-diff-filter/test12-v0.o: Likewise.
* tests/data/test-diff-filter/test12-v1.cc: Likewise.
* tests/data/test-diff-filter/test12-v1.o: Likewise.
* tools/bidiff.cc: Run this test with the additional input data
above.
* tests/Makefile.am: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Let's
consider that a data member being not laid out (i.e, not having a
data_member_location) is is a static data member. Otherwise, we
were not detecting static data members at all. Well we were only
inferring their presence from seeing the static variable
definition later on. That means we were missing most of the
static variables. Woops.
* src/abg-comparison.cc
(corpus_diff::priv::ensure_lookup_tables_populated): Now that we
are really seeing static data members, let's be prepare to the
fact that we can the same static data member being declared
several times in a corpus.
* tests/data/test-diff-dwarf/test7-report.txt: New test input file.
* tests/data/test-diff-dwarf/test7-v0.cc: Likewise.
* tests/data/test-diff-dwarf/test7-v0.o: Likewise.
* tests/data/test-diff-dwarf/test7-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test7-v1.o: Likewise.
* tests/test-diff-dwarf.cc: Update this to consume the new test
input files.
* tests/Makefile.am: Update this to add the missing test files to
the source distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Use the virtual
member functions here, not the member functions in general.
(compute_diff): Consider virtual member functions only, not
non-virtual ones.
* src/abg-ir.cc (class_decl::operator==): Do not compare
non-virtual member functions. Only compare virtual member
functions.
* tests/data/test-bidiff/test-struct1-report.txt: New test input.
* tests/data/test-diff-dwarf/test0-report.txt: New test input.
* tests/data/test-diff-filter/test0-report.txt: New test input.
* tests/data/test-diff-filter/test01-report.txt: New test input.
* tests/data/test-diff-filter/test10-report.txt: New test input.
* tests/data/test-diff-filter/test11-report.txt: New test input.
* tests/data/test-diff-filter/test2-report.txt: New test input.
* tests/data/test-diff-filter/test9-report.txt: New test input.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-fwd.h (member_function_is_virtual): Declare new
function.
* include/abg-comparison.h
(diff_category::{NON_VIRT_MEM_FUN_CHANGE_CATEGORY,
VIRTUAL_MEMBER_CHANGE_CATEGORY}): New enumerators.
(diff_category::EVERYTHING_CATEGORY): Adjust.
(class_diff::{changed, deleted, inserted}_member_fns): Declare new
member functions.
* src/abg-comp-filter.cc (data_member_added_or_removed): Add
missing comments.
(has_non_virtual_mem_fn_change): New static predicate function.
(harmless_filter::visit): Categorize non-virtual member function
changes in a diff into NON_VIRT_MEM_FUN_CHANGE_CATEGORY.
* src/abg-comparison.cc
(TRAVERSE_MEM_FN_DIFF_NODE_AND_PROPAGATE_CATEGORY): New macro.
(report_mem_header): Count filtered functions for added/deleted
functions as well.
(class_diff::priv::count_filtered_changed_mem_fns): Renamed
priv::count_filtered_member_functions into this. Filter out
changes to non-virtual member functions here.
(class_diff::priv::count_filtered_{inserted, deleted}_mem_fns):
New member functions.
(class_diff::{deleted, inserted, changed}_member_fns): Define new
member functions.
(class_diff::report): Adjust count for filtered inserted/deleted
member functions. Do not report NON_VIRT_MEM_FUN_CHANGE_CATEGORY
if it's disallowed.
(class_diff::traverse): Propagate only
VIRTUAL_MEMBER_CHANGE_CATEGORY from member functions to their
enclosing class.
* src/abg-ir.cc (member_function_is_virtual): Define new
functions.
* tools/bidiff.cc (set_diff_context_from_opts): Adjust to add
NON_VIRT_MEM_FUN_CHANGE_CATEGORY into the harmless group and
VIRTUAL_MEMBER_CHANGE_CATEGORY into the harmful one.
* tests/data/test-diff-filter/test0-report.txt: New test input.
* tests/data/test-diff-filter/test10-report.txt: Likewise.
* tests/data/test-diff-filter/test10-v0.cc: Likewise.
* tests/data/test-diff-filter/test10-v0.o: Likewise.
* tests/data/test-diff-filter/test10-v1.cc: Likewise.
* tests/data/test-diff-filter/test10-v1.o: Likewise.
* tests/data/test-diff-filter/test11-report.txt: Likewise.
* tests/data/test-diff-filter/test11-v0.cc: Likewise.
* tests/data/test-diff-filter/test11-v0.o: Likewise.
* tests/data/test-diff-filter/test11-v1.cc: Likewise.
* tests/data/test-diff-filter/test11-v1.o: Likewise.
* tests/data/test-diff-filter/test2-report.txt: Likewise.
* tests/data/test-diff-filter/test9-report.txt: Likewise.
* tests/data/test-diff-filter/test9-v0.cc: Likewise.
* tests/data/test-diff-filter/test9-v0.o: Likewise.
* tests/data/test-diff-filter/test9-v1.cc: Likewise.
* tests/data/test-diff-filter/test9-v1.o: Likewise.
* tests/test-diff-filter.cc: Consume the test input above to run
more tests.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (class_decl::{priv}): New private data member.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, get_earlier_declaration,
add_base_specifier, get_base_specifiers, get_member_types,
get_data_members, get_member_functions,
get_member_function_templates, get_member_class_templates}): Move
these methods out-of-line.
(class_decl::{comparison_started_,
declaration_,is_declaration_only_, definition_of_declaration,
is_struct_, bases_, member_types_, data_members_,
member_functions_, member_function_template,
member_class_templates_}): Move these data members into the pimpl
in ...
* src/abg-ir.cc
(class_decl::priv::{declaration_,is_declaration_only_,
definition_of_declaration, is_struct_, bases_, member_types_,
data_members_, member_functions_, member_function_template,
member_class_templates_}): ... here.
(class_decl::priv::classes_being_compared_): New data member.
(class_decl::priv::priv): Initialize the data members.
(class_decl::priv::{mark_as_being_compared,
unmark_as_being_compared, comparison_started): New methods.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, add_base_specifier,
get_base_specifiers, get_member_types, get_data_members,
get_member_functions, get_member_function_templates,
get_member_class_templates}): Move these out-of-line in here.
(class_decl::{class_decl, set_definition_of_declaration,
set_earlier_declaration, insert_member_type, add_member_type,
add_data_member, add_member_function,
add_member_function_template, add_member_class_template,
has_no_base_nor_member}): Adjust.
(class_decl::operator==): Harden inf-loop prevention during class
comparison using the new priv::mark/unmark_as_being_compared()
functions. Now comparison of a class really compares member
functions again. And it is *slooow*. I should probably change
this to compare only virtual member functions. But at least this
should be correct and robust for now.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* test01-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-fwd.h (get_data_member_offset): Declare new overload for
decl_base_sptr.
* include/abg-comparison.h (unsigned_decl_base_sptr_map)
(unsigned_changed_type_or_decl_map): New typedefs.
* src/abg-ir.cc (get_data_member_offset): Define new overload for decl_base_sptr.
* src/abg-comparison.cc (diff_kind::subtype_change_kind): New
enumerator for a change about a type or sub-type of a member of a
structure/enum.
(report_mem_header): Handle the new enumerator above.
(class_diff::priv::{deleted_dm_by_offset_, inserted_dm_by_offset_,
changed_dm_}): New data members.
(class_diff::priv::subtype_changed_dm_): Renamed
class_diff::priv::changed_data_members_ into this.
(class_diff::priv::subtype_changed_dm): Renamed
class_diff::priv::data_member_has_changed into this. Adjust.
(class_diff::count_filtered_subtype_changed_dm): Renamed
count_filtered_data_members into this. Adjust.
(class_diff::priv::count_filtered_changed_dm): New member
function.
(class_diff::lookup_tables_empty): Adjust.
(class_diff::ensure_lookup_tables_populated): Adjust. Detect when
a data member is deleted and added back to offset N, and be
prepared to present that as a change of data member at offset N.
(class_diff::report): Adjust. Report data members of a given
offset that have changed.
* tests/data/test-diff-dwarf/test6-report.txt: New reference
report for new test input.
* tests/data/test-diff-dwarf/test6-v0.cc: Source code for new test
input binary.
* tests/data/test-diff-dwarf/test6-v0.o: New test input binary.
* tests/data/test-diff-dwarf/test6-v1.cc: Source code for new test
input binary.
* tests/data/test-diff-dwarf/test6-v1.o: New test input binary.
* tests/test-diff-dwarf.cc: Adjust to include the new test inputs above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h (enum
diff_category::DECL_NAME_CHANGE_CATEGORY): New enumerator.
* src/abg-comparison.cc (report_name_size_and_alignment_changes)
({enum, typedef}_diff::report): Adjust to avoid emitting name
change report if the DECL_NAME_CHANGE_CATEGORY category of change
is currently disallowed.
* abg-comp-filter.cc (decl_name_changed): New static function.
(harmless_filter::visit): Detect that the decl name changed and
put the current diff node (and its parents) into the
DECL_NAME_CHANGE_CATEGORY category.
* tools/bidiff.cc (set_diff_context_from_opts): Set the new
DECL_NAME_CHANGE_CATEGORY category into the harmless_changes group
of categories.
* tests/data/test-diff-filter/test6-report.txt: New test input file.
* tests/data/test-diff-filter/test6-v0.cc: Likewise.
* tests/data/test-diff-filter/test6-v0.o: Likewise.
* tests/data/test-diff-filter/test6-v1.cc: Likewise.
* tests/data/test-diff-filter/test6-v1.o: Likewise.
* tests/data/test-diff-filter/test7-report.txt: Likewise.
* tests/data/test-diff-filter/test7-v0.cc: Likewise.
* tests/data/test-diff-filter/test7-v0.o: Likewise.
* tests/data/test-diff-filter/test7-v1.cc: Likewise.
* tests/data/test-diff-filter/test7-v1.o: Likewise.
* tests/test-diff-filter.cc: Take the new inputs above to run new tests.
* tests/Makefile.am: Add the new files above to the distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-ir.cc (compare_function_types): Compare return types,
unless this is a method and the return type is the same type as
the containing class type.
* tests/data/test-diff-dwarf/test5-report.txt: Reference report
for the comparison of the two input binaries below.
* tests/data/test-diff-dwarf/test5-v0.cc: Source code for the
input binary below.
* tests/data/test-diff-dwarf/test5-v0.o: Test input binary.
* tests/data/test-diff-dwarf/test5-v1.cc: Source code for the
input binary below.
* tests/data/test-diff-dwarf/test5-v1.o: Test input binary.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tests/data/test-diff-dwarf/test4-report.txt: Adjust.
* tests/test-diff-dwarf.cc: Run tests for
data/test-diff-dwarf/test3-report.txt" and
data/test-diff-dwarf/test4-report.txt.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (report_size_and_alignment_changes): Split
this static function out of ...
(report_name_size_and_alignment_changes): ... this one.
(distinct_diff::report): If the typedef-stripped variants of the
diff subjects are of the same kind, display their diff.
Otherwise, tell explicitly is the distinct type diff involves a
type size change.
(distinct_diff::traverse): If the typedef-stripped variants of the
diff subjects are of the same kind, traverse that underlying diff
sub-tree and propagate the categorizing possibly resulting from
that traversal.
* tests/data/test-diff-dwarf/test4-v0.o: New test input binary.
* tests/data/test-diff-dwarf/test4-v0.cc: Source code for the
input binary above.
* tests/data/test-diff-dwarf/test4-v1.o: New test input binary.
* tests/data/test-diff-dwarf/test4-v1.cc: Source code for the
input binary above.
* tests/data/test-diff-dwarf/test4-report.txt: Reference report
for the difference between the two binaries above.
* tests/data/test-diff-filter/test5-v0.o: New test input binary.
* tests/data/test-diff-filter/test5-v0.cc: Source code for the
input binary above.
* tests/data/test-diff-filter/test5-v1.o: New test input binary.
* tests/data/test-diff-filter/test5-v1.cc: Source code for the
input binary above.
* tests/data/test-diff-filter/test5-report.txt: Reference report
for the difference between the two binaries above.
* tests/test-diff-filter.cc: Adjust to produce a filtered diff for
the two input binaries above.
* tests/Makefile.am: Adjust to add missing test files to the
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
A given diff node for a type can be hung off of several contexts: a
function parameter type node, another type diff node, etc. For that
reason, a type diff node should not have a parent node. Thus, it's
should be the job of the context containing the type diff node to
propagate its categories to the context nodes. This actually fixes a bug
about category propagation.
* abg/comparison.cc (var_diff::var_diff): Do not set parent node
for the type diff of the var_diff.
(var_diff::traverse): Handle category propagation from the
type diff node to the var_diff node.
(pointer_diff::underlying_type_diff)
(reference_diff::underlying_type_diff)
(qualified_type_diff::underlying_type_diff, enum_diff::enum_diff)
(base_diff::get_underlying_class_diff)
(typedef_diff::underlying_type_diff): Do not set the parent node
here.
({pointer_diff, reference_diff, qualified_type, enum_diff,
class_diff, base_diff, function_decl_diff,
typedef_diff}::traverse): Handle category propagation here.
* tests/data/test-diff-filter/test4-v0.o: New input binary.
* tests/data/test-diff-filter/test4-v0.cc: Source code for the
input binary above.
* tests/data/test-diff-filter/test4-v1.o: New input binary.
* tests/data/test-diff-filter/test4-v1.cc: Source code for the
input binary above.
* tests/data/test-diff-filter/test4-report.txt: Reference diff
report for the input binaries above.
* tests/test-diff-filter.cc:: Run bidiff --no-harmless on the
binaries above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc
(function_decl_diff::ensure_lookup_tables_populated): Function
parameters that are diff'ed start at the first non-implicit
parameter, not at the first parameter. Oops.
* tests/data/test-diff-dwarf/test3-v0.o: New test input binary.
* tests/data/test-diff-dwarf/test3-v0.cc: Source code for the
binary above.
* tests/data/test-diff-dwarf/test3-v1.o: New test input binary.
* tests/data/test-diff-dwarf/test3-v1.cc: Source code for the
binary above.
* tests/data/test-diff-dwarf/test3-report.txt: Reference report
for the diff of the new test inputs.
* tests/test-diff-dwarf.cc: Use the test inputs above to run new
tests.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc
(function_decl_diff::ensure_lookup_tables_populated): A parm
change is valid only when the added parm has a different name from
the removed parm. Both have the same index, of course. In that
case, do not try to remove the corresponding parm sub-type change.
* tests/data/test-bidiff/test-enum0-report.txt: Adjust.
* tests/data/test-bidiff/test-enum1-report.txt: Adjust.
* tests/data/test-bidiff/test-qual-type0-report.txt: Adjust.
* tests/data/test-bidiff/test-struct0-report.txt: Adjust.
* tests/data/test-diff-dwarf/test0-report.txt: Adjust.
* tests/data/test-diff-dwarf/test1-report.txt: Adjust.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* tests/data/test-diff-filter/test01-report.txt: Adjust.
* tests/data/test-diff-filter/test1-report.txt: Adjust.
* tests/data/test-diff-filter/test2-report.txt: Adjust.
* tests/data/test-diff-filter/test3-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h
(diff_category::COMPATIBLE_TYPE_CHANGE_CATEGORY): New enumerator.
(operator|=(diff_category&, diff_category)): New declaration.
* include/abg-fwd.h (is_typedef, strip_typedef)
(types_are_compatible): New declarations.
* include/abg-ir.h (operator==(const decl_base_sptr, const
decl_base_sptr)): Added the consts here.
(operator==(const type_base_sptr, const type_base_sptr)): New
declaration.
* src/abg-comp-filter.cc (is_compatible_change): New static
function.
(harmless_filter::visit): Detect compatible changes and add the
sub-tree into the new COMPATIBLE_TYPE_CHANGE_CATEGORY if
applicable. Cleanup the logic.
* src/abg-comparison.cc (operator|=(diff_category&,
diff_category)): Define new function.
(operator==(const decl_base_sptr l, const decl_base_sptr r)): Add
consts.
(operator==(const type_base_sptr l, const type_base_sptr r)):
Define new operator.
(is_typedef, strip_typedef, types_are_compatible): New function
definitions.
* tests/data/test-diff-filter/test3-report.txt: New test report
reference.
* tests/data/test-diff-filter/test3-v0.cc: Source code for new
test input.
* tests/data/test-diff-filter/test3-v0.o: New test input.
* tests/data/test-diff-filter/test3-v1.cc: Source code for new
test input.
* tests/data/test-diff-filter/test3-v1.o: New test input.
* tests/test-diff-filter.cc: Adjust to consume the new tests
inputs above.
* tools/bidiff.cc: Add the new COMPATIBLE_TYPE_CHANGE_CATEGORY
into the --harmless group.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (represent): For var_decl, do not emit
filtered-out local size/offset/access changes.
(report_name_size_and_alignment_changes): Take the diff context.
Do not report filtered-out local size/offset changes.
({var_diff, enum_diff, class_diff, type_decl_diff}::report):
Adjust.
* test0-report.txt: Adjust.
* test01-report.txt: New reference report for the same inputs
test0-v{1,0}.o, but called without the --no-harmless command line.
* tests/data/test-diff-filter/test2-v0.cc: Source code for new test input.
* tests/data/test-diff-filter/test2-v1.cc: Likewise.
* tests/data/test-diff-filter/test2-v0.o: New test input.
* tests/data/test-diff-filter/test2-v1.o: Likewise.
* tests/data/test-diff-filter/test2-report.txt: Reference report
for new test input.
* tests/test-diff-filter.cc: Consume the test inputs above.
* tests/Makefile.am: Add the new test inputs above to the
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h (unsigned_changed_parm_map)
(unsigned_parm_map): New typedefs.
* src/abg-comparison.cc
(function_decl_diff::subtype_changed_parms): Renamed this from
changed_parms.
(function_decl_diff::priv::subtype_changed_parms_}): Renamed this
from changed_parms_;
(function_decl_diff::priv::{deleted_parms_by_id_,
added_parms_by_id_, changed_parms_by_id_}): New members.
(function_decl_diff::ensure_lookup_tables_populated): Update the
new priv::changed_parms_by_id_ member to contain the parameters
that got changed, as opposed to the subtype_changed_parms_ member
that contain parameters that got a sub-type change. The other
priv::*_by_id_ members are helpers for this. Update them too.
(function_decl_diff::subtype_changed_parms): Renamed this from
::changed_parms.
(function_decl_diff::report): Report separately about parameters
having a sub-type change, and parameters that got changed. Note
that in both cases, the change is necessarily to a compatible
type.
* data/test-diff-dwarf/test2-v0.cc: New test file.
* data/test-diff-dwarf/test2-v0.o: Likewise.
* data/test-diff-dwarf/test2-v1.cc: Likewise.
* data/test-diff-dwarf/test2-v1.o: Likewise.
* data/test-diff-dwarf/test2-report.txt: Likewise.
* tests/Makefile.am: Add the new test files above to the
distribution.
* tests/test-diff-dwarf.cc: Consume the input files above to
actually perform a regression test.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (class_diff::traverse): Fix thinking in
introduced by commit "6709478 Fix infinite loop when traversing
classes and their members"
* tests/data/test-diff-filter/test1-v{0,1}.o: New test binary input files.
* tests/data/test-diff-filter/test1-v{0,1}.cc: Source code for the
above.
* tests/data/test-diff-filter/test1-report.txt: Reference report
for the diffing of the two binary input files above.
* tests/test-diff-filter.cc: Make the test run on the new input above.
* tests/Makefile.am: Add the new material to the distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h
(diff_category::ACCESS_CHANGE_CATEGORY): Renamed
ACCESS_CHANGED_CATEGORY into this.
(diff_category::SIZE_OR_OFFSET_CHANGE_CATEGORY): Renamed
SIZE_CHANGED_CATEGORY into this. Changed its semantics to
incorporate offset changes as well.
* src/abg-comparison.cc (struct noop_deleter): Move this up.
(represent): Do not report filtered out data members.
(report_mem_header): Add a new num_filtered parameter to take
filtered-out members in account in members report headers.
Adjust.
(class_diff::priv::{count_filtered_bases,
count_filtered_data_members, count_filtered_member_functions}):
New member functions. When a member is filtered, do not report
it all.
({enum_diff, class_diff}::report): Adjust. Take filtered members
into account in headers.
(corpus_diff::priv::apply_filters_and_compute_diff_stats): New
member function.
(corpus_diff::priv::emit_diff_stats): Renamed
emit_corpus_diff_stats into this. Change it to take the stats in
parameter.
(corpus_diff::report): Adjust to re-use the above. Filter
varibles as well. Take the filtered functions & variables in
account in the stats. Do not report filtered-out functions &
variables at all.
* src/abg-comp-filter.cc (type_size_changed, access_changed)
(data_member_offset_changed): New predicates.
({harmless, harmful}_filter::visit): Adjust to use the new
predicates above. Update the harmful variant for the new
SIZE_OR_OFFSET_CHANGE_CATEGORY category.
* tools/bidiff.cc (set_diff_context_from_opts): Adjust for the
categories name changes.
* tests/data/test-diff-filter/test0-report.txt: New test input.
* tests/data/test-diff-filter/test0-v0.cc: Likewise.
* tests/data/test-diff-filter/test0-v0.o: Likewise.
* tests/data/test-diff-filter/test0-v1.cc: Likewise.
* tests/data/test-diff-filter/test0-v1.o: Likewise.
* tests/test-diff-filter.cc: New test harness.
* tests/Makefile.am: Add the new test files above to the
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (represent): For member var_decls, add a
missing apostrophe after the access.
* tests/data/test-diff-dwarf/test0-report.txt: Update test report.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tests/test-diff-dwarf.cc: New dwarf diffing regression test
harness.
* tests/data/test-diff-dwarf/test0-report.txt: New test input.
* tests/data/test-diff-dwarf/test0-v0.cc: Likewise.
* tests/data/test-diff-dwarf/test0-v0.o: Likewise.
* tests/data/test-diff-dwarf/test0-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test0-v1.o: Likewise.
* tests/Makefile.am: Add the new test inputs from
tests/test-diff-dwarf.cc and tests/data/test-diff-dwarf/* to
the build system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tests/test-ir-walker.cc: Renamed test-walker.cc into this.
* tests/Makefile.am: Adjust. The generated binary is now testirwalker.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-traverse.h (traversable_base::traversable): Change
the signature of this to return a boolean.
* include/abg-ir.h (ir_traversable_base::traverse): Change the
signature of this to return a boolean.
(*::traverse): Adjust.
(ir_node_visitor::visit): Change the signature of this to return a
boolean.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Adjust.
* src/abg-ir.cc (::traverse): Adjust.
* tests/test-walker.cc (name_printing_visitor::visit): Adjust.
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>
* include/abg-fwd.h (has_scope): Delete the overloads for
type_base.
(get_member_is_static): Add an overload for decl_base*.
({is,get,set}_data_member,{get_,set}_data_member_is_laid_out)
({get,set}_data_member_offset): New access declarations.
* include/abg-ir.h (class context_rel): Move up.
(decl_base::set_context_rel): New definition.
(class dm_context_rel): New type.
(decl_base::hash_as_member): Remove.
(var_decl::set_scope): Declare new virtual member.
(class_decl::data_member): Remove.
(ir_node_visitor::visit): Remove the overload for
class_decl::data_member.
(represent_data_member): Remove the represent overload for
class_decl::data_member into this. Make it take a var_decl.
(represent): Change the overload that takes two
class_decl::data_member take two var_decl. And adjust it.
(class_diff::report): Adjust.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Remove the
overload that takes a class_decl::data_member*. Adjust the
overload that takes a var_decl to recognize (static) data members.
* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_ir_node_from_die):
Adjust.
* src/abg-hash.cc (var_decl:#️⃣:operator()): Adjust.
(class_decl::data_member:#️⃣:operator()): Remove.
(decl_base:#️⃣:operator()): Take the context relationship in
account here.
(decl_base::hash_as_member::operator()): Remove.
({enum_type_decl,typedef_decl}:#️⃣:operator()): Adjust.
(class_decl::member_function:#️⃣:operator()): Adjust.
(type_base::dynamic_hash::operator()): Adjust.
* src/abg-ir.cc (dm_context_rel::~dm_context_rel): New definition.
(has_scope): Remove overload for type_base.
(get_member_is_static): New overload for decl_base*.
(is_data_member): New function definition.
({get,set}_data_member_{offset,is_laid_out}): Define new
accessors.
(var_decl::set_scope): Define new member function. Make this set
a dm_context_rel as the context relationship.
(var_decl::operator==): Adjust to take in account the new data
member relationship.
(class_decl::class_decl): Adjust.
(class_decl::insert_member_decl): Adjust.
(class_decl::add_data_member): Remove the overload for
class_decl::data_member.
(class_decl::add_data_member): Adjust the overload for var_decl.
(operator==): Remove overload for class_decl::data_member*.
(class_decl::data_member::operator==): Likewise.
(ir_node_visitor::visit): Remove overload for
class_decl::data_member.
* src/abg-writer.cc (write_layout_offset, write_class_decl):
Adjust.
* tests/data/test-read-write/test20.xml: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h (class base_diff): New.
* include/abg-ir.h (function_decl::get_first_non_implicit_parm):
New member function.
(function_type::get_first_non_implicit_parm): Likewise.
* src/abg-comparison.cc (base_has_changed): Change parm to take
class_decl::base_spec_sptr.
(class_diff::ensure_lookup_tables_populated): Compare the base
specs not just the base classes.
(class_diff::report): Adjust. Report sub-type changes in the
member functions.
(base_diff::*): Define member functions.
(compute_diff): Define an overload for base_diff_sptr.
* src/abg-hash.cc ({function_type,
method_type}:#️⃣:operator()): Do not hash the implicit parm of
member functions.
(class_decl:#️⃣:operator()): Do not hash member types.
* src/abg-ir.cc (decl_base::decl_base): Initialize the
hashing_started_ member that got moved here from class_decl.
(decl_base::get_hash): Do not set the hash if it's being set b/c
we are in a class_decl.
(decl_base::operator==) Do not compare hashes for now. Two decls
can have different hashes and compare equal; think about an
incomplete type foo, that compares equal with a complete foo.
Their hashes will be different though. So for now, just avoid
comparing these.
(compare_function_types): Avoid comparing the implicit parameter
for member functions.
({function, method}_type::get_first_non_implicit_parm): New
definition.
* tests/data/test-read-write/test20.xml: Update.
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-comparison.h (compute_diff): For class_decl_sptr, do not
compare member types and member class templates. This adds a lots
of noise that is not necessarily useful for now.
* tests/data/test-bidiff/test-qual-type0-report.txt: Update tests.
* tests/data/test-bidiff/test-struct0-report.txt: Likewise.
* tests/data/test-bidiff/test-struct1-report.txt: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
accordingly
* include/abg-comparison.h (class diff_context): New class.
(class diff::{ctxt_, reported_once_, currently_reporting_}): New
data members.
(diff::diff): Initialize the new data members above.
(diff::{context, currently_reporting, reported_once}): New
accessors.
(compute_diff, var_diff::var_diff, pointer_diff::pointer_diff)
(reference_diff::reference_diff, qualified_type_diff)
(enum_diff:enum_diff, class_diff::class_diff)
(scope_diff::scope_diff, function_decl_diff::function_decl_diff)
(type_decl_diff::type_decl_diff, typedef_diff::typedef_diff)
(translation_unit_diff::translation_unit_diff, corpus_diff::corpus_diff):
Take an additional pointer to diff_context.
* abg-comparison.cc (diff_context::{has_diff_for,
has_diff_for_types, add_diff}): New methods.
(try_to_diff, compute_diff_for_types, compute_diff_for_decls)
(represent): Take an additional pointer to
diff_context in argument. In the later function, do not re-report
a diff if it has already been reported, or if it's being reported
already.
(var_diff::var_diff, pointer_diff::pointer_diff)
(reference_diff::reference_diff)
(qualified_type_diff::qualified_type_diff, enum_diff::enum_diff)
(class_diff::class_diff, scope_diff::scope_diff)
(function_decl_diff::function_decl_diff, type_decl::type_decl)
(typedef_diff::typedef_diff)
(translation_unit_diff::translation_unit_diff)
(corpus_diff::corpus_diff): Take an additional pointer to
diff_context in argument.
({pointer_diff, qualified_type_diff,
reference_type_diff}::report): do not re-report a diff about the
underlying type if it has already been reported, or if it's being
reported already.
(enum_diff::report): Fix this to properly use the populated lookup
tables.
(compute_diff): take an additional pointer to diff_context in
argument. For the var_decl, pointer_diff reference_type_diff,
qualified_type_diff enum_diff, scope_diff, function_decl_diff,
type_decl_diff and typedef_diff overloads, do not re-build a diff
object, if one exits already. Otherwise, record the new diff
object created so that it can be re-used later.
(enum_diff::ensure_lookup_tables_populated): Fix logic to avoid
one loop.
(class_decl::priv::{deleted_member_functions_,
inserted_member_functions_, changed_member_function_}): New
members to support reporting about member functions changes.
(class_decl::{lookup_tables_empty, clear_lookup_tables, length):
Update for the new additions above.
(class_decl::ensure_lookup_tables_populated): Likewise. Fix to
properly use the lookup tables and also avoid a going through
several loops to compute the changed members.
(class_decl::report): Flip a switch to make the beginning and end
of the reporting, in the context. Also, do not try to report
again, if we were already reporting this diff. Fix quite some
spots to properly use the lookup tables.
(scope_diff::ensure_lookup_tables_populated): Skip decl-only
classes during comparison. Fix some thinkos. Fix logic to avoid a
loop.
(scope_diff::report): Adjust to pass a context to
compute_diff_for_types.
(function_decl_diff::ensure_lookup_tables_populated): Fix logic to
avoid a loop.
(function_decl_diff::report): Adjust call to
compute_diff_for_types to pass the context.
(typedef::report): Avoid re-reporting the diff of the underlying
types, if we are already reporting it.
(corpus_diff::priv::ensure_lookup_tables_populated): Use the
pretty representation of the function rather than its name to key
the maps of deleted and added functions. Fix logic to avoid going
through an additional loop for the changed functions.
(corpus_diff::report): Add a title for removed/added/changed
functions. Fix indentation for added/removed/changed functions.
* include/abg-ir.h (class_decl::comparison_started_): New member
* src/abg-dwarf-reader.cc (is_public_decl): Style fix.
(is_declaration_only_): New static function.
(build_class_type_and_add_to_ir): Create decl-only classes (IR) for
classes flagged as declaration-only in the DWARF.
* src/abg-hash.cc (class_decl:#️⃣:operator()): Do not forget to
include the "is_declaration_only" flag into the hashing.
* src/abg-ir.cc (class_decl::operator==): Look through decl-only
classes to get their definitions and compare the definitions
instead. Avoid comparing member types and fns if the comparison
of this type has already started.
* src/abg-reader.cc (build_class_decl): Set the definition of a
declaration, when we see it.
* tests/data/test-bidiff/test-qual-type0-report.txt: Update.
* tests/data/test-bidiff/test-struct0-report.txt: Likewise.
* tests/data/test-bidiff/test-struct1-report.txt: Likewise.
signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-diff-utils.h (end_of_frr_d_path_in_k_plus_delta):
Favour moving left when the two abscissas at the previous steps
are equal.
(compute_diff): Update the length of the shortest edit script when
the size of one of the inputs is zero.
* tests/test-core-diff.cc (in_out_spec): Add a new input to diff
two sequences for regression testing.
* tests/data/test-core-diff/report13.txt: New reference for
the comparison of the new regression test above.
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>
* include/abg-reader.h (read_corpus_from_native_xml)
(read_corpus_from_native_xml_file): Declare new entry points.
* include/abg-writer.h (write_corpus_to_native_xml)
(write_corpus_to_native_xml_file): Likewise.
* src/abg-reader.cc (read_translation_unit_from_input): Renamed
read_input into this. Support new 'path' attribute for
'abi-instr' XML element.
(read_corpus_from_input): New static function.
(read_translation_unit_from_file)
(read_translation_unit_from_buffer)
(read_translation_unit_from_istream): Update wrt read_input ->
read_translation_unit_from_input.
(read_corpus_from_native_xml, read_corpus_from_native_xml)
(read_corpus_from_native_xml_file): Define new entry points.
* src/abg-writer.cc (write_translation_unit): Write 'path'
attribute into the 'abi-instr' xml element.
(write_corpus_to_native_xml, write_corpus_to_native_xml_file):
Define new entry points.
* tools/abg-tools-utils.h (file_type::{FILE_TYPE_XML_CORPUS,
FILE_TYPE_ZIP_CORPUS}): New enumerators.
* tools/abg-tools-utils.cc (guess_file_type): Support detection of
the new xml file format containing a document root 'abi-corpus'
root element.
* tools/bidiff.cc (main): Support diffing xml corpus-es and zip
corpus-es.
* tools/bidw.cc (main): Recognize elf files before reading them.
* tools/bilint.cc (main): Support reading xml/zip corpus-es too.
* tests/data/test-read-write/test[0-23].xml: Update 'path'
attribute.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (ir_traversable_base): New type to be the base
of IR nodes that are to be traversed. Extends traversable_base.
Its ir_traversable_base::traversable() method takes an
ir_node_visitor&.
(ir_node_visitor::visit): Change these virtual overloads to take
pointers to IR nodes, rather than references. This will be useful
to e.g, store these IR nodes in containers on the side for some
algorithms to work. That is going to be useful later to,
e.g. build symbol tables on the side, using the visitor interface.
(class decl_base): Make this inherit ir_traversable_base.
* src/abg-ir.cc (*::traverse): Adjust comments and the call the
ir_node_visitor::visit call. Use the ir_traversable_base type
rather than traversable_base.
(ir_traversable_base::traverse): Define.
(ir_node_visitor::visit): Change these overloads to take pointers
rather than reference to ir nodes.
* tests/test-walker.cc (name_printing_visitor::visit): Adjust to
take pointers rather than references.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (translation_unit::translation_unit): Take an
address_size parameter.
(translation_unit::{get_address_size, set_address_size}): New
accessors.
* src/abg-ir.cc (translation_unit::priv::address_size_): New
private member.
(translation_unit::translation_unit): Take an address_size
parameter.
(translation_unit::{get_address_size, set_address_size}): Define
these new methods.
* src/abg-reader.cc (read_input): Read the "address-size"
attribute from the abi-instr element.
* src/abg-writer.cc (write_translation_unit): Write the
"address-size" attribute.
* tests/data/test-read-write/test23.xml: New test input.
* tests/test-read-write.cc (in_out_specs): Add the new test above
to the list of files to read and write back.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-reader.cc (build_function_parameter): Support reading
the "is-variadic" attribute.
* src/abg-writer.cc (write_function_decl): Support writing the
"is-variadic" attribute.
* tests/data/test-read-write/test22.xml: New test input.
* tests/test-read-write.cc (in_out_specs): Add the new test to the
list of files to read and write back.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-reader.h: New file with abigail::xml_reader APIs.
* include/abg-writer.h: New file with abigail::xml_writer APIs.
* include/Makefile.am: Add the new files above to the source
distribution.
* src/abg-reader.cc: Update top-file comments.
(namespace xml_reader): Rename namespace
reader into this.
(read_to_translation_unit, read_corpus_from_archive): New static
functions.
(read_translation_unit_from_file)
(read_translation_unit_from_file, read_corpus_from_file): New
entry points.
(struct array_deleter): New functor.
(translation_unit::read): Remove this.
* src/abg-writer.cc: Update top file comments.
(namespace xml_writer): Rename namespace
writer into this.
(struct archive_write_ctxt): New internal type.
(create_archive_write_context, write_translation_unit_to_archive)
(write_translation_unit, write_corpus_to_archive): New low level
static functions overloads.
(write_corpus_to_archive, write_translation_unit): Public higher
level overloads.
(translation_unit::write): Remove.
(dump): Update for new xml_writer namespace.
* include/abg-ir.h (translation_unit::{read, write}): Remove these
serialization methods.
* include/abg-corpus.h (corpus_sptr): New convenience typedef.
(corpus::{read, write}): Remove these methods.
* src/abg-corpus.cc (corpus::{read, write})
(corpus::impl::{serialized_tus, archive}): Remove these members.
(corpus::impl::{get_archive, close_archive, write_tu_to_archive,
read_to_translation_unit}): Remove these methods.
* tests/test-bidiff.cc (main): Update for usage of the new
xml_reader API.
* tests/test-read-write.cc (main): Likewise. Update for the usage
of the new xml_writer API, too.
* tests/test-walker.cc (main): Update for the usage of the new
xml_reader API.
* tests/test-write-read-archive.cc (main): Likewise. And for the
xml_writer API, too.
* tools/biar.cc (add_tus_to_archive, extract_tus_from_archive): Likewise.
* tools/bidiff.cc (main): Likewise, for xml_reader APIs.
* tools/bilint.cc (main): Likewise, for xml_writer APIs, too.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tests/Makefile.am (data/test-read-write/test{17, 18, 19, 20,
21}.xml): Add these test input files to the source distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-fwd.h (get_type_declaration): Declare function.
* include/abg-ir.h (class decl_base): Add class_decl as a friend.
This to be able to call decl_base::set_scope from class_decl.
(scope_decl::add_member_decl): Make this virtual protected, so
that it can be called (virtually) from e.g, class_decl.
(type_decl_sptr, typedef_decl_sptr): New convenience typedefs.
(class_decl::add_member_decl): New virtual overload for
scope_decl::add_member_decl.
(class_decl::{add_member_type, add_data_member,
add_member_function}): New overloads.
* src/abg-ir.cc (add_decl_to_scope): Benign style cleanup.
(get_type_declaration): Define new function.
(class_decl::add_member_decl): New method.
(class_decl::add_member_type): Avoid silently added a new member
type when that member type has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there. Also add a new overload that constructs
the member type out of a classic type and adds it to the class.
(class_decl::{add_data_member, add_member_function}): Likewise.
(class_decl::{add_member_function_template,
add_member_class_template}): Avoid silently added a new member
template when that template has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there.
* src/abg-reader.cc (push_decl_to_current_scope): Take a an extra
flag saying if the current decl should be added to the current
scope as well (in addition to being pushed onto the stack of
scopes maintained in the reader context).
(push_and_key_type_decl): Likewise, take that extra flag and pass
it to push_decl_to_current_scope.
(build_function_decl, build_var_decl, build_type_decl)
(build_qualified_type_decl, build_pointer_type_def)
(build_reference_type_def, build_enum_type_decl, build_typedef_decl)
(build_function_tdecl, build_class_tdecl): Likewise.
(build_class_decl): Likewise. When building member data, types,
and functions, make sure /not/ to add the data, type of function to
the current scope before adding it to the class_decl. This was
making the member not being added to the class because it already
had a scope.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_type): Adjust to add the template parm to the current scope
explicitly, like previously.
(handle_type_decl): Use build_type_decl function. Add the
type_decl to the current scope, like previously.
(handle_namespace_decl, handle_qualified_type_decl)
(handle_pointer_type_def, handle_reference_type_def)
(handle_enum_type_decl, handle_typedef_decl, handle_var_decl)
(handle_function_decl, handle_class_decl, handle_function_tdecl)
(handle_class_tdecl): Adjust to add the decl to the current scope,
like previously.
* tests/data/test-read-write/test21.xml: New test input with
member type(def).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-diff-utils.h (point::set): New overload..
(point::{add, operator<, operator>, operator<=, operator>=}): New
methods.
(point::operator!=): Constify.
(point::operator==): Constify. Cleanup.
(point::operator=): Keep emptiness.
(class snake): New class definition
(d_path_vec::{over_bounds, offset}): New methods.
(d_path_vec::check_index_against_bound): Don't take a bound
parameter anymore. Use the new over_bound method above. Fix up
error reporting.
(d_path_vec::d_path_vec): Fix d_path_vec size allocation.
(d_path_vec::operator[]): Use the d_path_vec::at method to check
all accesses against the bounds. This is slower, but at least we
can expect to have something that is more robust. We can remove
the bound checking later when we are sure the code has been tested
enough. Also use the new offset() method.
(d_path_vec::at): Take long long.
(ends_of_furthest_d_paths_overlap): Constify input parameters.
(end_of_fr_d_path_in_k, end_of_frr_d_path_in_k_plus_delta): Take
an instance of the new snake in parameter, rather than a bare end
point that wasn't carrying enough information about the snake.
Record the snake which consists of up to four points: a begin
point, an intermediate point, a diagonal start point and an end
point. Return that snake upon successful completion.
(compute_middle_snake): Take an instance of snake, rather than the
two points that were supposed to represent a snake and with which
we were loosing information before. Revisit/simplify the logic of
this function; this literally goes forward or in reverse, gets the
resulting snake returned by the end_of_fr_d_path_in_k and
end_of_frr_d_path_in_k_plus_delta functions, detect if these snakes
overlap and just return the current snake. Much simpler. The
caller now gets a snake, which has much more information than the
previous snake approximation made of just two points. Bonus
point, this follows almost to the word, what the paper says.
(maybe_record_match_point, find_snake_start_point): Remove these
as there are not used by compute_middle_snake anymore.
(print_snake, ses_len): Update these to take/handle a snake.
(snake_end_points): New declaration.
(compute_diff): When we are getting an empty first sequence, this
means that we are inserting the second sequence *before* the
beginning of the first sequence; keep this information by setting
the insertion point index to -1, rather than zero. Update this to
get/handle snakes, rather than free points vaguely representing
snakes. Now that compute_middle_snake returns real snakes, handle
the information we are getting. Basically for edit scripts of
length equal to 1, as the snake carries all the necessary
information about the non-diagonal edge (as well as the diagonal
edges), we (can) now precisely update the current edit script (as
well as the longest common sub-sequence). For edit scripts of
length greater than 1, better at which points to divide the
problem and consequently, at which points to conquer it back --
better following The Paper to the letter.
(display_edit_script): Update this for the use of instances of
snake.
* src/abg-diff-utils.cc (ends_of_furthest_d_paths_overlap): Update
for constification of inputs.
(snake_end_points): Define new function.
(compute_middle_snake): Adapt for the taking an instance of snake.
* tests/test-diff2.cc (main): Update for using instances of snake.
* tests/test-core-diff.cc: Add new tests.
* tests/data/test-core-diff/report0.txt: Update for output
adaptation.
* tests/data/test-core-diff/report6.txt: Likewise.
* tests/data/test-core-diff/report7.txt: Likewise.
* tests/data/test-core-diff/report8.txt: New test data.
* tests/data/test-core-diff/report9.txt: Likewise.
* tests/data/test-core-diff/report10.txt: Likewise.
* tests/data/test-core-diff/report11.txt: Likewise.
* tests/data/test-core-diff/report12.txt: Likewise.
* tests/data/test-core-diff/report3.txt: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (type_shared_ptr_equal::operator()): Fix thinko
in checking for the boolean value of the pointers to types.
* src/abg-ir.cc (type_decl::operator==(const decl_base&)): Do not
forget to compare the decl_base part of the type too.
(type_decl::operator==(const type_base&)): To ease maintenance,
re-use the equality operator that takes a decl_base.
(scope_type_decl::operator==(const type_base&)): Likewise.
(qualified_type_def::operator==(const type_base&)): Likewise.
(compare_function_types): New sub-routine to compare function
types. It fixes an infinite recursion when comparing two methods
of the same class.
(function_type::operator==(const type_base&)): Use the new
compare_function_types function.
(class_decl::operator==(const decl_base&)): Fix a thinko in the
first test of the function. Use a dedicated scope for each class
section comparison; that way, there won't be any chance to misuse
the variables pertaining to a different section. Fix the member
function sections; we were mistakenly using the variables for the
*data* section there.
(class_decl::operator==(const type_base&)): Re-use the operator
that takes a decl_base.
(class_decl::operator==(const class_decl&)): Don't remove
const-ness during the static cast.
(class_decl::member_function::operator==(const member_function&)):
Do not remove the reference from the static cast.
(class_decl::member_class_template::operator==(const
member_base&)): Likewise.
(type_tparameter::operator==(const template_parameter&)):
Likewise.
(template_tparameter::operator==(const template_parameter&)):
Likewise.
(function_tdecl::operator==(const template_decl&)): Likewise.
(class_tdecl::operator==(const template_decl&)): Likewise.
(class_tdecl::operator==(const class_tdecl&)): Likewise.
* tests/data/test-read-write/test12.xml: Update this because the
test now correctly considers two type template parameters at the
same index as being equivalent.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-diff-utils.h (compute_middle_snake): After the
overlap determination happened, finding the middle snake can
require keep on building the current path until the "end". The
end meaning reaching the max of D. And that max is (M + N)/2 + 1.
In the extreme cases were middle snake was on the very last step
(M + N) + 1, we were not finding the middle snake. Fix this.
(compute_diff): When d == 1 and the first edge on the edit graph
is a non-diagonal edge and when a_base != a_begin, we were failing
to properly initialize x,y to find that non-diagonal edge. Also
we were failing to correctly compute the size of the sequence.
Fix these.
* tests/test-core-diff.cc: Add a new regression test for the two
cases above.
* tests/data/test-core-diff/report7.txt: New reference data for
the new regression test.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-diff-utils.h (point::{operator!=,operator==}): New
operators.
(end_of_fr_d_path_in_k, end_of_frr_d_path_in_k_plus_delta): Allow
the initial point (-1,-1) that is not a point addressing elements
of the input sequences, but that is the starting point of the
forward paths and the ending point of reverse paths in the "Linear
Refinement" of the algorithm.
(is_match_point, maybe_record_match_point)
(find_snake_start_point): New functions.
(find_last_snake_in_path): Remove this. It's not used anymore.
(compute_middle_snake): Allow checking for overlapping paths even
on points that are outside of the edit graph boundaries. Once the
overlap is detected, if a non-empty snake has been seen already,
report it as the middle snake. Otherwise, keep building the path
until the end and report the last snake encountered as the middle
snake. Add comments.
(compute_diff): For the d == 1 case, fix the logic of the finding
the non-diagonal edge. Fix typos. Add comments.
(display_edit_script): Fix report glitches.
* tests/data/test-core-diff/report3.txt: Update as per the report
glitch above.
* tests/data/test-core-diff/report4.txt: Likewise.
* tests/data/test-core-diff/report5.txt: Likewise.
* tests/data/test-core-diff/report6.txt: New reference report for
a new test.
* tests/test-core-diff.cc: Add a new test for negative delta.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tests/test-diff2.cc: New command line testing facility.
* tests/Makefile.am: Add this to the build system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tests/test-utils.h (is_dir, ensure_dir_path_created)
(ensure_parent_dir_created): Move these directories manipulation
utilities from here to ...
* tools/abg-tools-utils.h (is_dir, ensure_dir_path_created)
(ensure_parent_dir_created): ... here in this new file.
(dir_name, base_name): Declare these new functions.
* tests/test-utils.cc (is_dir, ensure_dir_path_created)
(ensure_parent_dir_created): Likewise, move these to ...
* tools/abg-tools-utils.cc (is_dir, ensure_dir_path_created)
(ensure_parent_dir_created): ... here in this new file.
(dir_name, base_name): Define these.
* tools/Makefile.am: New file. Create a new libtoolsutils.la
static library with stuff from tools/abg-tools-utils.cc in it.
Also create a new 'biar' program with the stuff from the new
tools/biar.cc in it.
* tools/biar.cc: New file. Contains the code for the new "biar"
archive manipulation command line utility.
* tests/test-read-write.cc (main): Adjust for the change about
ensure_parent_dir_created above.
* tests/test-write-read-archive.cc (main): Likewise.
* Makefile.am (SUBDIRS): Add the new tools/ sub-directory to the
build system.
* configure.ac (AC_CONFIG_FILES): Generate tools/Makefile.
* tests/Makefile.am: Make libtestutils.la link with the new
libtoolsutils.la. Make sure to express the dependencies between
libtestutils.la and the binaries that depend on it. Otherwise
parallel builds can go awry.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-corpus.h (corpus::{get_path, set_path): Renamed
corpus::get_file_path and corpus::set_file_path into these as
get_path/set_path is what is used elsewhere as well.
* src/abg-corpus.cc (corpus::{get_path, set_path}): Likewise.
* tests/test-write-read-archive.cc (main): Adjust for the change
above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* configure.ac: Support detection of libzip dependency. Define
new DEPS_CFLAGS and DEPS_LIBS variables for use in
Makefile.am to refer to the dependency headers and
libraries.
* doc/website/mainpage.txt: Update this to talk about the new
libzip dependency.
* include/Makefile.am: Add abg-libzip-utils.h to the build system.
* include/abg-corpus.h (corps): Hide abigail::corpus's private behind a
pimpl idiom.
(corpus::{drop_translation_units, get_file_path, set_file_path,
write, read}): New methods.
* include/abg-libxml-utils.h (new_reader_from_buffer): Declare new
function.
* include/abg-libzip-utils.h: New file.
* src/Makefile.am: Add abg-corpus.cc and abg-libzip-utils.cc to
the build system. Refer to the library and headers dependencies
via the new DEPS_LIBS and DEPS_CFLAGS variables.
* src/abg-corpus.cc: New file.
* src/abg-ir.cc (translation::set_path): New method.
* src/abg-libxml-utils.cc (new_reader_from_buffer): Define new
function.
* src/abg-libzip-utils.cc: New file.
* src/abg-reader.cc (translation_unit::read): New overload.
* src/abg-writer.cc: Inject the names from the std namespace into
the abigail namespace, rather than into abigail::writer.
(abigail::translation_unit::write): New overload. This can now
use ofstream and the other stuff from std that are injected in the
abigail:: namespace.
* tests/Makefile.am: Add tests/test-write-read-archive.cc to the
build system; use that to build runtestwritereadarchive. Also add
the input test data from
tests/data/test-write-read-archive/test[0-4].xml.
* /tests/data/test-write-read-archive/test[0-4].xml: New test
input data files.
* tests/test-write-read-archive.cc: New test for this archive
write/read support.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/Makefile.am: Pass absolute file paths to the compiler during
the build. This helps in e.g in emacs' compilation mode, when the
output shows an error reported by GCC's diagnostics, setting point
to the error line and hitting 'enter' transports the user to the
file location where the error happened; as the file path is nows
absolute, emacs can always find it. Otherwise, finding it depends
on $PWD and whatnot.
* tests/Makefile.am: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* Makefile.in: Remove this autotools-generated file. I know that
people in the GCC-realm like storing these autotools-generated
files into the source control system, but I believe in this day
and age, this is annoying (to say the least) for the project
developers for no good reason. Requiring (the ubiquitous)
autoconf for building from source is no big deal today, and typing
"autoreconf" is not hard to do, really. And it saves the
developers for having to update a bunch of boilerplate
automatically generated files into the source control system; this
is really unnecessary noise and it is a commonly accepted good
practice to avoid doing it these days. To help people who do not
know how to handle this, there is a COMPILING file in the source
tree that explains how to build the project from sources.
* aclocal.m4: Likewise.
* configure: Likewise.
* include/Makefile.in: Likewise.
* src/Makefile.in: Likewise.
* doc/Makefile.in: Likewise.
* tests/Makefile.in: Likewise.
* include/libabigail/abg-ir.h (struct ir_node_visitor, struct
traversable): New interfaces.
(translation_unit, scope_decl, type_decl, qualified_type_def)
(pointer_type_def, reference_type_def, enum_type_decl)
(typedef_decl, var_decl, function_decl, data_member)
(member_function, member_function_template)
(member_class_template): Implement the traversable interface,
overload the traversable::traverse pure virtual function.
* src/abg-ir.cc ({translation_unit, scope_decl, type_decl,
namespace_decl, qualified_type_def, pointer_type_def,
reference_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, class_decl::member_function, class_decl,
class_decl::data_member, class_decl::member_function_template,
class_decl::member_class_template, function_template_decl,
class_template_decl, }::traverse): Implement traversal.
(ir_node_visitor::visit): New method, overloaded for the types
above, which implement the traversable interface.
* tests/test-walker.cc: New test case program to showcase how to
use the new traversal API.
* tests/makefile.am: Add test-walker.cc to the build system.
* include/libabigail: New directory.
* include/Makefile.am: New file.
* include/libabigail/Makefile.am: New file.
* src/abg-*.h: Move these in include/libabigail/*.h
* src/Makefile.am: Set -I option to look for headers in include/libabigail
* doc/api/libabigail.doxy: Look for headers in include/libabigail
* tests/Makefile.am: Set -I option to look for headers in include/libabigail
* abigail.m4: Set includedir to $prefix/include/libabigail for
library used as a dep, or to srcdir/libabigail/include/libabigail
in GCC source tree.
* configure.ac: Add Makefile.am in include and include/libabigail
* abigail.m4: Look for headers in include/libabigail when the
libabigail is in in the source tree and in $incdir/libabigail when
it is installed as a dependency.
* src/abg-ir.h (class_decl::base_spec::base_spec): Take an offset
and a is_virtual flag.
(class_decl::base_spec::{get_is_virtual, get_offset_in_bits}): New
methods.
(class_decl::has_no_base_nor_member): New method declaration..
* src/abg-ir.cc (class_decl::base_spec::base_spec): Take an offset
and a is_virtual flag
(class_decl::has_no_base_nor_member): Define it.
* src/abg-reader.cc (read_offset_in_bits): Renamed
read_var_offset_in_bits into this.
(read_is_virtual): New static function.
(build_class_decl): Read the 'layout-offset-in-bits' and the
'is-virtual' of the base class specifier. Adjust for the
read_var_offset_in_bits -> read_offset_in_bits rename.
* src/abg-writer.cc (write_layout_offset): New overload for the
base class specifiers.
(write_class_decl): If the class has no member or base class, make
it a proper empty xml element. Write the offset and the
is-virtual attribute.
* tests/data/test-read-write/test20.xml: New test input data.
* tests/test-read-write.cc: De-serialize the test above, serialize
it back and compare that both versions are the same.
* src/abg-ir.h (class_decl::base_spec::base_spec): Move this
out-of-line. Add a new constructor for clients compiled without
RTTI.
* src/abg-ir.cc (class_decl::base_spec::base_spec): This is now
here out-of-line. Define the new constructor for clients compiled
without RTTI.
* tests/data/test-read-write/test19.xml: New test case input for
base classes.
* tests/test-read-write.cc: De-serialize and serialize the new
test case input above.
* abg-ir.h (class_decl::set_earlier_declaration): Move this
out-of-line and add an overload.
* src/abg-ir.cc (class_decl::set_earlier_declaration): Moved this
out-of-line here and add an overload.
* src/abg-reader.cc (build_class_decl): Really read the
'decl-of-decl-id' property. Do not make the definition use the id
of the declaration. Both have their id.
* src/abg-writer.cc (write_class_decl): Put a space before the
property "def-of-decl-id".
* tests/data/test-read-write/test18.xml: New test input.
* tests/test-read-write.cc: De-serialize this new input, serialize
it back and make sure both versions are identical.
* src/abg-ir.h (function_decl::parameter::parameter): New
constructor with variadic parameter marker.
(function_decl::m_type): Make this protected to let method_decl
inheriting class to access it.
(function_decl::get_type): Move this out-of-line.
(class method_type, method_type_hash): New types.
(enum class_decl::access_specifier): Add no_access new enumerator.
(class_decl::data_member::data_member): Move this out-of-line.
(class_decl::data_member::~data_member): Declare virtual
destructor.
(class method_decl): New class.
(class member_function): Make this inherit method_decl, instead of
function_decl.
(class_decl::class_decl): New constructors.
(class_decl::{hashing_started, is_declaration_only,
set_earlier_declaration, get_earlier_declaration}): New methods.
* src/abg-ir.cc (add_decl_to_scope): If a decl is already in a
scope, don't add it to this scope.
(get_global_scope): Make this work when passed an instance of
global_scope.
(dynamic_type_hash::operator()): Add support for method_type.
(method_type::{method_type, set_class_type, ~method_type, })
(method_type_hash::operator()): New defintions.
(function_decl::get_type, class_decl::class_decl): Move these
out-of-line here.
(class_decl::method_decl::{method_decl, ~method_decl, get_type}):
New definitions.
(class_decl::member_function::member_function): Move this
out-of-line here. Support method_decl.
(class_decl::data_member::data_member): Likewise.
(class_decl_hash::operator()): Guard this against endless loop.
* src/abg-reader.cc (write_class_is_declaration_only): New static
function.
(write_var_decl): Take a flag to write the mangled name or not.
(write_function_decl): Take a flag to skip the first parameter.
(write_cdtor_const_static): Use 'yes' instead of 'true' as value
of the properties.
(write_decl, write_function_template_decl): Adjust wrt the new
signatures of write_var_decl and write_function_decl.
(write_enum_type_decl): Simplify call to write_location.
(write_class_decl): Support serializing declaration-only classes.
* src/abg-writer.cc:
* tests/data/test-read-write/test17.xml: New test input.
* tests/test-read-write.cc: De-serialize the above, and serialize it back.
* tests/data/test-read-write/test10.xml: Update this test.
* src/abg-ir.h (class function_type): Forward decl prior to class
function_decl.
(function_decl::parameter): Pass string by const reference. Add a
variadic marker member and initialize it.
(function_decl::parameter::get_type): Add a non-const overload.
(function_decl::parameter::get_variadic_marker): New getter.
(function_decl::function_decl) Take a const reference to a vector
for parameters, type size/alignment. Add two overloads that takes a
pointer to function_type.
(function_decl::get_parameters): Move this out-of-line.
(function_decl::append_parameter(s)): Renamed
function_decl::add_parameter(s) into these. Move it out-of-line.
Add an overload.
(function_decl::{get_type, set_type}): New declaration.
(function_decl::get_return_type): Move this out-of-line.
(function_decl::is_variadic): New in-line function.
(function_decl::m_type): New data member.
(function_decl::{m_parms, m_return_type}): Remove. This are now
carried by function_decl::m_type.
(class function_type, struct function_type_hash): New
declarations.
(member_function::member_function): Take a vector of pointers to
parameters. Take size/align of the type of the member function.
Adjust initialization.
* src/abg-ir.cc (dynamic_type_hash): Hash instance of
function_type accessed through a pointer.
(function_type::{operator==, ~function_type})
(function_type_hash::operaror(), function_decl::{get_return_type,
}, function_decl::parameter:#️⃣:operator()): New definitions.
(function_decl::function_decl): The out-of-line definitions of the
declarations above.
(function_decl::append_parameter): Moved this out-of-line from
inline function_decl::add_parameter. Make this rely on the
underlying m_type.
(function_decl::operator==): Adjust for use of vector for the
parameters. Also, there is no need anymore to compare the
parameters or the return types as they are compared by the
comparison of the function types.
* src/abg-reader.cc (build_function_decl): Read the new size/alignment
attributes on the function-decl element. Build a function_type
and use it to build the function_decl. Parameters and return type
are now hung off of the function_type.
(handle_function_decl): use build_function_decl.
* src/abg-writer.cc (write_function_decl): Write the new
size/alignment properties of the function-decl element. Adjust
for the use of vectors for function parameters now.
* tests/data/test-read-write/test10.xml: Adjust for the presence
of size/alignment properties in the function-decl element now.
* tests/data/test-read-write/test11.xml: Likewise.
* tests/data/test-read-write/test12.xml: Likewise.
* tests/data/test-read-write/test13.xml: Likewise.
* tests/data/test-read-write/test14.xml: Likewise.
* tests/data/test-read-write/test9.xml: Likewise.
* configure.ac: Define the components of the version number as
autoconf variables. Set the version number to 0.1.0
* abigail.m4: New file
* Makefile.am: Add abigail.m4 to the build system. Install it in
$(datadir)/aclocal.
* src/Makefile.am: Generate and add abg-version.h from the version
number autoconf variable defined in configure.ac. Re-generate
abg-version.h each time configure.ac changes.
* src/abg-config.h (abigail_get_library_version): Declare ...
* src/abg-config.cc (abigail_get_library_version): ... and define
this wirth C linkage. This is useful for autoconf tests to test
for the presence of the library.
* configure: Re-generate.
* Makefile.in: Likewise.
* src/Makefile.in: Likewise.
* tests/Makefile.in: Likewise.
* Makefile.am: Support the doc sub-directory. We don't have a
COPYRIGHT file.
* src/Makefile.am: Don't prefix the file paths by the absolute
path of the src dir; current autotools know how to deal with it,
otherwise and it break them.
* tests/Makefile.am: Likewise. Make sure to remove the output of
the tests upon make clean.
* Makefile.in: Re-generate.
* aclocal.m4: Likewise.
* configure: Likewise.
* src/Makefile.in: Likewise.
* tests/Makefile.in: Likewise.
* src/abg-ir.cc (class_decl::add_member_function_template): Fix
comment.
(class_decl::add_member_class_template)
(class_decl::member_class_template::operator==)
(class_decl::member_class_template_hash::operator()): New
definitions.
(class_decl::operator==): Compare member templates. Fix logic.
(class_decl::data_member_hash::operator())
(class_decl::member_function_hash::operator())
(class_decl::member_function_template_hash::operator()): Don't
hash the is_static boolean as it's hashed as part of the 'member'
sub-object hashing.
(class_decl::member_function_template::operator==): Move this out
of line here, from the header file.
(class_decl_hash::operator()): Hash member class templates.
* src/abg-ir.h (class_decl::member::{m_is_static,is_static}): Add the is_static
boolean here, so that it's factorized out of the inherited classes
of this class.
(class_decl::data_member::{is_static, m_is_static})
(class_decl::member_function::{is_static, m_is_static})
(class_decl::member_function_template::{is_static, m_is_static}): Remove this
as it's now part of the base 'member' class.
(class_decl::data_member::operator==)
(class_decl::member_function::operator==): Don't compare the
is_static boolean as it's now compared as part of the 'member'
sub-object comparison.
(class_decl::member_function_template::operator==): Move this
out-of-line into src/abg-ir.cc.
(class class_decl::member_class_template, struct
class_decl::member_class_template_hash)
(class_decl::{add_member_class_template,
get_member_class_templates}): New declarations.
(class_decl::member_class_templates_type): New typedef.
* src/abg-reader.cc (build_class_decl): Support de-serializing
member class templates.
* src/abg-writer.cc (write_class_decl): Likewise, support
serializing member class templates.
* tests/data/test-read-write/test16.xml: New test input.
* tests/test-read-write.cc (int_out_specs[]): Add the new test
input to the list of inputs that are de-serialized and serialized
back.
* tests/Makefile.am: Add the new test input to the distribution.
* src/abg-ir.cc (class_template_decl::class_template_decl)
(class_template_decl::set_pattern)
(class_template_decl::operator==)
(class_template_decl::~class_template_decl)
(class_template_decl_hash::operator())
(class_tmpl_shared_ptr_hash::operator()): New definitions.
* src/abg-ir.h (class class_template_decl, struct
class_tmpl_shared_ptr_hash, struct class_tmpl_shared_ptr_hash):
New declarations.
* src/abg-reader.cc (read_context::const_class_tmpl_map_it): New
typedef.
(read_context::get_fn_tmpl_decl): Fix comment.
(read_context::{get_class_tmpl_decl,key_class_tmpl_decl})
(build_class_template_decl, handle_class_template_decl): New
definitions.
(read_context::m_class_tmpl_map): New member.
(handle_element): Support "class-template-decl" xml elements
nodes.
(build_class_decl): Add missing bits to comment.
(build_function_template_decl): Fix spacing.
* src/abg-writer.cc (class_tmpl_shared_ptr_map): New typedef.
(write_context::m_class_tmpl_map): New member.
(write_context::get_id_for_class_tmpl, write_class_template_decl):
New definitions.
(write_template_parameters): Factorize this this out from ...
(write_function_template_decl): ... here.
(write_decl): Support writing instances of class_template_decl.
Fix spacing.
* tests/data/test-read-write/test15.xml: New test input.
* tests/Makefile.am: Add the new test15.xml input to the
distribution.
* tests/test-read-write.cc (in_out_specs): Add the new test15.xml
test to the list of serialized output to be de-serialized and
serialized back.
* src:abg-ir.h: Move template declarations before class
class_decl, so that class_decl can have member templates.
(class class_decl::member_function_template)
(class_decl::add_member_function_template)
(class_decl::{base_specs_type, member_types_type,
data_members_types, member_functions_type,
member_function_templates_type}): New declarations.
* src/abg-ir.cc (class_decl::add_member_function_template)
(class_decl::member_function_template_hash::operator()): New
definitions.
(class_decl_hash::operator()): Support hashing for member
function templates.
* src/abg-reader.cc (build_class_decl): Use the new
class_decl::{member_types_type, data_members_type,
member_functions_type, base_specs_type} types. Support member
function templates.
* src/abg-writer.cc (write_cdtor_const_static): New definition.
(write_class_decl): Support member function templates.
* tests/data/test-read-write/test14.xml: New input data.
* tests/Makefile.am: Add it to the distribution.
* tests/test-read-write.cc (InOutSpec int_out_specs): De-serialize
the new test input file, serialize it back and diff both results.
* src/abg-ir.h (class tmpl_parm_type_composition): New
declaration.
* src/abg-ir.cc
(tmpl_parm_type_composition::tmpl_parm_type_composition)
(tmpl_parm_type_composition::~tmpl_parm_type_composition): New
definitions.
* src/abg-reader.cc (build_tmpl_parm_type_composition): New
function.
(build_template_parameter): Support template parameter type
composition.
* src/abg-writer.cc (write_tmpl_parm_type_composition): New
function.
(write_template_non_type_parameter): Fix type-id attribute.
(write_template_parameter): Support template parameter type
composition.
* tests/data/test-read-write/test13.xml: New test input.
* tests/Makefile.am: Add it to the distribution.
* tests/test-read-write.cc (InOutSpec in_out_spec): Add test13.xml
to the list of xml file that are de-serialized and serialized back.
* src/abg-ir.cc (decl_base_hash::operator()): Don't hash the
context for decls in general.
* src/abg-reader.cc (read_context::push_decl_to_current_scope)
(read_context::push_and_key_type_decl): Add an overload that takes
a node and update_depth_info boolean.
(build_var_decl, build_type_decl, build_qualified_type_decl)
(build_pointer_type_def, build_reference_type_def)
(build_enum_type_decl, build_type_decl)
(build_template_type_parameter, build_template_non_type_parameter)
(build_template_template_parameter, build_template_parameter)
(build_type): Make these functions take an update_depth_info
parameter. Pass it do read_context::push_and_key_type_decl or
read_context::push_decl_to_current_scope rather than call
update_read_context.
(build_function_decl, build_class_decl)
(build_function_template_decl): Change the seen_by_reader
parameter into update_depth_info. Pass the update_depth_info bool
to read_context::push_decl_to_current_scope rather than call
update_depth_info here.
(handle_class, handle_function_template_decl): Adjust.
* tests/data/test-read-write/test12.xml: Add new test input.
* tests/test-read-write.cc (InOutSpec in_out_specs): Add it to the
list of input to de-serialize, serialize back and compare the two.
* tests/Makefile.am: Add the new test input to the distribution.
* src/abg-ir.h (function_decl::set_return_type): New inline
definition.
(class template_decl, struct template_decl_hash, class
template_parameter, struct template_parameter_hash, struct
dynamic_template_parameter_hash, struct
template_parameter_shared_ptr_hash, class template_type_parameter)
(struct template_type_parameter_hash, class
template_non_type_parameter, struct
template_non_type_parameter_hash, class
template_template_parameter, struct
template_template_parameter_hash, class function_template_decl)
(struct function_template_decl_hash, struct
fn_tmpl_shared_ptr_hash): New declarations.
* src/abg-ir.cc (dynamic_type_hash::operator()): Add hashing for
template template, and template type parameters.
(template_decl_hash::operator, template_decl::~template_decl)
(template_decl::operator==, template_parameter::operator==)
(template_parameter_hash::operator())
(dynamic_template_parameter_hash::operator())
(template_type_parameter::operator==)
(template_type_parameter::~template_type_parameter)
(template_type_parameter_hash::operator())
(template_non_type_parameter::operator==)
(template_non_type_parameter::~template_non_type_parameter)
(template_non_type_parameter_hash::operator())
(template_template_parameter::operator==)
(template_template_parameter::~template_template_parameter)
(template_template_parameter_hash::operator())
(function_template_decl::operator==)
(function_template_decl_hash::operator())
(fn_tmpl_shared_ptr_hash::operator())
(function_template_decl::~function_template_decl()): New
definitions.
* src/abg-reader.cc (read_context::get_fn_tmpl_decl)
(read_context::key_fn_tmpl_decl): New functions.
(read_context::m_fn_tmpl_map): New data member.
(read_context::key_type_decl): Renamed read_context::add_type_decl
into this.
(read_context::push_decl_to_current_scope): Renamed
read_context::finish_decl_creation into this. Add an assert.
(read_context::push_and_key_type_decl): Renamed
read_context::finish_type_decl_creation into this. Adjust to the
use of push_decl_to_current_scope and key_type_decl.
(build_function_template_decl, build_template_type_parameter)
(build_template_non_type_parameter)
(build_template_template_parameter, build_template_parameter)
(handle_function_template_decl): New functions.
(handle_element): Call handle_function_template_decl.
(build_function_decl): Take a bool parameter to update depth
information in parsing context. Move instantiation of
function_decl before parsing its xml sub-nodes. Update the depth
info in the parsing context if necessary. Push the newly
intantiated decl to scope. And then parse the sub nodes. Do not
forget to add the fn parameters and return type using
function_decl::add_parameter and function_decl::set_return_type.
(build_var_decl, build_type_decl, build_qualified_type_decl)
(build_pointer_type_def, build_reference_type_def)
(build_enum_type_decl, build_typedef_decl, handled_type_decl)
(handle_qualified_type_decl, handle_pointer_type_def)
(handle_reference_type_def, handle_enum_type_decl)
(handle_typedef_decl, handle_var_decl, handle_function_decl)
(handle_class_decl): Adjust.
(build_class_decl): Take a bool parameter to update depth
information in parsing context. Add comment. Wait for the class
members to be built, before keying (and thus hashing it) the
class.
(build_type): Fix logic, and adjust.
* src/abg-writer.cc (write_context::type_has_existing_id)
(write_context::get_id_for_fn_tmpl, write_template_type_parameter)
(write_template_non_type_parameter)
(write_template_template_parameter, write_template_parameter)
(write_function_template_decl): New functions.
(write_context::get_id_for_type): Simplify logic.
(write_decl): Support writing function template.
* tests/data/test-read-write/test11.xml: New test input.
* tests/test-read-write.cc (InoutSpec in_out_specs[]):
De-serialize the new test11.xml test, serialize it back and diff
output and input.
* tests/Makefile.am: Add test11.xml to the distribution.
* src/abg-ir.h (scope_decl::scope_decl)
(scope_type_decl::scope_type_decl): Don't set mangled name for
scope_decl instances as it doesn't make sense.
(var_decl::var_decl): Pass the type shared pointer by value.
(struct var_decl_hash, function_decl::parameter::operator==)
(struct function_decl::parameter_hash, function_decl::operator==)
(struct function_decl_hash, class class_decl, struct
class_decl_hash): New declarations.
* src/abg-ir.cc (scope_type_decl::scope_type_decl): Don't set the
mangled name. It doesn't make sense for scope_decls.
(dynamic_type_hash::operator): Fix comment. Run the hashing for
scope_type_decl instances *after* running it for class_decl
instance, otherwise, the class_decl instances case will never get
hit.
(var_decl::var_decl): Pass the type shared pointer by value.
(function_decl::operator==, class_decl::operator==)
(class_decl_hash::operator()): New fns.
* src/abg-libxml-utils.h (get_xml_node_depth): Declare new fn.
(XML_READER_GET_ATTRIBUTE): Fix comment.
(XML_NODE_GET_ATTRIBUTE): New getter macro.
* src/abg-libxml-utils.cc (get_xml_node_depth): New definition.
* src/abg-reader.cc (update_read_context)
(update_depth_info_of_read_context, read_visibility, read_binding)
(read_access, read_size_and_alignment, read_static)
(read_var_offset_in_bits, read_cdtor_const, build_function_decl)
( build_var_decl, build_type_decl, build_qualified_type_decl)
(build_pointer_type_def, build_reference_type_def)
(build_enum_type_decl, build_typedef_decl, build_class_decl)
(build_type, handle_class_decl): New functions or overloads.
(handle_element): Update to handle "class-decl" xml elements.
* src/abg-writer.cc (write_size_and_alignment, write_access)
(write_class, do_indent_to_level, get_indent_to_level): New fns.
(write_decl): Update to serialize instances of class_decl.
(write_type_decl, write_pointer_type_def)
(write_reference_type_def): Use the new write_size_and_alignment instead of
writing the attributes directly.
* tests/data/test-read-write/test10.xml: New test file.
* tests/Makefile.am: Add tests/data/test-read-write/test10.xml to
the build system.
* tests/test-read-write.cc (in_out_spec): De-serialize
data/test-read-write/test10.xml, serialize it back into
output/test-read-write/test10.xml, and compare the two output that
should be identical.
* src/abg-reader.cc (handle_enum_type_decl): The name of the
element holding the underlying type is now "underlying-type", no
more "base".
* src/abg-writer.cc (write_enum_type_decl): Likewise.
* tests/data/test-read-write/test6.xml: Likewise.
* src/abg-ir.h (class function_decl): New declaration & inline
definitions.
* src/abg-ir.cc (function_decl::~function_decl): New definition.
* src/abg-reader.cc (read_location): New overload to read location
from an xmlNodePtr.
(build_function_parameter, handle_function_decl):
New definitions.
(handle_element): Support "function-decl" elements.
* src/abg-writer.cc (write_location): New overload to write a
location directly, not from a decl.
(write_function_decl): New definition.
(write_binding): Support writing the binding attribute from a
function_decl instance.
(write_decl): support serializing function
* tests/data/test-read-write/test9.xml: New test input file.
* tests/Makefile.am: Add data/test-read-write/test9.xml to the
build system.
* tests/test-read-write.cc: De-serialize
data/test-read-write/test9.xml, serialize it back and diff the
output from the input.
* abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove.
(abi_corpus::add): New function to add a translation unit.
(abi_corpus::get_translation_units): New declaration.
* abg-corpus.cc (abi_corpus::*): Remove all the definitions of
abi_corpus for now, as the abi_corpus type is not used anymore --
for now at least.
* src/abg-ir.h (add_decl_to_scope, get_global_scope)
(get_translation_unit, is_global_scope, is_decl_at_global_scope)
(class translation_unit, class global_scope): New declarations
* src/abg-ir.cc (translation_unit::translation_unit)
(translation_unit::get_global_scope)
(translation_unit::get_loc_mgr, translation_unit::get_loc_mgr)
(translation_unit::is_empty, get_global_scope)
(get_translation_unit, is_global_scope, is_global_scope)
(is_decl_at_global_scope, global_scope::~global_scope): New
definitions.
(scope_decl::scope_decl, scope_decl::scope_decl)
(scope_decl::add_member_decl, scope_decl::get_member_decls): Move
to abg-ir.h, inline.
* src/abg-reader.h (read_file): Don't use abi_corpus in the api.
Rather, use translation_unit.
* src/abg-reader.cc (read_context::get_cur_scope): Now that we
have a specific instance of global_scope to represent global
scope, don't play games with empty scopes to detect a global
scope.
(read_context::get_translation_unit): New definition.
(read_context::finish_decl_creation, finish_type_decl_creation):
(read_input, read_file, read_location, handle_element)
(handle_type_decl)
(handle_namespace_decl, handle_qualified_type_decl)
(handle_pointer_type_def, handle_reference_type_def)
(handle_enum_type_decl, handle_typedef_decl, handle_var_decl):
Don't use abi_corpus anymore. Rather, the translation unit a decl
belongs to is accessible from the decl itself.
* src/abg-writer.h (write_to_ostream): Use translation_unit in
this API, rather than abi_corpus.
* src/abg-writer.cc (write_translation_unit): Rename write_corpus
into this. And stop using abi_corpus here.
(write_to_ostream, write_corpus, write_location, write_decl)
(write_type_decl, write_namespace_decl, write_qualified_type_def)
(write_pointer_type_def, write_reference_type_def)
(write_enum_type_decl, write_typedef_decl, write_var_decl): Stop
using abi_corpus. Use the translation_unit that is accessible
from the decl being serialized, if need be.
* test-read-write.cc (main): De-serialize the input into an
instance of translation_unit, not an abi_corpus anymore, and
serialize that translation_unit.
* src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name)
(decl_base::set_mangled_name, decl_base::m_mangled_name): New
declarations.
(scope_decl::scope_decl: type_decl::type_decl)
(scope_type_decl::scope_type_decl, typedef_decl::typedef_decl):
Initialize mangled_name.
(namespace_decl::namespace_decl): Initialize visibility.
(class var_decl): New declaration.
* src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl)
(type_decl::type_decl, scope_type_decl::scope_type_decl):
Initialize mangled name.
(namespace_decl::namespace_decl): Initialize visibility.
(qualified_type_def::qualified_type_def)
(pointer_type_def::pointer_type_def)
(reference_type_def::reference_type_def): By default, set the
visibility to the same as for the underlying type.
(enum_type_decl::enum_type_decl, typedef_decl::typedef_decl):
Initialize mangled name.
(var_decl::var_decl, var_decl::operator==, var_decl::~var_decl):
New definitions.
* src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New
definitions.
(read_file): Handle var-decl elements.
* src/abg-writer.cc (write_location): Rename write_decl_location
into this.
(write_var_decl, write_visibility, write_binding): New definitions.
(write_decl, write_type_decl, write_qualified_type_def)
(write_pointer_type_def, write_reference_type_def)
(write_enum_type_decl, write_typedef_decl): Adjust to use
write_location.
* tests/data/test-read-write/test8.xml: New test input.
* tests/test-read-write.cc: De-serialize the above and serialize
it back and ensure both are equal.
* tests/Makefile.am: add tests/data/test-read-write/test8.xml to
the distribution.
* src/abg-ir.cc (dynamic_type_hash::operator()): Handle hashing of
a pointer to an instance of typedef_decl.
(typedef_decl::typedef_decl, typedef_decl::operator==)
(typedef_decl::operator==, typedef_decl::get_underlying_type)
(typedef_decl::~typedef_decl): New definitions.
* src/abg-ir.h (class typedef_decl, struct typedef_decl_hash): New
declarations.
* src/abg-reader.cc (handle_typedef_decl): New definition.
(handle_element): Handle de-serialization of typedef-decl element.
* src/abg-writer.cc (write_typedef_decl): New definition.
(write_decl): Handle serialization of an instance of typedef_decl.
* tests/data/test-read-write/test7.xml: New test.
* tests/Makefile.am: Add it to the distribution.
* tests/test-read-write.cc: De-serialize the content of the new
test, serialize it back and diff both.
* src/abg-ir.h (class enum_type_decl, struct enum_type_decl_hash):
New declarations.
* src/abg-ir.cc (dynamic_type_hash::operator()): Add hashing
support for enum_type_decl.
(enum_type_decl::enum_type_decl)
(enum_type_decl::get_underlying_type)
(enum_type_decl::get_enumerators, enum_type_decl::~enum_type_decl)
(enum_type_decl::operator==): New definitions.
* src/abg-reader.cc (handle_enum_type_decl): New definition.
(handle_element): Handle "enum-decl" element.
* src/abg-writer.cc (write_enum_type_decl): New.
(write_decl): Add support to serialize enum_type_decl.
* tests/test-read-write.cc: De-serialize and serialize
data/test-read-write/test6.xml back.
* tests/data/test-read-write/test6.xml: New test input.
* tests/Makefile.am: Add it to the distribution.
* tests/test-read-write.cc: Really de-serialize and then serialize
back data/test-read-write/test5.xml, not test4.xml. Sigh.
* src/abg-writer.cc (write_reference_type_def): As a result of
really trying to serialize reference type definitions fix the
serialization code here.
* src/abg-ir.h (class reference_type_def, struct pointer_type_def)
(struct reference_type_def): New declaration.
(type_base_hash::operator(), type_decl_hash::operator())
(scope_type_decl_hash::operator())
(qualified_type_def_hash::operator()): Include the typeid name in
the hash.
* src/abg-ir.cc (reference_type_def::reference_type_def)
(reference_type_def::operator==)
(reference_type_def::get_pointed_to_type)
(reference_type_def::is_lvalue)
(reference_type_def::~reference_type_def): New definitions.
(dynamic_type_hash::operator): Hash pointer_type_def and
reference_type_def instances.
* src/abg-reader.cc (read_context::finish_decl_creation)
(read_context::finish_type_decl_creation)
(handle_reference_type_def): New definitions.
(read_file): Handle "reference-type-def" elements.
(handle_type_decl, handle_namespace_decl)
(handle_qualified_type_decl, handle_pointer_type_def): Use the new
read_context::finish_type_decl_creation or
read_context::finish_decl_creation.
* src/abg-writer.cc (write_reference_type_def): New definition.
(write_decl): Supporting writing a pointer to an instance of
reference_type_def.
* tests/data/test-read-write/test5.xml: New test file.
* tests/test-read-write.cc: (De)Serialize it.
* tests/Makefile.am: Add it to the build system.
* src/abg-ir.h (location::{operator==, operator<})
(decl_base::operator==, scope_decl::operator==)
(type_base::operator==, struct type_shared_ptr_equal)
(type_decl::operator==, scope_type::operator==)
(qualified_type_def::operator==, class pointer_type_def): New
declarations..
* src/abg-ir.cc (decl_base::operator==, scope_decl::operator==)
(type_base::operator==, type_decl::operator==)
(scope_type_decl::operator==, namespace_decl::operator==)
(qualified_type_def::operator==)
(pointer_type_def::pointer_type_def, pointer_type_def::operator==)
(pointer_type_def::get_pointed_to_type)
(pointer_type_def::~pointer_type_def): New definitions.
* src/abg-reader.cc (handle_pointer_type_def): New definition.
(read_input): Handle pointer-type-def
elements.
* src/abg-writer.cc (type_shared_ptr_map): Make this map use the
use type_shared_ptr_equal predicate.
(write_pointer_type_def): New definition.
(write_decl): Improve logic. Support serializing a pointer to
pointer_type_def.
* tests/data/test-read-write/test4.xml: New test input file.
* tests/Makefile.am: Add tests/data/test-read-write/test4.xml to
the build system.
* tests/test-read-write.cc: (De)serialize the new test file.
* src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash)
(struct type_shared_ptr_hash, struct scope_type_decl_hash, class
qualified_type_def, struct qualified_type_def_hash): New.
(decl_base_hash::operator()): Constify. Don't crash if the scope
of the decl we are hashing is null.
(class type_decl): Add comment at the end.
(type_decl_hash::operator()): Constify. Reuse the new
type_base_hash hasher.
(class namespace_decl): Add comment.
* src/abg-ir.cc (qualified_type_def::qualified_type_def)
(qualified_type_def::~qualified_type_def)
(qualified_type_def::get_cv_quals)
(qualified_type_def::set_cv_quals)
(qualified_type_def::get_underlying_type)
(dynamic_type_hash::operator()): New function definitions.
* src/abg-reader.cc (handle_qualified_type_decl): New.
(read_file): Handle elements named "qualified-type-def".
(read::context::add_type_decl): Assert that
the type being associated to the unique ID is non-null.
(handle_type_decl): Fix this in the process; don't crash if some
attributes are not present. Associate the unique id present in
the xml document with the type we just parsed.
(handle_namespace_decl): Add some comments. Don't crash if the
name attribute is not present.
* src/abg-writer.cc (write_context::get_id_for_type)
(write_context::m_type_id_map, write_decl_location)
(write_qualified_type_def): New.
(write_decl): Handle instances of qualified_type_def.
(write_type_decl): Use the new write_decl_location and
write_context::get_id_for_type.
* tests/data/test-read-write/test0.xml: Update id format since we
are now using the new write_context::get_id_for_type to generate
it.
* tests/data/test-read-write/test1.xml: Likewise.
* tests/data/test-read-write/test2.xml: Likewise.
* tests/data/test-read-write/test3.xml: New test.
* tests/test-read-write.cc: Test De-serializing
tests/data/test-read-write/test3.xml and serializing it back.
Also don't bail out if we fail on one input.
* tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the
distribution.
* src/abg-reader.cc (read_context::get_cur_scope): Remove useless
const overload. Don't make this rely on m_cur_scope. Rather, use
the path to the current decl (from the root element) to compute
the cur scope.
(read_context::m_cur_scope, read_context::set_cur_scope): Remove
these.
(update_read_context): Re-think logic.
* tests/data/test-read-write/test2.xml: Add new test input.
* tests/Makefile.am: Add data/test-read-write/test2.xml to the
distribution.
* tests/test-read-write.cc: Add data/test-read-write/test2.xml to
the harness.
* abg-ir.{h,cc} (decl_base::decl_base, scope_decl::scope_decl)
(type_decl::type_decl, namespace_decl::namespace_decl): Do not
append a decl to its context from within its constructor. It's
better doing that in a function that takes shared_ptrs to decl and
context. That way we avoid memory management havoc.
(decl_base::set_scope): New private function.
(scope_decl::add_member_decl): Make this private.
(add_decl_to_scope): New function, friend of decl_base and
scope_decl.
* abg-reader.cc (read_context::get_cur_scope): Add a non-const
overload.
(handle_type_decl, handle_namespace_decl): Use add_decl_to_scope.
Adjust to new type_decl and namespace_decl constructor signature.
* src/abg-writer.cc (write_type): Emit 'id', not 'xml:id'.
(write_namespace_decl): Emit "namespace-decl", not
"namespace-decl-name", as the name of namespace element.
* tests/Makefile.am (test0.xml): Rename input0.xml into this.
(test1.xml): New test input.
* tests/data/test-read-write/test0.xml: Update to use 'id' as id
attribute, rather than xml:id.
* tests/data/test-read-write/test1.xml: New test.
* test-read-write.cc (struct InOutSpec): New
(main): Reorganize to give a list of input files to read and to
write to an output file, have the test read the input files, write
them, and diff the two.
* src/abg-writer.cc (do_indent): New function.
(write_corpus&): Use do_indent. Don't forget to close the
abi-instr tag.
(write_type_decl): Use do_indent. Handle null decls pointers.
Emit the id at the end of the element.
(write_namespace_decl): Use do_indent. Handle null decls
pointers.
* tests/test-utils.{h,cc} (get_src_dir,get_build_dir): Constify
the returned reference to string.
(is_dir, ensure_dir_path_created, ensure_parent_dir_created): New
function definitions.
* tests/test-read-write.cc (main): Augment the test to serialize
the corpus too.
* src/abg-ir.cc (namespace_decl::~namespace_decl): Add this
missing virtual constructor definition.
* src/abg-reader.cc (read_context::{get_cur_decl,pop_decl}):
Return a null pointer when the decls stack is empty.
(update_read_context): Don't try to de-reference a NULL cur_decl.
(read_input): Don't try to poke at file validity here. What was I
thinking. Really test for advance_cursor to return 1, expressing
success.
* src/abg-reader.h (read_file): Fix style.
* Makefile.am: Add tests sub-directory.
* configure.ac: Build with debugging-friendly options if the
ABIGAIL_DEBUG env variable is set. Generate tests/Makefile.
* tests/Makefile.am: New file.
* tests/test-read-write.cc: Likewise.
* tests/test-utils.{h,cc}: Likewise.
* tests/data/test-read-write/input0.xml: Likewise.