While looking at something else, it occured to me that we forget to
emit textual diagnostic for when a required alternate debug info file
was not found. The facility in question is mainly used by the
abipkgdiff tool for now.
* src/abg-dwarf-reader.cc (status_to_diagnostic_string): Report
textual diagnostic for the STATUS_ALT_DEBUG_INFO_NOT_FOUND case
too.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Sometimes, the debug information for one given package P can have been
split into several packages. In that case, we need abipkgdiff to
consider several debug info packages for a given input binary package.
This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package>
option, for a given input package.
* doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can
be provided several times on the command line.
* tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the
debug_package{1,2} data members into this, and make them be vector
of strings, rather than just strings.
(package::debug_info_packages_): Renamed
package::debug_info_package_ into this and make it be a vector of
package_sptr, rather than just a package_sptr.
(package::debug_info_packages): Renamed the method
package::debug_info_package into this and -- for the getter
overload -- make it return a vector of package_sptr, rather than
just a package_sptr. Likewise for the setter overload. Add a
non-const getter overload.
(package::erase_extraction_directories)
(extract_package_and_map_its_content): Adjust.
(extract_rpm, extract_deb): Do not erase the content of the
extraction directory (if it was pre-existing) prior to extracting
the RPM/deb into it.
(pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and
make it be a vector of packages, rather than just a package.
(pkg_extraction::pkg_extraction): Adjust to take a package_sptr
rather than just a package. Add an overload to take a vector of
packages_sptr.
(pkg_extraction::perform): Extract the vector of package that the
task is not responsible for, not just one random package.
(extract_package_and_map_its_content): Adjust.
(prepare_packages): Take smart pointers to package rather than
just packages. Adjust accordingly.
(compare_prepared_package): Make the overload that takes two
packages to take two smart pointers of packages.
(compare): Make the overload that takes two package take two
package_sptr.
(parse_command_line): Parse having --d{1,2} several times for a
given input package.
(main): Take several debug info packages for one input file.
* include/abg-tools-utils.h (split_string): Declare ...
* src/abg-tools-utils.cc (split_string): ... new function.
* tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm:
Add a new RPM test input file.
* tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt:
new reference output file.
* tests/data/Makefile.am: Add the new test input files above to source
distribution.
* tests/test-diff-pkg.cc (in_out_spec): Add new test entry to
specify two debug info packages for one input package.
(test_task::perform): Support having several debug info package
paths in the IntOutSpec::{first,second}_in_debug_package_path data
member. The debug info packages paths are separated by either a
white space or commas.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The alternate debug info file referred to a binary can be missing,
even though the rest of the debug info is not. In that case,
libabigail starts loading the debug info and then it crashes when
trying to get DIEs that are part of the missing alternate debug info.
This patch detects when the alternate debug info is missing, so that
abidiff and abipkgdiff can gracefully bail out, yielding a meaningful
error message.
* include/abg-dwarf-reader.h (enum abigail::dwarf_reader::status):
Add a new STATUS_ALT_DEBUG_INFO_NOT_FOUND enumerator there.
(refers_to_alt_debug_info): Declare new function.
* src/abg-dwarf-reader.cc (read_corpus_from_elf): Detect when the
referred-to alternate debug info file is not found and flip the
STATUS_ALT_DEBUG_INFO_NOT_FOUND bit of the status accordingly. If
the debug info was found but not the alternate debug info, then do
not try to read the debug info at all.
(refers_to_alt_debug_info): Define new function.
* tools/abidiff.cc (handle_error): Define new static function.
(main): Use it, rather than handling errors preventing libabigail
from reading the corpus on a case by case basis.
tools/abipkgdiff.cc (compare): Handle the case where no alternate
debug info was found.
* tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt:
New test output reference.
* tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm:
New test input RPM.
* tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm:
Likewise.
* tests/data/Makefile.am: Add the new test files above to source
distribution.
* tests/test-diff-pkg.cc (in_out_specs): Add a new test case from
the new input files above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
On some 32 systems (older glibc) the fts.h file cannot be included
"as-is" if the _FILE_OFFSET_BITS macro is set to 64.
This patch handles that case gently by including fts.h with
_FILE_OFFSET_BITS unset, but then by making sure fts.h can still
handle 64 bits file offset files.
* configure.ac: Detect if we are on a system where fts.h cannot be
included with _FILE_OFFSET_BITS defined. If that is the case,
then define the BAD_FTS macro.
* src/abg-tools-utils.cc: If BAD_FTS is defined then include fts.h
with _FILE_OFFSET_BITS not defined (that is, before config.h) but
then make sure that open and fopen are 64 bits aware.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Up to know, it wasn't possible to set options to instances of
xml_writer::write_context. So it wasn't possible to, say, make abidw
stop emitting source locations in the abixml.
This patch does the work necessary to set two options: annotate and
show locations. Note that the patch doesn't yet enable abidw to stop
emitting source locations. That will be done in a subsequent patch.
* include/abg-writer.h (create_write_context, set_show_locs)
(set_annotate): Declare new functions.
(write_corpus, write_corpus_group): Remove the output stream and
the annotate parameters as these can be retrieved from the
context.
* src/abg-writer.cc (write_context::m_show_locs): New data member.
(write_context::write_context): Initialize it.
(write_context::{get_show_locs, set_show_locs}): Add new member
functions.
(write_location): Take a write_context, rather than an output
stream. From the context, we detect if the user did set the "show
loc" option and act accordingly. Write the second overload in
terms of the first one.
(create_write_context, set_show_locs, set_annotate): Define new
functions.
(write_type_decl, write_qualified_type_def)
(write_pointer_type_def, write_reference_type_def)
(write_array_type_def, write_enum_type_decl, write_typedef_decl)
(write_var_decl, write_function_decl)
(write_class_decl_opening_tag, write_union_decl_opening_tag)
(write_type_tparameter, write_non_type_tparameter)
(write_function_tdecl, write_class_tdecl): Adjust the invocation
of write_location.
(write_corpus, write_corpus_group): Remove the output stream and
the annotate parameters as these can be retrieved from the
context. Adjust.
* tools/abidw.c: (load_corpus_and_write_abixml): Create a
write_context object, set the 'annotate' option to it and use that
object to actually write out the corpus.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-writer.cc (class write_context): Remove useless vertical
space near the end of the class definition.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (die_qualified_type_name): Cleanup a
switch case to make the form support more what we meant, and shut
down a GCC 7.2.1 warning.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
abg-leaf-reporter.cc: In member function ‘virtual void abigail::comparison::leaf_reporter::report(const abigail::comparison::qualified_type_diff&, std::ostream&, const string&) const’:
abg-leaf-reporter.cc:158:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
if (!diff_to_be_reported(&d))
^~
abg-leaf-reporter.cc:161:5: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
report_local_qualified_type_changes(d, out, indent);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* src/abg-leaf-reporter.cc (leaf_reporter::report): Fix misleading
indentation.
Signed-off-by: Mark Wielaard <mark@klomp.org>
This patch allows abidiff to take the --leaf-changes-only option and
then to display only the changes that are local to any given type.
That means the reporting agent won't follow pointers when displaying
changes. That gives less context to the ABI change reports but then
they are less cluttered.
To do this, the patch introduces a new reporting agent to libabigail:
abigail::comparison::leaf_reporter. When given a graph of diff nodes,
this agent only reports about the leaf (local) changes. That is, it
will *NOT* follow pointers, references, underlying types of qualified
and typedef types and things like that. It will just report about
changes that are local to a given type.
This reporting agent is then used (in lieu of the default
abigail::comparison::default_reporter agent) when the
--leaf-changes-only option is provided by the user on the command line
of abidiff.
Note that abidiff also takes the --impacted-interfaces option to so
that the leaf reporter shows the set of interfaces impacted
by each leaf change.
* doc/manuals/abidiff.rst: Add documentation the new
--leaf-changes-only and --impacted-interfaces options.
* src/abg-leaf-reporter.cc: New file.
* src/Makefile.am: Add the new src/abg-leaf-reporter.cc file to
source distribution.
* include/abg-fwd.h (get_var_size_in_bits)
(function_decl_is_less_than): Declare new functions.
(get_name): Add new overload for type_or_decl_base*.
* include/abg-ir.h (struct type_or_decl_hash, type_or_decl_equal)
(type_or_decl_base_comp): Define new types.
(artifact_sptr_set_type, artifact_ptr_set_type): Define new
typedefs.
* include/abg-comp-filter.h: Update copyright year.
(has_basic_type_name_change): Add new function declaration.
* src/abg-comp-filter.cc (decl_name_changed): Take a
type_or_decl_base rather than just a decl. Add an overload for
diff*.
(has_basic_type_name_change): Define new function.
* include/abg-comparison.h: Update copyright year.
(string_diff_ptr_map): Define this new typedef.
(class diff_maps): Define this new class.
(diff_context::{set_corpora}): Remove this member function.
(diff_context::{set_corpus_diff, get_corpus_diff,
show_leaf_changes_only, show_impacted_interfaces,
forbid_visiting_a_node_twice_per_interface}): Declare these new
member functions.
(diff_node_visitor::priv_): Add a new pimpl data member.
(diff_node_visitor::{diff_node_visitor, get_visiting_kind,
set_visiting_kind}): Turn these into out-of-line member functions.
(diff_node_visitor::{set,get}_current_topmost_iface_diff): Add new
member functions.
(class {scope_diff, function_type_diff, corpus_diff}): Add class
leaf_reporter as a friend.
(corpus_diff::mark_leaf_diff_nodes, get_leaf_diffs): Declare new
member functions.
(diff::{visiting_a_node_twice_is_forbidden_per_interface,
parent_interface_node}): Define new member functions.
(is_diff_of_basic_type): Return a type_decl_diff* rather than just
a bool.
(is_enum_diff, is_array_diff, is_function_type, is_typedef_diff)
(is_corpus_diff): Declare new functions.
(corpus_diff::diff_stats::{num_leaf_changes,
num_leaf_changes_filtered_out, net_num_leaf_changes}): Add new
member functions.
(is_distinct_diff): Declare new function.
* include/abg-reporter.h: Forward-declare "class diff_maps".
(reporter_base::diff_to_be_reported): Declare a new virtual member
function.
(reporter_base::{report_local_typedef_changes,
report_local_reference_type_changes,
report_local_function_type_changes}): Declare new member
functions.
(class leaf_reporter): Define new type.
* src/abg-comparison-priv.h (struct diff_hash, diff_equal): Define
new types.
(diff_artifact_set_map_type): Define new typedef.
(diff_context::priv::{first_corpus_, second_corpus_}): Remove
these data members.
(diff_context::priv::{corpus_diff_, leaf_changes_only_,
reset_visited_diffs_for_each_interface_,
show_impacted_interfaces_}): Add new data members.
(diff_context::priv::priv): Adjust.
(corpus_diff::priv::{leaf_diffs_, parent_interface_}): Add new
data member.
(corpus_diff::diff_stats::priv::{num_leaf_changes,
num_leaf_changes_filtered_out}): Add new data members.
(corpus_diff::priv::count_leaf_changes): Define new member
function.
(sort_artifacts_set, get_fn_decl_or_var_decl_diff_ancestor)
(is_diff_of_global_decls): Declare new functions.
(function_comp::operator()): Factorize this out into the new
function abigail::ir::function_decl_is_less_than.
* src/abg-ir.cc (get_var_size_in_bits)
(function_decl_is_less_than): Define new functions.
(get_name): Define new overload for type_or_decl_base*.
* src/abg-comparison.cc (is_enum_diff, is_typedef_diff)
(is_array_diff, is_function_type_diff, is_corpus_diff)
(is_distinct_diff, sort_artifacts_set, is_diff_of_global_decls):
Define new functions.
(is_union_diff): Fix comment.
(diff_context::forbid_visiting_a_node_twice_per_interface): Define
new member functions.
(diff_context::set_corpus_diff, get_corpus_diff)
(diff_context::show_leaf_changes_only)
(diff_context::visiting_a_node_twice_is_forbidden_per_interface)
(diff_context::show_impacted_interfaces): Define new member
functions.
(diff_context::get_reporter): Create the reporter that matches
what diff_context::show_leaf_changes_only says.
(diff_node_visitor::priv): Define a new type.
(diff_node_visitor::{diff_node_visitor, get_visiting_kind,
set_visiting_kind, or_visiting_kind,
set_current_topmost_iface_diff, get_current_topmost_iface_diff}):
Define new out-of-line member functions.
(struct diff_maps::priv): Define new type.
(diff_maps::{diff_maps, get_type_decl_diff_map,
get_type_decl_diff_map, get_enum_diff_map, get_class_diff_map,
get_union_diff_map, get_typedef_diff_map, get_array_diff_map,
get_function_type_diff_map, get_function_decl_diff_map,
get_var_decl_diff_map, get_reference_diff_map,
get_fn_parm_diff_map, get_distinct_diff_map, insert_diff_node,
lookup_impacted_interfaces}): Define member functions.
(corpus_diff::{mark_leaf_diff_nodes, get_leaf_diffs}): Define new
member functions.
(struct leaf_diff_node_marker_visitor): Define new type.
(corpus_diff::apply_filters_and_suppressions_before_reporting):
Mark diff nodes in here.
(corpus_diff::traverse): Appropriately set the current topmost
interface into the visitor before visiting a diff node.
(compute_diff): In the overload for corpus_sptr, adjust to reflect
that we are now storing the corpus_diff in the diff context.
(is_diff_of_basic_type): Return a type_decl_diff*, not just a
bool.
(corpus_diff::priv::count_leaf_changes): Define a new member
function.
(corpus_diff::diff_stats::{num_leaf_changes,
num_leaf_changes_filtered_out, net_num_leaf_changes}): Define new
member functions.
(corpus_diff::priv::apply_filters_and_compute_diff_stats): Use the
new corpus_diff::priv::count_leaf_changes to compute the number of
leaf changes.
(corpus_diff::priv::emit_diff_stats): Emit the report about leaf
type changes when necessary.
* src/abg-reporter-priv.h (report_mem_header): Declare new
overload.
(maybe_show_relative_offset_change,): Pass the var_diff_sptr
parameter by const reference.
(represent): Pass the var_diff_sptr parameter by const reference
and take a new "local-only" flag.
(maybe_show_relative_size_change)
(maybe_report_interfaces_impacted_by_diff): Declare new functions.
* src/abg-default-reporter.cc: Adjust copyright year.
(default_reporter::{report_local_typedef_changes,
report_local_qualified_type_changes,
report_local_reference_type_changes,
report_local_function_type_changes}): Define new member functions.
(default_reporter::report): Adjust. Add an overload for
function_type_diff&. In the overload for qualified_type_diff, if
the name of the underlying type changed, do not detail the changes
any further. In the overload for function_decl_diff, Adjust to
use the new diff_context::get_{first, second}_corpus member
function. In the overload for enum_diff, call the new
maybe_report_interfaces_impacted_by_diff that is advertised below.
* src/abg-reporter-priv.cc (represent): Adjust the overload for
var_diff_sptr.
(report_mem_header): Define new overload.
(maybe_show_relative_size_change)
(maybe_report_interfaces_impacted_by_diff): Define new functions.
(reporter_base::diff_to_be_reported): Define new member function.
(maybe_show_relative_offset_change): Pass the var_diff_sptr
parameter by const reference.
(represent): In the overload for var_diff_sptr, pass the
var_diff_sptr parameter by reference. Take a 'local_only' flag.
Iisplay type changes only if we are not displaying "local changes
only". Display size changes of data members too, when in
"local-only" mode.
* src/abg-suppression.cc (sonames_of_binaries_match)
(names_of_binaries_match): Adjust.
* tools/abidiff.cc (options::{leaf_changes_only,
show_impacted_interfaces}): Add new data members.
(display_usage): Emit usage string for the new --leaf-changes-only
and --impacted-interfaces options.
(parse_command_line): Parse the new --leaf-changes-only and the
--impacted-interfaces options.
(set_diff_context_from_opts): Set the 'show-leaf-changes' and the
'show-impacted-interfaces' flags.
* tests/data/test-diff-filter/libtest42-leaf-report-v{0,1}.so: New
test input.
* tests/data/test-diff-filter/test42-leaf-report-output-0.txt: New
test reference output.
* tests/data/test-diff-filter/test42-leaf-report-v{0,1}.cc: Source
code of the new test inputs.
* tests/test-diff-filter.cc (in_out_specs): Use the new test
inputs above in this harness.
* tests/data/test-diff-suppr/libtest35-leaf-v0.so: New test input.
* tests/data/test-diff-suppr/test35-leaf-report-0.txt: New test
reference output.
* tests/data/test-diff-suppr/test35-leaf-v{0,1}.cc: Source code of
the new test inputs.
* tests/data/test-diff-suppr/test35-leaf.suppr: Suppression
specification to use for the test35 test.
* tests/data/test-diff-suppr/libtest36-leaf-v0.so: New test input.
* tests/data/test-diff-suppr/libtest36-leaf-v1.so: Likewise.
* tests/data/test-diff-suppr/test36-leaf-report-0.txt: New
reference test output.
* tests/data/test-diff-suppr/test36-leaf-v0.cc: Source code of
test input above.
* tests/data/test-diff-suppr/test36-leaf-v1.cc: Likewise.
* tests/test-diff-suppr.cc (in_out_specs): Use the new test inputs
above in this harness.
* tests/data/Makefile.am: Add the new test inputs above to source
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Right now, the reporting functionnality is implemented directly in the
comparison engine. Being able to emit several kinds of reports is
really not practical with the current design.
This patch improves that situation by introducing an indirection
between the comparison engine and the code that emits the report.
A new abigail::comparison::reporter_base type is introduced. That
type several contains virtual methods that knows how to implement
reporting. Each virtual method reports about changes carried by a
kind of diff node. In other words, abigail::comparison::reporter_base
is the interface of reporter objects.
The current reporting using the current format is thus implemented by
the new abigail::comparison::default_reporter type, which implements
the abigail::comparison::reporter_base interface.
The diff::report methods now "just" get the reporter object from the
context of the diff and invoke its right reporting interface.
So whenever someone needs to implement a new reporting format, she
needs to provide a new implementation of the
abigail::comparison::reporter_base interface and set it to the
diff_context prior to invoking the
abigail::comparison::corpus_diff::report() method.
* include/Makefile.am: Add the new abg-reporter.h header file to
source distribution.
* include/abg-comparison.h: Include the new abg-reporter.h header
file.
(diff_context::{g,s}et_reporter): Declare new accessors.
({type_diff_base, decl_diff_base, corpus_diff}::priv): Make this
be a struct rather than a class.
({decl_diff_base, class_diff, scope_diff, function_type_diff,
corpus_diff}): Declare default_reporter a friend class of these.
* include/abg-reporter.h: New file.
* src/Makefile.am: Add abg-comparison-priv.h,
abg-reporter-priv.{h,cc} and abg-default-reporter.cc files to
source distribution.
* src/abg-comparison-priv.h: New file.
* src/abg-comparison.cc (sort_enumerators)
(sort_changed_enumerators, sort_data_members)
(sort_string_function_ptr_map)
(sort_string_function_decl_diff_sptr_map)
(sort_string_var_diff_sptr_map, sort_string_elf_symbol_map)
(sort_string_var_ptr_map, sort_string_data_member_diff_sptr_map)
(sort_unsigned_data_member_diff_sptr_map)
(sort_string_diff_sptr_map, sort_string_base_diff_sptr_map)
(sort_string_base_sptr_map, sort_string_fn_parm_diff_sptr_map)
(sort_string_parm_map, get_leaf_type, sort_enumerators)
(sort_changed_enumerators): Make these functions non-static and
move them at the beginning of the file. These functions are now
declared in abg-compared-priv.h so they can be shared privately
with other files in src/.
(diff_context::{g,s}et_reporter): Define new accessors.
({diff_context, diff, type_diff_base, decl_diff_base,
distinct_diff, pointer_diff, array_diff, reference_diff,
qualified_type_diff, enum_diff, class_or_union_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_type_diff,
function_decl_diff, type_decl_diff, typedef_diff,
translation_unit_diff, corpus_diff::diff_stats,
corpus_diff}::priv)
(diff_less_than_functor, enumerator_value_comp)
(changed_enumerator_comp, base_spec_comp, base_diff_comp)
(data_member_diff_comp, diff_comp, fn_parm_diff_comp, parm_comp)
(elf_symbol_comp, function_comp, function_decl_diff_comp)
(var_diff_sptr_comp): Move these type definitions to
abg-comparison-priv.h
(report_size_and_alignment_changes, report_loc_info)
(maybe_report_diff_for_member, maybe_report_diff_for_symbol)
(represent, represent_data_member)
(maybe_show_relative_offset_change, represent)
(report_size_and_alignment_changes, report_loc_info)
(report_name_size_and_alignment_changes, report_mem_header)
(maybe_report_diff_for_member, maybe_report_diff_for_symbol)
(show_linkage_name_and_aliases): Move these definitions to
abg-reporter-priv.cc.
({distinct_diff, var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff,
class_or_union_diff, class_diff, base_diff, union_diff,
scope_diff, fn_parm_diff, function_type_diff, type_decl_diff,
typedef_diff, corpus_diff}::report): Use the reporter object to
report about the changes carried by the the current diff node.
* src/abg-default-reporter.cc: New file.
* src/abg-reporter-priv.h: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-writer.cc (write_context::m_emitted_decl_only_set):
Renamed m_emitted_decl_only_map into this and make the type be a
set, rather than a map.
(write_context::{record_decl_only_type_as_emitted,
decl_only_type_is_emitted}): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
To record the emitted types, the abixml writer records the emitted
type *ID*s. So to lookup an emitted type, it needs to lookup the ID
of the type first, and then lookup that type-id in the set of emitted
type IDs. We are doing twice as much work as we should and profiling
the writting of a big abixml showed that it's quite taxing.
This patch makes the write records the set of emitted types directly.
No need to go through the emitted type *ID*s anymore. So we save one
map lookup. This incurs a 16% speedup when writting an abixml file
for a big (3GB) vmlinux file.
* src/abg-writer.cc (type_ptr_set_type): Declare new typedef.
(writer_context::m_emitted_type_id_map): Remove this data member.
(writer_context::m_emitted_type_set): Add a new data member.
(writer_context::{record_type_id_as_emitted, type_id_is_emitted,
clear_emitted_types_map}): Remove these member functions.
(writer_context::{record_type_as_emitted, type_is_emitted}): Use
the new m_emitted_type_set data member above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Until now, the canonical DIE offsets map (the map that associates a
canonical DIE offset to a given DIE offset) was implemented in the
DWARF reader by using vectors. This proves to use a lot of memory
(more than 25GB!!) for huge vmlinux binaries. So much that the thing
was too slow (hey, yeah, because it was swapping out!) on vmlinux
kernel binary of 3GB of size, just to abidw it out.
This patch changes that to use an unordered map for this. It now uses
~ 4GB of peak RAM memory, so I can actually abidw the vmlinux of 3GB
of size on my laptop. It's still taking 16 minutes (!!) to complete,
but at least it's progress, as it's completed at least, without
swapping out.
And it doesn't see to noticeably slowdown the test suite.
* src/abg-dwarf-reader.cc
(read_context::canonical_type_die_offsets_): Renamed the
canonical_type_die_vecs_ data member into this.
(read_context::canonical_decl_die_offsets_): Renamed the
canonical_decl_die_vecs_ data member into this.
(read_context::{initialize, compute_canonical_die_offset,
compute_canonical_die, get_canonical_die,
get_or_compute_canonical_die, set_canonical_die_offset,
get_canonical_die_offset}): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When computing a canonical DIE while reading DWARF, we crash in
get_or_compute_canonical_die basically because we loop over a vector
using an iterator which gets invalidated during the walk because some
code in the loop can increase the size of the vector (by adding
elements at its end) during the loop.
This patch fixes the issue by looping over the vector without using an
iterator that can be invalidated. The code now properly expects the
vector to grow during the walk.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (dwarf_offsets_type): There are two
instances of this typedef declaration, remove one.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
While looking into something else, I realized that for consistency,
the name of the offset_offset_map type should be
offset_offset_map_type. So I just did the change.
* src/abg-dwarf-reader.cc (offset_offset_map_type): Renamed
offset_offset_map into this.
(read_context::{primary_die_parent_map_,
alternate_die_parent_map_, type_section_die_parent_map_}): Adjust
the type of these data members.
(read_context::{die_parent_map, type_section_die_parent_map}):
Adjust the type of these member functions.
(read_context::{build_die_parent_relations_under,
get_parent_die}): Adjust for the type name in these functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When comparing classes that differ in their number of virtual member
functions, it can happen that we crash because we should have got out
earlier.
This patch fixes that. That problem happens on the test provided in
PR libabigail/17948 -- which is too big to be included in the test
suite.
* src/abg-ir.cc (equals): In the overload for class_decl, when we
detect that the virtual member function counts are different, get
out, even when we are being asked about the kind of the change.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When we face two equivalent highly recursive structs/classes, it can
happen that a given data member be added twice to the type. When
comparing two versions of a binary in which the data member happens to
have been removed from the second version, we thus trigger an assert
because a given data member has been "removed twice".
This happens on the example provided in PR libabigail/17948 -- which
is too big to be added to the test suite.
This patch hopefully fixes the issue by looking harder at the data
structure to make sure that we don't add the same data member twice.
* src/abg-dwarf-reader.cc (add_or_update_class_type): After a we
try to create a data member type, look *again* if the data member
wasn't added recursively by the creation of the data member type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This patch makes the data_member_diff_comp comparison functor consider
all the properties local to the data member: that is, its offset and
its name.
It used to only take the offset into account.
This makes sure that offset change reports have a stable ordering and
thus makes the runtestdiffpkg testcase succeeds on debian-i386.
* src/abg-comparison.cc (data_member_diff_comp): Make the
comparison take the qualified name of the data member into
account. Also, if the initial offset and qualified names of the
data members of the diff nodes are equal, consider the offset and
qualified names of the new data members.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When computing canonical DIEs, the DWARF reader mistakenly represents
'array of const' and 'const array' the same.
This patch fixes that.
* src/abg-dwarf-reader.cc (die_is_array_type): Define new static
function.
(die_is_pointer_or_reference_type): Also test that the DIE can be
an array.
* tests/data/test-read-dwarf/PR22122-libftdc.so: New binary test input.
* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: New reference output.
* tests/data/Makefile.am: Add the two new test files above to
source distribution.
* tests/test-read-dwarf.cc (in_out_specs): Run this test harness
over the new test input.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When the size of a var_decl changes, we want the 'equals' function for
var_decl to report that change as being a local one, not a subtype
one.
This patch fixes that.
* src/abg-ir.cc (equals): In the var_decl overload detect size
changes of type as being a local change.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Since glibc 2.24 readdir_r() is deprecated.
Applications are recommended to use readdir which is thread-safe when
using different directory streams (we explicitly create a new one here).
* src/abg-tools-utils.cc (dir_is_empty): Use readdir() instead
of readdir_r().
Signed-off-by: Mark Wielaard <mark@klomp.org>
On 32bit platforms [s]size_t isn't the same as [u]int64_t causing:
abg-dwarf-reader.cc:358:1: warning: ‘bool abigail::dwarf_reader::eval_last_constant_dwarf_sub_expr(Dwarf_Op*, size_t, ssize_t&, bool&)’ declared ‘static’ but never defined [-Wunused-function]
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare expr_len as uint64_t and value as int64_t.
Signed-off-by: Mark Wielaard <mark@klomp.org>
During DWARF reading, it can happen that we want to get the global
scope of a DIE which translation unit hasn't yet been constructed.
In that case, use the global scope of the current translation unit.
* src/abg-dwarf-reader.cc (get_scope_for_die): If the translation
unit of the parent die hasn't yet been constructed, then return
the global scope of the current translation unit.
* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so: New
binary test input.
* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
New reference test output.
* tests/data/Makefile.am: Add the new test materials above to
source distribution.
* tests/test-read-dwarf.cc (in_out_specs): Add the new test input
to the test suite.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When for a reason the ELF file could not be read and yet the user
keeps going with the elf reader context, it can happen that we crash.
This patch fixes that.
* src/abg-dwarf-reader.cc
(read_context::elf_architecture_is_ppc64): Do not crash if the elf
handle is nil.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This is the initial patch that makes abipkgdiff recognize Linux kernel
packages passed in argument and do the right thing.
abipkgdiff gets the vmlinux binary from the debug info package,
considers the union of that vmlinux binary and the thousands of kernel
modules that we shall name "the Kernel". It then compares ABI
(actually Kernel/Module Interface, a.k.a KMI) of the Kernel of the
first package against the KMI of the Kernel of the second package.
* include/abg-tools-utils.h (get_vmlinux_path_from_kernel_dist):
Declare new function.
(get_binary_paths_from_kernel_dist): Re-organize order of
parameters.
(file_is_kernel_package, file_is_kernel_debuginfo_package): Make
the file_path parameter be const.
(build_corpus_group_from_kernel_dist_under): Take an additional
debug_info_root parameter.
* src/abg-tools-utils.cc (file_is_kernel_package)
(file_is_kernel_debuginfo_package): Const-ify the file_name
parameter.
(find_vmlinux_path): Define new static function.
(get_binary_paths_from_kernel_dist): Re-organize the order of
parameters. The debug_info_root_path parameter is now an input
parameter.
(get_vmlinux_path_from_kernel_dist): Define new function.
(get_binary_paths_from_kernel_dist): Adjust invocation of
get_binary_paths_from_kernel_dist.
(build_corpus_group_from_kernel_dist_under): Take an additional
debug_info_root parameter.
* tools/abidw.cc (load_kernel_corpus_group_and_write_abixml):
Adjust invocation to build_corpus_group_from_kernel_dist_under.
* tools/abipkgdiff.cc (create_maps_of_package_content): Don't map
the content of a Linux Kernel package.
(compare_prepared_userspace_packages)
(compare_prepared_linux_kernel_packages, compare_prepared): Define
new functions.
(compare): Use the new functions above here.
* tools/kmidiff.cc (print_kernel_dist_binary_paths_under): Adjust
the invocation of get_binary_paths_from_kernel_dist.
(main): Adjust the invocation of
build_corpus_group_from_kernel_dist_under. Make sure that a
kernel package is accompanied by a debug info package.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When a class type lookup fails in a the type map of a corpus, the code
goes look the class up in the type maps of a every single translation
unit.
This design dates back from the time where there could be only one
type of a given name present in in the type map of a corpus. When
several types with the same were found, then each type would be
present in the type map of its translation unit, but then no type with
that name would be present in the type map of the corpus.
As a result, when a type was not found in the type map of the corpus,
we were looking for it in the type maps of the translation units.
Now that the type map of the corpus can carry several types with the
same name, we don't need to look in the translation unit anymore.
This patch implements that adjustment.
* src/abg-ir.cc (lookup_class_type): In the overload that looks
for a class name denoted by an interned_string in the corpus, do
not look for the class in the translation units when the type
wasn't found in the type map of the corpus.
(maybe_update_types_lookup_map): Remove the
erase_if_exists_already parameter and the code that uses it.
(lookup_class_type_through_translation_units): Remove this
function that is now useless.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When abipkgdiff compares binaries of a package, it doesn't report
errors like debug info or symbol not found.
This patch fixes that.
* include/abg-dwarf-reader.h (status_to_diagnostic_string):
Declare new function.
* src/abg-dwarf-reader.cc (status_to_diagnostic_string): Define
new function.
* tools/abipkgdiff.cc (compare): Take a new detailed_error_status
parameter.
(compare_task::perform): Get the details of the error, in case the
status of the comparison is ABIDIFF_ERROR.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When a type has a noop qualifier and that noop qualifier disapears in
a subsequent version of that type, the two versions of the type have
different internal pretty representations. And that leads to the type
canonicalization code ending up with two different canonical types for
the two versions, even if they should be considered equivalent.
This patch makes a noop-qualified type have the same internal pretty
representation as its non-qualified variant.
* src/abg-ir.cc (get_name_of_qualified_type): A noop-qualified
type has an empty string as reprsentation for its qualifier.
* src/abg-dwarf-reader.cc (die_qualified_type_name): Adjust to
comply with what is done in get_name_of_qualified_type. Adjust
comment too.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
Adjust.
* tests/data/test-diff-pkg/libcdio-0.94-1.fc26.x86_64--libcdio-0.94-2.fc26.x86_64-report.1.txt:
New reference test output.
* tests/data/test-diff-pkg/libcdio-0.94-1.fc26.x86_64.rpm: New
test binary input.
* tests/data/test-diff-pkg/libcdio-0.94-2.fc26.x86_64.rpm: Likewise.
* tests/data/test-diff-pkg/libcdio-debuginfo-0.94-1.fc26.x86_64.rpm: Likewise.
* tests/data/test-diff-pkg/libcdio-debuginfo-0.94-2.fc26.x86_64.rpm Likewise.
* tests/data/Makefile.am: Add the new test inputs to source distribution.
* tests/test-diff-pkg.cc (in_out_specs): Make this test harness run on
the new test inputs above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When a class is compared to its decl-only counterpart, if the user
doesn't want to see decl-only class related change, then do not report
any size change that might result from it.
This was already meant to be implemented but there was a typo. Fixed
thus.
* src/abg-comparison.cc (report_size_and_alignment_changes): Fix
typo.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Sincea little while, libabigail can now handle the presence of several
different class types definition that have the same name.
To handle that, we settled that for types originating from C, a
decl-only class would be considered different from a definition of
that class. Especially during type canonicalization.
Now it seems that it's wrong to consider this only for C types. That
is because the same class type foo, defined in a C header, can be
compile either into a C++ compilation unit, or a C one, in the same
binary. That is, in the same binary, a struct type foo can be seen
defined in a C compilation unit *and* in a C++ compilation unit.
So rigth now, the C++ struct type foo would compare equal to a
decl-only struct foo, but the C struct type foo would compare
different to a decl-only struct foo. This leads to spurious change
reports, especiall in the nmap and mariadb package from Fedora 25,
when we run selfcheck.py on fc25 critpath packages.
This patch makes libabigail always consider -- during type
canonicalization -- that a decl-only class is different from a
definition of that class. Not only for C.
* src/abg-comparison.cc (function_decl_diff::report): Don't report
possible vtable changes between a decl-only class and its
definition.
* src/abg-ir.cc (type_base::get_canonical_type_for): Consider that
a decl-only class is different from its definition when comparing
types for the purpose of type canonicalization.
(equals): In the class_or_union overload, only consider the global
decl_only_class_equals_definition() property to know when to
consider that a decl-only class is different from its definition
when comparing two classes.
* src/abg-reader.cc (build_class_decl): Read the size property of
a class, even if it's a decl-only class.
* src/abg-writer.cc (write_class_decl_opening_tag): Write size
property of types even if the types are decl-only classes.
* tests/data/test-annotate/test13-pr18894.so.abi: Adjust.
* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
Likewise.
* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Likewise.
* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
Likewise.
* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi:
Likewise.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt:
Likewise.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt:
Likewise.
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
Likewise.
* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Likewise.
* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
Likewise.
* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
Likewise.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
In debug info, some translation units are known to be empty because
they don't carry any DIE. It's thus useless to add those translation
units to the ABI corpus.
Note that in some packages like gcc and glibc (in Fedora 25) the same
empty translation unit can be present in the debug info more than
once. This violates a Libabigail invariant that asserts that a given
translation unit (designated by its path) shall be present only once
in the debug info.
* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir):
A translation unit DIE that has no child DIE shall not be added to
the current ABI corpus.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This seems to be a typo where I forgot to add a "break" statement in
the stv_to_elf_symbol_visibility function. Oops.
This patch fixes that.
* src/abg-dwarf-reader.cc (stv_to_elf_symbol_visibility): Add a
missing break statement.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
From what I have usually seen emitted by GCC, a "this pointer" is
represented by a DW_TAG_pointer_type. If the "this pointer" is for a
const method, then it points to a const class type DIE.
But in, in this problem report, I am seeing a "this pointer"
represented by a DW_TAG_const_type that points to a
DW_TAG_pointer_type, which is itself points to a class type DIE.
The code of die_this_pointer_is_const needs to be adjusted so that it
doesn't expect only a DW_TAG_pointer_type.
This is what this patch does.
* src/abg-dwarf-reader.cc (die_this_pointer_is_const): If the DIE
is not a DW_TAG_pointer_type then don't crash.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
A prerequisite to represent the relationship "DIE 'D' has canonical
DIE C", is that D and C come from the same DIE source. A DIE source
being either the main debug info file, the alternate debug info file
(both having DIEs in their .debug_info section), or a .debug_type
section.
This prerequisite is a result of the design of the current
libabigail's DWARF reader.
Unfortunately the code that compares DIEs and that updates the
canonical DIEs of the compared DIEs (in case the two DIEs are
equivalent) sometimes fails to honour that prerequisite, causing other
troubles down the road.
This patch fixes that by ensuring that equivalent DIEs must be of the
same DIE source.
The patch doesn't embed a regression test as this problem was
discovered using the
https://pagure.io/libabigail-selfcheck/blob/master/f/selfcheck.py
testing framework
* src/abg-dwarf-reader.cc (compare_dies): Don't propagate
a canonical DIE to a DIE that comes from a different source.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The path of a translation unit is relative to the directory where that
translation unit was compiled.
So there can be several different translation units (in the same
binary) that have the same (relative) paths. To tell them apart, one
needs to consider the compile directory of those translation units.
But then Libabigail ignores the compilation directory of translation
units. It just considers their (relative) path. That leads to
different translation units having the same path.
Furthermore, there can be a translation unit with full path (one that
takes into account the file name and its compile directory) named "P"
that contains function definitions f1 and f2, as described by the
debug info. Further down the road, there can be *another* translation
unit which also has "P" as its full path, and that cotnains function
definitions f3 and f4. A way to understand is to consider that the
translation unit of full path "P" contains f1, f2, f3 and f4.
This patch introduces the concept of the compile dir of a given
translation unit, and the concept of the absolute path of the
translation unit which would then be a concatenation of the compile
dir and relative paths of the translation unit.
The patch also tries to reuse a translation unit with a given path,
*if* that translation unit has already been seen in the current
binary, instead of creating a new one altogether.
This patch doesn't carry a regression test as the problem was found
while running the
https://pagure.io/libabigail-selfcheck/blob/master/f/selfcheck.py
script over the Fedora 25 critpath packages.
The patch does however update existing reference outputs of existings
tests where appropriate.
* include/abg-ir.h (translation_unit::{get_compilation_dir_path,
set_compilation_dir_path, get_absolute_path}):
* src/abg-corpus.cc (corpus::add): Use the new
translation_unit::get_absolute_path() as the key for the tu path
-> tu map.
* src/abg-dwarf-reader.cc
(read_context::resolve_declaration_only_classes): Use the new
translation_unit::get_absolute_path().
(build_translation_unit_and_add_to_ir): Set the compilation
directory of the translation unit.
* src/abg-ir-priv.h (translation_unit::priv::{comp_dir_path_,
abs_path_}):
* src/abg-ir.cc (translation_unit::set_path): Update comment.
(translation_unit::{get_compilation_dir_path,
set_compilation_dir_path, get_absolute_path}): Define new member
functions.
* src/abg-reader.cc (read_translation_unit): Take the new
'comp-dir-path' attribute into account.
* src/abg-writer.cc (write_translation_unit): Emit the new
'comp-dir-path' attribute.
* tests/data/test-annotate/libtest23.so.abi: Adjust.
* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Adjust.
* tests/data/test-annotate/libtest24-drop-fns.so.abi: Adjust.
* tests/data/test-annotate/test0.abi: Adjust.
* tests/data/test-annotate/test1.abi: Adjust.
* tests/data/test-annotate/test13-pr18894.so.abi: Adjust.
* tests/data/test-annotate/test14-pr18893.so.abi: Adjust.
* tests/data/test-annotate/test15-pr18892.so.abi: Adjust.
* tests/data/test-annotate/test17-pr19027.so.abi: Adjust.
* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust.
* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust.
* tests/data/test-annotate/test2.so.abi: Adjust.
* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust.
* tests/data/test-annotate/test21-pr19092.so.abi: Adjust.
* tests/data/test-annotate/test3.so.abi: Adjust.
* tests/data/test-annotate/test4.so.abi: Adjust.
* tests/data/test-annotate/test5.o.abi: Adjust.
* tests/data/test-annotate/test6.so.abi: Adjust.
* tests/data/test-annotate/test7.so.abi: Adjust.
* tests/data/test-annotate/test8-qualified-this-pointer.so.abi: Adjust.
* tests/data/test-read-dwarf/libtest23.so.abi: Adjust.
* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi: Adjust.
* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Adjust.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
* tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust.
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
* tests/data/test-read-dwarf/test13-pr18894.so.abi: Adjust.
* tests/data/test-read-dwarf/test14-pr18893.so.abi: Adjust.
* tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust.
* tests/data/test-read-dwarf/test17-pr19027.so.abi: Adjust.
* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust.
* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust.
* tests/data/test-read-dwarf/test2.so.abi: Adjust.
* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust.
* tests/data/test-read-dwarf/test21-pr19092.so.abi: Adjust.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust.
* tests/data/test-read-dwarf/test3.so.abi: Adjust.
* tests/data/test-read-dwarf/test4.so.abi: Adjust.
* tests/data/test-read-dwarf/test5.o.abi: Adjust.
* tests/data/test-read-dwarf/test6.so.abi: Adjust.
* tests/data/test-read-dwarf/test7.so.abi: Adjust.
* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi: Adjust.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When looking at ELF file of the ET_REL kind (i.e, relocatable object
files), several kinds of symbols (for instance weak symbols) can have
the symbol value zero. Although they have the same value, the fact
that that value is zero prevents us from considering those symbols as
being aliases.
Libabigail was wrongly considering those symbols with value zero as
being aliases. So, in practice, it was considering all WEAK symbols
as being aliases, because the value of a weak symbols is zero.
When comparing two binaries originating from the same source code, one
compiled with g++ and the other one compiled with clang++, abidiff was
thus reporting spurious function aliases changes due to this issue.
Note that the two binaries in question come from the bug PR21486.
Comparing them using abidiff exhibits several other issues that were
fixed in previous commits, such as
- Reporting changes about top cv qualifier changes on function
parameter types.
- Not supporting ELF symbol visibility
* src/abg-dwarf-reader.cc (load_symbol_maps_from_symtab_section):
Do not consider symbols with zero value as being aliases.
* tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-1.txt:
Likewise.
* test-diff-filter/test41-PR21486-abg-writer.gcc.o: New test
binary input.
* tests/data/test-diff-filter/test41-PR21486-abg-writer.llvm.o:
Likewise.
* tests/data/Makefile.am: Add the new test material to source
distribution.
* tests/test-diff-filter.cc (in_out_specs): Run the test harness
on the new test input above.
* tests/data/test-diff-dwarf/test5-report.txt: Adjust.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When the type of a function parameter sees its top CV qualifier
change, that should never negatively affect ABI compliance.
So this patch filters out top cv qualifier changes on function
parameter types, by default.
* include/abg-comparison.h (enum diff_category): Add a new
FN_PARM_TYPE_TOP_CV_CHANGE_CATEGORY enumerator. "Or" the
enumerator to the EVERYTHING_CATEGORY enumerator.
* src/abg-comp-filter.cc (has_fn_parm_type_cv_qual_change): Define
new static function.
(categorize_harmless_diff_node): Categorize changes to top cv
qualifiers on function parameter types into the new
FN_PARM_TYPE_TOP_CV_CHANGE_CATEGORY.
* src/abg-comparison.cc (get_default_harmless_categories_bitmap):
Add the new FN_PARM_TYPE_TOP_CV_CHANGE_CATEGORY category to the
set of harmless categories.
(operator<<(ostream&, diff_category)): Adjust to serialize
the new FN_PARM_TYPE_TOP_CV_CHANGE_CATEGORY.
* tests/data/test-diff-filter/libtest40-v0.so: New test input binary.
* tests/data/test-diff-filter/libtest40-v1.so: Likewise.
* tests/data/test-diff-filter/test40-report-0.txt: New test
reference output.
* tests/data/test-diff-filter/test40-v0.cc: Source code of the
test binary above.
* tests/data/test-diff-filter/test40-v1.cc: Likewise.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-diff-filter.cc (in_out_specs): Add new binaries to
compare.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt:
Adjust.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
Likewise.
* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt:
Likewise.
* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-1.txt:
Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When a class is forward-declared, resolving it to a definition that
appears later in the same translation unit or in another translation
is an interesting problem.
Until now, the declaration would be resolved to the definition of that
class found in the binary. The problem is that there can be different
such definitions, especially in C where there is no "One Definition
Rule". In that case, the definition chosen is random.
This patch resolves that randomness.
For a given class declaration, if there is just one possible
definition in the binary, then the declaration is resolved to that
definition. If there is one definition for that declaration in the
same translation unit, then the declaration is resolved to that
definition. If there are more than one definitions in translation
units that are not the one of the declaration, then the declaration is
left unresolved. This is what I call "selective class declaration resolution".
Note that an unresolved class declaration now compares different to a
definition of a class of the same name. This is so that we can have
an unresolved class be present in the resulting .abi file, alongside
an (incompatible) definition of the same class. The change from a class
declaration to its definition is filtered out by default, though.
* include/abg-fwd.h (type_base_wptrs_type)
(istring_type_base_wptrs_map_type): Define new typedefs.
(lookup_class_types): Declare new functions.
* include/abg-ir.h
(environment::decl_only_class_equals_definition): Declare new
accessor.
(type_maps::{*_types}): Make these accessors return
istring_type_base_wptrs_map_type& instead of
istring_type_base_wptr_map_type&.
* src/abg-dwarf-reader.cc
(read_context::resolve_declaration_only_classes): Implement the
new selective declaration resolution scheme.
* src/abg-ir.cc (type_maps::priv::{*_types_}): Change the type of
these data members from istring_type_base_wptr_map_type to
istring_type_base_wptrs_map_type.
(type_maps::{*_types}): Make these accessors definitions return
istring_type_base_wptrs_map_type& instead of
istring_type_base_wptr_map_type&.
(translation_unit::bind_function_type_life_time): Adjust.
(environment::priv::decl_only_class_equals_definition_): New data
member.
(environment::priv::priv): Initialize it. By default, a decl-only
class is now considered different from its definition.
(environment::decl_only_class_equals_definition): Define new
accessor.
(lookup_types_in_map, lookup_class_types): Define new functions.
(lookup_type_in_map, lookup_union_type_per_location)
(lookup_basic_type, lookup_basic_type_per_location)
(lookup_class_type, lookup_class_type_per_location)
(lookup_union_type, lookup_enum_type)
(lookup_enum_type_per_location, lookup_typedef_type)
(lookup_typedef_type_per_location, lookup_qualified_type)
(lookup_pointer_type, lookup_reference_type, lookup_array_type)
(lookup_function_type, maybe_update_types_lookup_map)
(maybe_update_types_lookup_map<class_decl>)
(maybe_update_types_lookup_map<function_type>): Adjust.
(type_base::get_canonical_type_for): When doing type comparison
here, we can now consider that an unresolved class declaration
compares different to an incompatible class definition of the same
name. So no need to look through decl-only classes in that case.
(equals): In the overload for class_or_union, if
environment::decl_only_class_equals_definition() is false, then an
unresolved class declaration of name "N" compares different to a
class definition named "N".
* tests/data/test-annotate/test15-pr18892.so.abi: Adjust.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
* tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust.
* tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt:
Adjust.
* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt:
Adjust.
* tests/data/test-diff-filter/test38/Makefile: New test material.
* tests/data/test-diff-filter/test38/test38-a.c: Likewise.
* tests/data/test-diff-filter/test38/test38-b.c: Likewise.
* tests/data/test-diff-filter/test38/test38-c.c: Likewise.
* tests/data/test-diff-filter/test38/test38-report-0.txt: Likewise.
* tests/data/test-diff-filter/test38/test38-v0: Likewise.
* tests/data/test-diff-filter/test38/test38-v1: Likewise.
* tests/data/test-diff-filter/test38/test38.h: Likewise.
* tests/data/test-diff-filter/test39/Makefile: Likewise.
* tests/data/test-diff-filter/test39/test39-a-v0.c: Likewise.
* tests/data/test-diff-filter/test39/test39-a-v1.c: Likewise.
* tests/data/test-diff-filter/test39/test39-b-v0.c: Likewise.
* tests/data/test-diff-filter/test39/test39-b-v1.c: Likewise.
* tests/data/test-diff-filter/test39/test39-c-v0.c: Likewise.
* tests/data/test-diff-filter/test39/test39-c-v1.c: Likewise.
* tests/data/test-diff-filter/test39/test39-main.c: Likewise.
* tests/data/test-diff-filter/test39/test39-report-0.txt: Likewise.
* tests/data/test-diff-filter/test39/test39-v0: Likewise.
* tests/data/test-diff-filter/test39/test39-v1: Likewise.
* tests/data/test-diff-filter/test39/test39.h: Likewise.
* tests/data/Makefile.am: Add the new test material above to the
source distribution.
* tests/test-diff-filter.cc (in_out_specs): Add the new test
inputs above to the test harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Right now, when loading each corpus of a group, a new read_context is
created and destroyed. That makes thousands of corpora that are
created and destroyed. Profiling seems to argue that we'd gain in
performance by re-using the first read_context that was created
instead, and re-set it before loading a new corpus.
This is what this patch does.
* include/abg-dwarf-reader.h (reset_read_context): Declare new
function.
* src/abg-dwarf-reader.cc (read_context::elf_paths_): Make this to
be non const.
(read_context::initialize): New function to initialize all data
members.
(read_context::read_context): Use the new read_context::initialize
function, rather than initializing data members 'inline' here.
(reset_read_context): Define a new function to reset a
read_context so that it can be re-used to load a new corpus.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When using abidw to generate an abixml for a Linux Kernel build tree,
usually, people have to copy the vmlinux binary into the directory
where modules are, so that the tool can find it. This --vmlinux
option helps to avoid doing that copy.
Simarly, when comparing two Linux Kernel build trees, --vmlinux1 and
--vmlinux2 are there to make the tool find the vmlinux binaries to
compare, independantly from the directories under which the modules
are to be found.
* include/abg-tools-utils.h
(build_corpus_group_from_kernel_dist_under): Add a new
vmlinux_path parameter.
* src/abg-tools-utils.cc (find_vmlinux_and_module_paths): Do not
try to find a vmlinux binary if we already have the path to one.
(build_corpus_group_from_kernel_dist_under): Add a new
vmlinux_path parameter.
* tools/abidw.cc (options::vmlinux): New data member.
(display_usage): Add a usage string for --vmlinux
(parse_command_line): Parse the new --vmlinux option.
(load_kernel_corpus_group_and_write_abixml): Fix some return code
when the function fails. Verify the presence of the vmlinux
binary that was given. Adjust.
* tools/kmidiff.cc (options::{vmlinux1, vmlinux2}): New data
members.
(display_usage): Add a usage string for --vmlinux1 and --vmlinux2.
(parse_command_line): Parse the --vmlinux1 and --vmlinux2
options.
(main): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
get_type_name can be called over and over again on function types.
This patch caches the result of the computation of function type names
in those cases.
This is a speed optimization.
* src/abg-ir.cc (get_type_name): Cache function type names.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-reader.cc (build_enum_type_decl): Do not check for
errno which might have been set earlier by something else.
Rather, check the returned value for overflow or underflow.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Sometimes some virtual member functions don't have any virtual offset
set in the debug info. This happens for virtual destructors
sometimes. In that case, the ABI change report should not refer to
that unset virtual offset as being '0'. Rather, it shouldn't refer to
it at all.
This is what this patch does.
* include/abg-ir.h (mem_fn_context_rel::mem_fn_context_rel):
Initialize the virtual offset to -1.
* src/abg-comparison.cc (represent): In the overload to represent
a method_decl, do not represent the vofffset if it's not set.
* src/abg-writer.cc (write_voffset): The virtual offset is signed
because if it's -1, it means no offset is set.
* tests/data/test-annotate/test14-pr18893.so.abi: Adjust.
* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
Adjust.
* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Adjust.
* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
Adjust.
* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi:
Adjust.
* tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt: Adjust.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
* tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust.
* tests/data/test-read-dwarf/test14-pr18893.so.abi: Adjust.
* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
Adjust.
* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Adjust.
* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
Adjust.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>