mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-17 23:44:35 +00:00
246ca20049
593 Commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
Matthias Maennich
|
246ca20049 |
corpus/writer: sort emitted translation units by path name
By sorting the corpora output, we achieve determinism for the emitted XML file across multiple runs of abidw. For that to happen, change the collection of translation units to a std::set (instead of std::vector), sorted by absolute path name. Test data needed adjustments, but changes are fully compatible. * include/abg-fwd.h: remove translation_units fwd declaration. * include/abg-ir.h (struct shared_translation_unit_comparator): Define new class. (translation_units): Define new typedef. * src/abg-corpus.cc (corpus::add): do checked insert into the translation_units set (rather than vector::push_back) * tests/data/test-annotate/test13-pr18894.so.abi: Adjust test data. * 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. Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
f014f8c1f0 |
Fix compilation with g++ 4.8.5 on el7
G++ 4.8.5 doesn't allow a function template specialization to appear in a namespace that is different from the namespace where the function template was declared. Also, in that namespace, the name of the specialized function template must be non-fully-qualified. Fixed thus. * include/abg-libxml-utils.h (build_sptr<xmlTextReader>): Wrap this specialization in the namespace sptr_utils and do away with the sptr_utils qualifier. * include/abg-regex.h (build_sptr<regex_t>): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
186cc9ed3a |
Simplify generation of symbol whitelist regex.
The code to build the symbol whitelist regex uses things like seekp and tellp to generate regexes like "^foo$|^bar$". This patch simplifies the code, for further enhancement, resulting in generated regexes like "^(foo|bar)$". There should be no change in behaviour, unless whitelisted symbol names contain special regex characters. * include/abg-regex.h (generate_from_strings): Declare new function to build a regex from some strings, representing a membership test. * src/abg-regex.cc (generate_from_strings): Implement new function to build a regex from some strings, representing a membership test, in a straightfoward fashion. * src/abg-tools-utils.cc (gen_suppr_spec_from_kernel_abi_whitelists): Replace regex-building code with a call to generate_from_strings. * tests/test-kmi-whitelist.cc: Update regexes in test. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
0082ee529f |
Move libxml bits out of abg-sptr-utils.h.
The header file abg-sptr-utils.h contains generic things relating to shared pointers. It also contains shared pointer typedefs (in the sptr_utils namespace) and template specialisations for XML types. The last of these more naturally belong in abg-libxml-utils.h (and in the xml namespace). This patch moves them. There are no behavioural changes. * include/abg-sptr-utils.h: Remove reader_sptr and xml_char_sptr typedefs, from namespace sptr_utils. (build_sptr): Remove corresponding template function specialisations for these types. * include/abg-libxml-utils.h: Add reader_sptr and xml_char_sptr typedefs, to namespace xml. (build_sptr): Add corresponding template function specialisations for these types. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
ae30e5fa96 |
Move regex definitions to own files.
As a prelude to adding wrapper and helper functions for regex functionality, it makes sense to move the existing regex code (the shared pointer type and its specialised deleter) to their own files. This patch does this and also moves various entities into a new namespace, abigail::regex. It removes the file abg-sptr-utils.cc which only contained regex things. There are no behavioural changes. * include/Makefile.am: Add abg-regex.h. * src/Makefile.am: Remove abg-sptr-utils.h, add abg-regex.cc * include/abg-sptr-utils.h (regex_t_sptr): Remove this typedef, from namespace abigail::sptr_utils. (regex_t_deleter): Remove this struct, from namespace abigail::sptr_utils. (build_sptr): Remove these template specialisations, in duplicate, for regex_t_sptr. * include/abg-regex.h: New file, introduces namespace abigail::regex. (regex_t_sptr): Add this typedef, to namespace abigail::regex. (regex_t_deleter): Add this struct, to namespace abigail::regex. (build_sptr): Add these template specialisations for regex_t_sptr * src/abg-sptr-utils.cc: Remove this file. * src/abg-regex.cc: Add new file with contents effectively the same as abg-sptr-utils.cc. * src/abg-corpus-priv.h: Update regex_t_sptr namespace qualification. * src/abg-corpus.cc: Ditto. * src/abg-suppression-priv.h: Ditto. * src/abg-suppression.cc: Ditto. Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Mark Wielaard
|
a9f5fb4089 |
Add --no-write-default-sizes option.
abidw will write out the exact same size-in-bits address for every
pointer type, reference type, function declaration and function type
even though it is always the same as the translation unit address
size. When giving the --no-write-default-sizes option these aren't
written out anymore. The reader is updated to set the default size
when none is given in the XML description.
Even though size and alignment are handled together in the reader,
default alignment is still set to zero, following commit
|
||
Mark Wielaard
|
b8860e1db3 |
Add --no-elf-needed option to drop DT_NEEDED list from corpus.
The elf-needed list is not relevant for the exported ABI of a library so provide an option to drop it. * doc/manuals/abidw.rst: Document --no-elf-needed. * include/abg-writer.h (set_write_elf_needed): New function. (set_common_options): Call it. * src/abg-writer.cc (write_context::m_write_elf_needed): New data member. (write_context::{g,s}et_write_elf_needed): Add new accessors. (set_write_elf_needed): New function. (write_context::write_corpus): Check write_elf_needed. * tools/abidw.cc (options): Add write_elf_needed bool. (display_usage): Describe --no-elf-needed. (parse_command_line): Parse --no-elf-needed. Signed-off-by: Mark Wielaard <mark@klomp.org> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Mark Wielaard
|
8da509aaa2 |
Add no-parameter-names to drop function parameter names.
The function parameter names are not relevant for the (exported) ABI. So provide an option to simply drop them from the corpus. * doc/manuals/abidw.rst: Add documentation for --no-parameter-names. * include/abg-writer.h (set_write_parameter_names): New function. (set_write_parameter_names): Call it. * src/abg-writer.cc (write_context): Add m_write_parameter_names bool, get_write_parameter_names and set_write_parameter_names functions. (write_context::write_function_decl): Check write_parameter_names. * tools/abidw.cc (options): Add write_parameter_names. (display_usage): Describe --no-parameter-names. (parse_command_line): Parse --no-parameter-names. Signed-off-by: Mark Wielaard <mark@klomp.org> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Mark Wielaard
|
254cafb7d7 |
Add --drop-undefined-syms to abidw.
Add a drop_undefined_syms properties to the read_context that indicates the reader wants to drop any undefined symbols (which don't have associated addresses in the corpus). Implement this for the dwarf_reader and abidw (when using the --drop-undefined-syms option). * include/abg-dwarf-reader.h (set_drop_undefined_syms): New declaration. * src/abg-dwarf-reader.cc (class read_context): Add private bool drop_undefined_syms_. (drop_undefined_syms): New getter and setter method. (set_drop_undefined_syms): New function. (function_is_suppressed): Check drop_undefined_syms on read_context. (variable_is_suppressed): Likewise. * src/abg-reader.cc (read_context): Add private bool m_drop_undefined_syms. (drop_undefined_syms): New getter and setter method. * tools/abidw.cc (struct options): Add drop_undefined_syms. (display_usage): Print --drop-undefined-syms. (parse_command_line): Parse --drop-undefined-syms. (main): Call set_drop_undefined_syms. Signed-off-by: Mark Wielaard <mark@klomp.org> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Mark Wielaard
|
9fe85b370c |
Add --header-file option to add individual public header files.
Sometimes public header files are in the same directory as private header files. In such cases --headers-dir cannot be used. Add --header-file to add individual public header files. * include/abg-tools-utils.h (gen_suppr_spec_from_headers): Add hdr_files string vector argument. * src/abg-tools-utils.cc (handle_file_entry): New function that adds one specific file to the type_suppression. Implementation lifted from... (handle_fts_entry): ...here. Call handle_file_entry for each file. (gen_suppr_spec_from_headers): Also takes a header_files string vector as argument. Call handle_file_entry for each file entry. * tools/abidiff.cc (options): Add header_files1 and header_files2 string vectors. (display_usage): Print --header-file1 and --header-file2 usage. (parse_command_line): Handle --header-file1, --hf1 and --header-file2, --hf2. (set_diff_context_from_opts): Call gen_suppr_spec_from_headers with header_files1 and header_files2. (set_suppressions): Likewise. * tools/abidw.cc (options): Add header_files string vector. (display_usage): Print --header-file usage. (parse_command_line): Handle --header-file1, --hf1. (maybe_check_header_files): New function. (set_suppressions): Call gen_suppr_spec_from_headers with header_files. (main): Call maybe_check_header_files. * tools/abilint.cc (options): Add header_files string vector. (display_usage): Print --header-file usage. (parse_command_line): Handle --header-file1, --hf1. (set_suppressions): Call gen_suppr_spec_from_headers with header_files. * doc/manuals/abidiff.rst: Document --header-file1, --hf1 and --header-file2, --hf2. Add new options to documentation of --drop-private-types. * doc/manuals/abidw.rst: Document --header-file, --hf. * doc/manuals/abilint.rst: Likewise. Signed-off-by: Mark Wielaard <mark@klomp.org> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Giuliano Procida
|
ef90972a4a |
abidiff: Remove blank line after typedef changes.
This patch removes perhaps the last remaining cause of double blank lines in output. The state variable emit_nl was being set to true just after emitting a new line which resulted in a blank line after every local typedef change report. * include/abg-reporter.h (default_reporter::report_local_typedef_changes): Change return type to void. * src/abg-default-reporter.cc: (default_reporter::report_local_typedef_changes): Change return type to void, remove emit_nl state variable and logic. * tests/data/test-abidiff/test-PR18791-report0.txt: Remove blank lines. * tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt: Ditto. * tests/data/test-diff-suppr/test39-opaque-type-report-0.txt: Ditto. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
2d5389f265 |
Fix size calculations for multidimensional arrays.
The code in abg-ir.cc that calculated the memory size of an array summed, rather than multiplied, the dimensions. It also did duplicate work for each dimension after the first. Existing code in abg-reader.cc asserted that array size information read from XML match freshly calculated values. This patch corrects the calculation, eliminates the duplicate work and updates the XML reader validation to just emit a warning if old bad array size information is found. * include/abg-ir.h (array_type_def::append_subrange): Remove this function. * src/abg-ir.cc (array_type_def::set_element_type): Add a note about safe usage. (array_type_def::append_subrange): Inline this function into its only caller append_subranges and remove it. (array_type_def::append_subranges): Do correct multiplicative calculation of multidimensional array sizes. * src/abg-reader.cc (build_array_type_def): When checking calculated against read array sizes, warn once if value matches old behaviour rather than raising an assertion. Otherwise, before raising an assertion, emit an informative error message. * tests/data/test-annotate/test14-pr18893.so.abi: Correct array sizes. * tests/data/test-annotate/test17-pr19027.so.abi: Ditto. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Ditto. * tests/data/test-annotate/test7.so.abi: Ditto. * tests/data/test-diff-dwarf/test10-report.txt: Ditto. * tests/data/test-diff-dwarf/test11-report.txt: Ditto. * tests/data/test-read-write/test25.xml: Ditto. Reviewed-by: Matthias Maennich <maennich@google.com> Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
9cf76b1175 |
abg-ir.cc: Improve types_have_similar_structure.
This function is used to determine whether or not type differences are "local" and is primarily used in --leaf-changes-only mode. The logic has some issues which are addressed by this patch: - Any number of points-to (*) and refers-to (& and &&) components are peeled off the types being compared, rather than checking these match in number and kind. - This peeling is done with peel_typedef_pointer_or_reference_type which also peels any number of CV qualifiers (OK) and array-of ([N]) type components (not OK). - The function sets a state variable (was_indirect_type) to modify the behaviour of downstream comparisons, but this cannot be passed through recursive calls. The effect of the indirect_type flag is to switch to comparisons by name: identically named structs don't get introspected. Arguably, a more useful behaviour for --leaf-changes-only mode would be to treat any change to a named type as non-local, except in the context of the definition of that type itself. This would be a more significant change in behaviour. * include/abg-fwd.h (types_have_similar_structure): In both overloads, add an indirect_type argument, defaulting to false. * src/abg-ir.cc (reference_type_def constructor): Tabify. (types_have_similar_structure): In both overloads, add an indirect_type argument and update documentation text. In the type_base_sptr overload, pass indirect_type in the tail call. In the type_base* overload, replace was_indirect_type with indirect_type; peel CV qualifiers and typedefs without testing as the peel function does this; replace the indiscriminate peeling of qualifier/pointer/reference/array type components with code that checks the same pointer/reference/array type component is used on each side and makes recursive calls with indirect_type set to true; pass the indirect_type argument recursively when comparing other subtypes; move the typeid check earlier, document its purpose and remove unneccessary checks after later dynamic casts; remove an always-true conditional; add a TODO for comparing array types more accurately. * tests/data/Makefile.am: Add new test case files. * tests/data/test-abidiff-exit/test-leaf-peeling-v0.cc: New test case. * tests/data/test-abidiff-exit/test-leaf-peeling-v1.cc: Ditto. * tests/data/test-abidiff-exit/test-leaf-peeling-report.txt: Ditto. * tests/test-abidiff-exit.cc: Run new test case. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Giuliano Procida
|
b0ce702088 |
Eliminate redundancy in representation of local change kinds.
* include/abg-ir.h (change_kind): Remove redundant LOCAL_CHANGE_KIND member, renumber members and update comments. * src/abg-comparison.cc (distinct_diff::has_local_changes): Remove redundant LOCAL_CHANGE_KIND. (var_diff::has_local_changes * src/abg-ir.cc (equals): In the type_base, qualified_type_def, pointer_type_def, reference_type_def, array_type_def::subrange_type, array_type_def, enum_type_decl, typedef_decl, var_decl, function_type, function_decl, function_decl::parameter, class_or_union, class_decl::base_spec, class_decl, decl_base and scope_decl overloads, remove redundant LOCAL_CHANGE_KIND. (enum_has_non_name_change): Remove redundant LOCAL_CHANGE_KIND. Signed-off-by: Giuliano Procida <gprocida@google.com> |
||
Dodji Seketeli
|
1d6731c438 |
Update copyright year to 2020
We are in February 2020 so this is long overdue. * include/abg-comp-filter.h: Update copyright year to 2020. * include/abg-comparison.h: Likewise. * include/abg-config.h: Likewise. * include/abg-corpus.h: Likewise. * include/abg-cxx-compat.h: Likewise. * include/abg-diff-utils.h: Likewise. * include/abg-dwarf-reader.h: Likewise. * include/abg-fwd.h: Likewise. * include/abg-hash.h: Likewise. * include/abg-ini.h: Likewise. * include/abg-interned-str.h: Likewise. * include/abg-ir.h: Likewise. * include/abg-libxml-utils.h: Likewise. * include/abg-libzip-utils.h: Likewise. * include/abg-reader.h: Likewise. * include/abg-reporter.h: Likewise. * include/abg-sptr-utils.h: Likewise. * include/abg-suppression.h: Likewise. * include/abg-tools-utils.h: Likewise. * include/abg-traverse.h: Likewise. * include/abg-viz-common.h: Likewise. * include/abg-viz-dot.h: Likewise. * include/abg-viz-svg.h: Likewise. * include/abg-workers.h: Likewise. * include/abg-writer.h: Likewise. * src/abg-comp-filter.cc: Likewise. * src/abg-comparison-priv.h: Likewise. * src/abg-comparison.cc: Likewise. * src/abg-config.cc: Likewise. * src/abg-corpus-priv.h: Likewise. * src/abg-corpus.cc: Likewise. * src/abg-default-reporter.cc: Likewise. * src/abg-diff-utils.cc: Likewise. * src/abg-dwarf-reader.cc: Likewise. * src/abg-hash.cc: Likewise. * src/abg-ini.cc: Likewise. * src/abg-internal.h: Likewise. * src/abg-ir-priv.h: Likewise. * src/abg-ir.cc: Likewise. * src/abg-leaf-reporter.cc: Likewise. * src/abg-libxml-utils.cc: Likewise. * src/abg-libzip-utils.cc: Likewise. * src/abg-reader.cc: Likewise. * src/abg-reporter-priv.cc: Likewise. * src/abg-reporter-priv.h: Likewise. * src/abg-sptr-utils.cc: Likewise. * src/abg-suppression-priv.h: Likewise. * src/abg-suppression.cc: Likewise. * src/abg-tools-utils.cc: Likewise. * src/abg-traverse.cc: Likewise. * src/abg-viz-common.cc: Likewise. * src/abg-viz-dot.cc: Likewise. * src/abg-viz-svg.cc: Likewise. * src/abg-workers.cc: Likewise. * src/abg-writer.cc: Likewise. * tests/print-diff-tree.cc: Likewise. * tests/test-abicompat.cc: Likewise. * tests/test-abidiff-exit.cc: Likewise. * tests/test-abidiff.cc: Likewise. * tests/test-alt-dwarf-file.cc: Likewise. * tests/test-core-diff.cc: Likewise. * tests/test-diff-dwarf-abixml.cc: Likewise. * tests/test-diff-dwarf.cc: Likewise. * tests/test-diff-filter.cc: Likewise. * tests/test-diff-pkg.cc: Likewise. * tests/test-diff-suppr.cc: Likewise. * tests/test-diff2.cc: Likewise. * tests/test-dot.cc: Likewise. * tests/test-ini.cc: Likewise. * tests/test-ir-walker.cc: Likewise. * tests/test-lookup-syms.cc: Likewise. * tests/test-read-dwarf.cc: Likewise. * tests/test-read-write.cc: Likewise. * tests/test-svg.cc: Likewise. * tests/test-tools-utils.cc: Likewise. * tests/test-types-stability.cc: Likewise. * tests/test-utils.cc: Likewise. * tests/test-utils.h: Likewise. * tests/test-write-read-archive.cc: Likewise. * tools/abiar.cc: Likewise. * tools/abicompat.cc: Likewise. * tools/abidiff.cc: Likewise. * tools/abidw.cc: Likewise. * tools/abilint.cc: Likewise. * tools/abipkgdiff.cc: Likewise. * tools/abisym.cc: Likewise. * tools/binilint.cc: Likewise. * tools/kmidiff.cc: Likewise. * update-copyright.sh: Fix the updating script to handle not just "Red Hat, Inc." Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
6a0e7e120b |
abixml-reader: Support SONAME related properties on file suppression
When comparing binary files (using abidiff for instance) libabigail can interpret the [suppress_file] section of a suppression specification. If the suppression specification matches either of the compared files, no comparison is performed. At the moment, that doesn't work when comparing abixml files. Thus, this patch implements that feature for abixml files. With this patch, one can now write a suppression specification like this: [suppress_file] soname_regexp = <some-regexp> or [suppress_file] file_name_regexp = <some-regexp> If either abixml file has a soname matched by such a regexp, then no comparison is performed. * doc/manuals/libabigail-concepts.rst: Update the documentation to mention soname_regexp and soname_not_regexp is supported in the [suppress_file] section. * include/abg-suppression.h (suppression_matches_soname) (suppression_matches_soname_or_filename): Declare new functions. Make them be friends of class suppression_base. * src/abg-reader.cc (read_context::corpus_is_suppressed_by_soname_or_filename): Define new member function. (read_corpus_from_input): Apply file suppression. * src/abg-suppression.cc (read_file_suppression): Support "soname_regexp" and "soname_not_regexp" in the [suppress_file] section. (suppression_matches_soname) (suppression_matches_soname_or_filename): Define new functions. * tests/data/test-diff-suppr/libtest48-soname-abixml-report-{1,2}.txt: New test reference output files. Likewise. * tests/data/test-diff-suppr/libtest48-soname-abixml-suppr.txt: New test suppression file. * tests/data/test-diff-suppr/libtest48-soname-abixml-suppr-{2,3,4}.txt:: Likewise. * tests/data/test-diff-suppr/libtest48-soname-abixml-v{0,1}.so: New test binary input files. * tests/data/test-diff-suppr/libtest48-soname-abixml-v{0,1}.so.abi: New abixml for the binary input files above. * tests/data/test-diff-suppr/test48-soname-abixml-v{0,1}.c: Source code of the binary input files above. * tests/data/Makefile.am: Add the above test material to source distribution. * tests/test-diff-suppr.cc (in_out_specs): Add the test input above to this test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
f5fd6931f6 |
suppression: Better handle soname/filename properties evaluation
At the moment, we don't make any difference between these two cases: 1/ A suppression specification has no soname or file name related property. 2/ A suppression specification has a soname or file name related property that doesn't match the soname or file name of a given corpus. In both cases 1/ and 2/ libabigail currently assumes that the suppression specification does not match the given corpus we are looking at. This can be wrong, especially if we are in the case 1/ and if the suppression does have other properties that should make it match the corpus. This patch fixes this issue. * include/abg-suppression.h (suppression_base::has_{soname,file_name}_related_property): Add new member functions. * src/abg-dwarf-reader.cc (read_context::suppression_can_match): Fix the logic to make a difference between the case where the suppression doesn't have any soname/filename property and the case where the suppression does have a soname/filename property that does not match the current binary. * src/abg-reader.cc (read_context::suppression_can_match): Likewise. * src/abg-suppression-priv.h (suppression_base::priv::matches_soname): If the suppression does not have any soname related property then it doesn't match the soname we are looking at. (suppression_base::priv::matches_binary_name): If the suppression does not have any filename related property then it doesn't match the filename we are looking at. * src/abg-suppression.cc (suppression_base::has_{soname,file_name}_related_property): Define new member functions. (sonames_of_binaries_match): If the suppression does not have any soname related property then it doesn't match the corpora of the diff we are looking at. (names_of_binaries_match): If the suppression does not have any filename related property then it doesn't match the corpora of the diff we are looking at. (type_suppression::suppresses_type): Fix the logic to make a difference between the case where the suppression doesn't have any soname/filename property and the case where the suppression does have a soname/filename property that does not match the current binary. (function_suppression::suppresses_{function, function_symbol}): Likewise. (variable_suppression::suppresses_{variable, variable_symbol}): Likewise. (file_suppression::suppresses_file): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Matthias Maennich
|
91a4274c9c |
abg-workers: Rework the worker queue to improve concurrent behaviour
This patch refactors the abigail::workers::queue and abigail::workers::worker implementations to avoid holding locking primitives longer than necessary. In particular, the queue_cond_mutex was held during the entiry worker runtime, effectively serializing the workers. Hence, use a mutex+cond pair for each, the input and output queue and only synchronize around the interaction with their corresponding queues. The tasks_todo_(mutex|cond) are meant to synchronize scheduling and distribution of work among workers, while tasks_done_(mutex|cond) are used for synchronizing threads when putting back the tasks to the output queue and to hold back threads waiting for the queue and workers to drain. Along that way, I did some cleanup that was now possible. - Move entire implementation of abigail::workers::task into header. - Make default_notify a static member. - Replace the multiple constructors with one with default arguments. * include/abg-workers.h (workers::task): move entire implementation to header and drop superfluous forward declaration. * src/abg-workers.cc (workers::task):: Likewise. (workers::queue::priv): Drop queue_cond_mutex, rename queue_cond to tasks_todo_cond, add task_done_cond, make default_notify static. (workers::queue::priv::priv): Add default arguments to fully qualified constructor, drop the remaining ones. (workers::queue:prive::more_tasks_to_execute): Drop method. (workers::queue:prive::schedule_task): Do not synchronize access to the queue condition variable, but only on the mutex. (do_bring_workers_down): Likewise. Also await tasks_done to be empty. (workers::queue:prive::worker::wait_to_execute_a_task): Await tasks on the tasks_todo with tasks_todo_(cond|mutex) and signal task completion to tasks_done_cond. Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Matthias Maennich
|
48c8da31c0 |
abg-fwd: drop duplicate forward declaration for corpus_sptr
This declaration has already been done some lines above. Drop the duplicate. * include/abg-fwd.h: drop superfluous forward declaration. Signed-off-by: Matthias Maennich <maennich@google.com> |
||
Matthias Maennich
|
fe214f0f70 |
Fix / add include guards
Fix the include guards of abg-dwarf-reader.h and abg-reporter-priv.h by moving them before any other includes where they actually belongs. Add missing include guards for abg-libxml-utils.h and abg-libzip-utils.h. * include/abg-dwarf-reader.h: Move include guard to the beginning. * include/abg-reporter-priv.h: Likewise. * include/abg-libxml-utils.h: Add include guard. * include/abg-libzip-utils.h: Likewise. Signed-off-by: Matthias Maennich <maennich@google.com> |
||
Matthias Maennich
|
9ab71105eb |
KMI Whitelists: Drop old whitelist extraction methods
The previous commit introduces a new (tested) way of creating function and variable suppressions from multiple whitelist definitions. Migrate to this new way of processing KMI whitelists. * include/abg-tools-utils.h (gen_suppr_spec_from_kernel_abi_whitelist): Delete declaration. * src/abg-tools-utils.cc (gen_suppr_spec_from_kernel_abi_whitelist): Delete definition and migrate users to gen_suppr_spec_from_kernel_abi_whitelists. * tools/abidiff.cc (set_suppressions): Migrate from using gen_suppr_spec_from_kernel_abi_whitelist to gen_suppr_spec_from_kernel_abi_whitelists. * tools/abidw.cc (set_suppressions): Likewise. * tools/abipkgdiff.cc: Drop unused using definition. * tools/kmidiff.cc: Likewise. Reviewed-by: Dodji Seketeli <dodji@seketeli.org> Signed-off-by: Matthias Maennich <maennich@google.com> |
||
Matthias Maennich
|
4ecde9a800 |
KMI Whitelists: Add functionality to make whitelists additive
If multiple KMI whitelists are specified, either by passing --kmi-whitelist several times or by having multiple whitelist sections in the whitelist files, the generated suppressions are created as an intersection of symbols. That is rather unusual, as whitelisting should rather work additive. That means that the symbols (or expressions thereof) defined across several sections or files shall be considered a union of symbols. This patch combines the whitelist parsing to create exactly one function_suppression and one variable suppression. A test case has been added to ensure the functionality is working. Please note, migrating the existing code to this new functionality is done in a separate commit. * include/abg-tools-utils.h (gen_suppr_spec_from_kernel_abi_whitelists): New function. * src/abg-tools-utils.cc (gen_suppr_spec_from_kernel_abi_whitelists): Likewise. * tests/.gitignore: Ignore new test executable. * tests/Makefile.am: Add new test executable. * tests/data/test-kmi-whitelist/whitelist-with-another-single-entry: New test input file. * tests/data/test-kmi-whitelist/whitelist-with-duplicate-entry: Likewise. * tests/data/test-kmi-whitelist/whitelist-with-single-entry: Likewise. * tests/data/test-kmi-whitelist/whitelist-with-two-sections: Likewise. * tests/data/Makefile.am: Add above test material. * tests/test-kmi-whitelist.cc: Add new test executable. Reviewed-by: Dodji Seketeli <dodji@seketeli.org> Signed-off-by: Matthias Maennich <maennich@google.com> |
||
Matthias Maennich
|
ade58f9c49 |
Add (undocumented) support for version suffixes
Allow appending arbitrary text to the libabigail version string representation. That is useful to identify custom versions of the library (e.g. development versions or versions of a particular origin). The feature can be enabled by passing VERSION_SUFFIX to `configure`, e.g. $ configure VERSION_SUFFIX="-dev" That will extend the version string to (currently) 1.7.0-dev. The behaviour before this patch remains the default behaviour of not appending any additional text. The feature stays intentionally undocumented as the main release of libabigail will usually not carry a version suffix. * configure.ac: add substitution for VERSION_SUFFIX * include/abg-version.h.in: add define for ABIGAIL_VERSION_SUFFIX * include/abg-config.h(abigail_get_library_version): add support for a version suffix * src/abg-config.cc(abigail_get_library_version): Likewise. * src/abg-tools-utils.cc(get_library_version_string): Likewise. Reviewed-by: Dodji Seketeli <dodji@seketeli.org> Signed-off-by: Matthias Maennich <maennich@google.com> |
||
Dodji Seketeli
|
c32b8ec9f3 |
Bug 24690 - Support comparing non-reachable types of a binary
This patch adds the ability to compare all types of a binary, including those types that are not reachable from global functions and variables. This implies that for types that are not reachable from public interfaces, we want compare them against each others directly, without first comparing global functions/variables and walking the graph of reachable types from there. The patch adds the --non-reachable-types option to abidiff and abipkgdiff, instructing them to also compare types that are non-reachable from global variables and functions. Using that option, for instance, here is what the summary of abipkgdiff now looks like, in the test case attached added by this patch: ================ changes of 'libflatpak.so.0.10204.0'=============== Functions changes summary: 0 Removed, 0 Changed (16 filtered out), 16 Added functions Variables changes summary: 0 Removed, 0 Changed, 0 Added variable Unreachable types summary: 3 removed (2 filtered out), 1 changed (15 filtered out), 3 added (1 filtered out) types You can see that there is a new summary line which starts with the string: "Unreachable types summary:" Then in the body of the report, those unreachable types are reported separately. In practise, we want to limit the unreachable types to compare somehow, otherwise we'll end up comparing all the types of the types of the binary and that can be huge. So we want to limit the unreachable type analysis to types that are defined in public headers. So, for abipkgdiff, one can limit the analysis of non-reachable types to those defined in public headers by supplying the --devel{1,2} options that specifies the development packages that contain said public headers. For abidiff however, you'll want to use the --headers-dir{1,2} options for that. The patch comes with appropriate regression tests. * include/abg-comparison.h (string_type_base_sptr_map): Define new typedef. (diff_context::show_unreachable_types): Declare new member functions. (corpus_diff::{deleted_unreachable_types, deleted_unreachable_types_sorted, added_unreachable_types, added_unreachable_types_sorted, changed_unreachable_types, changed_unreachable_types_sorted}): Likewise. (maybe_report_unreachable_type_changes): Declare this function a friend of class corpus_diff. (corpus_diff::diff_stats::{num_added_unreachable_types, num_added_unreachable_types_filtered_out, net_num_added_unreachable_types, num_removed_unreachable_types, num_removed_unreachable_types_filtered_out, net_num_removed_unreachable_types, num_changed_unreachable_types, num_changed_unreachable_types_filtered_out, net_num_changed_unreachable_types}): Likewise. * src/abg-comparison-priv.h (diff_context::priv::show_unreachable_types_): Define new data member. (diff_context::priv::priv): Initialize the new data member. (diff_comp::operator()): Use pretty representation of diff subjects to sort them, rather than just their name. Also, add comment to the other member functions of diff_comp. (corpus_diff::{unreachable_types_edit_script_, deleted_unreachable_types_, deleted_unreachable_types_sorted_, suppressed_deleted_unreachable_types_, added_unreachable_types_, added_unreachable_types_sorted_, suppressed_added_unreachable_types_, changed_unreachable_types_, changed_unreachable_types_sorted_}): Define new data members. (corpus_diff::priv::apply_supprs_to_added_removed_fns_vars_unreachable_types): Changed the name of corpus_diff::priv::apply_suppressions_to_added_removed_fns_vars into this. (corpus_diff::priv::{added_unreachable_type_is_suppressed, deleted_unreachable_type_is_suppressed, changed_unreachable_types_sorted, count_unreachable_types}): Declare new member functions. (corpus_diff::diff_stats::priv::{num_added_unreachable_types, num_added_unreachable_types_filtered_out, num_removed_unreachable_types, num_removed_unreachable_types_filtered_out, num_changed_unreachable_types, num_changed_unreachable_types_filtered_out}): Define new data members. (sort_string_type_base_sptr_map): Declare new function. * src/abg-comparison.cc (sort_string_type_base_sptr_map) (diff_context::show_unreachable_types): Define new functions. (corpus_diff::diff_stats::{num_added_unreachable_types, num_added_unreachable_types_filtered_out, net_num_added_unreachable_types, net_num_removed_unreachable_types, num_removed_unreachable_types_filtered_out, num_removed_unreachable_types}): Define new member functions. (diff_maps::insert_diff_node): Do not update the map "diff -> impacted interfaces" if the current impacted interface is nil. This happens if we are looking at a diff node for a change on a type that is not reachable from any interfaces. (corpus_diff::priv::ensure_lookup_tables_populated): Handle the edit script for unreachable types. (corpus_diff::priv::apply_supprs_to_added_removed_fns_vars_unreachable_types): Rename corpus_diff::priv::apply_suppressions_to_added_removed_fns_vars into this. Apply suppression specifications to added and removed unreachable types as well. (corpus_diff::priv::{added,deleted}_unreachable_type_is_suppressed): Define new member functions. (corpus_diff::priv::{count_unreachable_types, changed_unreachable_types_sorted}): Likewise. (corpus_diff::priv::apply_filters_and_compute_diff_stats): Update statistics (including walking changed unreachable types to apply categorization and redundancy filters to them) related to unreachable types. (corpus_diff::priv::emit_diff_stats): Emit diff stats related to unreachable types. (corpus_diff::priv::maybe_dump_diff_tree): Dump diff tree nodes related to unreachable types. (corpus_diff::{deleted_unreachable_types, deleted_unreachable_types_sorted, added_unreachable_types, added_unreachable_types_sorted, changed_unreachable_types, changed_unreachable_types_sorted): Define new member functions. (corpus_diff::has_changes): Take deleted/added/changed unreachable types into account. (corpus_diff::has_incompatible_changes): Take net removed/changed unreachable types into account. (corpus_diff::has_net_subtype_changes): Take net removed and changed unreachable types into account. (corpus_diff::has_net_changes): Take net removed/added/changed unreachable types into account. (corpus_diff::traverse): When traversing the components of a corpus_diff node, make sure to traverse the changed unreachable types of the corpus. (leaf_diff_node_marker_visitor::visit_begin): Arrange for the fact that the current topmost interface can be nil if we are looking at types not reachable from global functions/variables. Also, make sure that only leaf nodes that are reachable from a global function/variable are recorded as leaf nodes. (compute_diff): In the overload for corpus_sptr, compute the changes between types not reachable from global functions and variables, if the user wishes that we do so. Also, add more comments. (apply_suppressions): Update for the name change of the function apply_suppressions_to_added_removed_fns_vars to apply_supprs_to_added_removed_fns_vars_unreachable_types. * include/abg-corpus.h (corpus::{record_type_as_reachable_from_public_interfaces, type_is_reachable_from_public_interfaces, get_types_not_reachable_from_public_interfaces}): Declare new member functions. (corpus::recording_types_reachable_from_public_interface_supported): Declare new virtual member function. (corpus_group::get_public_types_pretty_representations): Declare new member functons. (corpus_group::recording_types_reachable_from_public_interface_supported): Declare new virtual member function. * src/abg-corpus-priv.h (corpus::priv::{types_not_reachable_from_pub_ifaces_, pub_type_pretty_reprs_}): Define new data members. (corpus::priv::priv): Initialize the pub_type_pretty_reprs_ data member because it's a pointer. (corpus::priv::get_public_types_pretty_representations): Declare new member function. (corpus::priv::~priv): Declare a destructor. * src/abg-corpus.cc (corpus::priv::get_public_types_pretty_representations): Define new member function. (corpus::priv::~priv): Define new destructor to delete the new pub_type_pretty_reprs_ member pointer. (corpus::{record_type_as_reachable_from_public_interfaces, type_is_reachable_from_public_interfaces, get_types_not_reachable_from_public_interfaces, recording_types_reachable_from_public_interface_supported}): Define new member functions (corpus_group::get_public_types_pretty_representations): Likewise. * include/abg-diff-utils.h (struct deep_ptr_eq_functor): Document the equality operator. Also, add an overload to the equality operator, for weak_ptr<T>. The existing equality operator overload was just for shared_ptr<T>. * include/abg-fwd.h (is_user_defined_type): Declare function. * include/abg-ir.h (operator!=(const decl_base_sptr&, const decl_base_sptr&)): Declare new operator. (type_maps::get_types_sorted_by_name): Declare new member function. (decl_base::{g,s}et_is_artificial): Declare new member function. (function_decl::parameter::{g,s}et_artificial): Remove these member functions. * src/abg-ir.cc (operator!=(const decl_base_sptr&, const decl_base_sptr&)): Define new operator. (decl_base::priv::is_artificial_): Define new data member. (type_maps::priv::sorted_types_): Define new data member. (struct type_name_comp): Define new comparison functor to sort types based on their pretty representations. (decl_base::priv::priv): Initialize it. (decl_base::{g,s}et_is_artificial): Define new member functions. (type_maps::get_types_sorted_by_name): Define new member function. (is_user_defined_type): Define new function overloads. (strip_typedef, function_type::{function_type, set_parameters}): Adjust using decl_base::get_is_artificial rather than function_decl::parameter::get_artificial. (function_decl::parameter::priv::artificial_): Remove this data member. (function_decl::parameter::priv::priv): Adjust to the removal of function_decl::parameter::priv::artificial_. This constructor does not take an "is_artificial" flag anymore. (function_decl::parameter::parameter): Adjust to the removal of the is_artificial flag from the arguments of the constructor of function_decl::parameter::parameter::priv. (function_decl::parameter::get_artificial): Remove this member function. * src/abg-reporter-priv.h (maybe_report_unreachable_type_changes): Declare new function. * src/abg-reporter-priv.cc (maybe_report_unreachable_type_changes): Define new function. * src/abg-default-reporter.cc (default_reporter::report): In the overload for corpus_diff&, report added/removed/changed types that are not reachable from global functions and variables using the new function maybe_report_unreachable_type_changes. * src/abg-leaf-reporter.cc (leaf_reporter::report): In the overload for corpus_diff, report changes to types unreachable from global functions or variables, using the new function maybe_report_unreachable_type_changes. * src/abg-dwarf-reader.cc (build_ir_node_from_die): When the user requests that all types be loaded, record relevant types as reachable from global functions and variables. (build_enum_type, add_or_update_class_type) (add_or_update_union_type): Read the 'is-artificial' DWARF attribute and set the corresponding decl_base property accordingly. (finish_member_function_reading, strip_typedef) (function_type::function_type): Adjust using decl_base::get_is_artificial, rather than function_decl::parameter::get_artificial. * include/abg-reader.h (consider_types_not_reachable_from_public_interfaces): Declare new function. * src/abg-reader.cc (read_context::m_tracking_non_reachable_types): Add new data member. (read_context::read_context): Initialize it. (read_context::tracking_non_reachable_types): Define accessors for the new data member above. (read_is_declaration_only): Re-indent. (read_is_artificial): Define new helper function. (build_function_parameter): Use the new read_is_artificial function here, rather than open-coding it. (build_enum_type_decl, build_class_decl, build_union_decl): Support reading the 'is-artificial' property by using the new read_is_artificial function. (read_corpus_from_input): If the user wants us to take non-reachable types into account, then make sure we do so. (read_tracking_non_reachable_types, read_is_non_reachable_type): Define new static functions. (handle_element_node, build_type): Read the "is-non-reachable" attribute on type element nodes if the user wants us to track non-reachable types. (consider_types_not_reachable_from_public_interfaces): Define new function. * src/abg-writer.cc (write_is_artificial): Define new static helper function. (annotate): Adjust using decl_base::get_is_artificial rather than function_decl::parameter::get_artificial. (write_enum_type_decl, write_class_decl_opening_tag) (write_union_decl_opening_tag): Support writing the "is-artificial" property, using the new write_is_artificial function. (write_function_type): Adjust this to use the new write_is_artificial rather than open-coding writing the 'is-artificial' attribute. (write_is_non_reachable) (write_tracking_non_reachable_types): Define new static functions. (write_enum_type_decl, write_class_decl_opening_tag) (write_union_decl_opening_tag): Write the 'is-no-reachable' attribute when applicable. (write_corpus, write_corpus_group): Write the 'tracking-non-reachable-types' attribute when applicable. * tools/abidiff.cc (options::options): Initialize ... (options::show_all_types): ... new data member. (display_usage): Add help string from the new --non-reachable-types option. (parse_command_line): Parse the new --non-reachable-types option. (set_diff_context_from_opts): Set the dwarf_reader::read_context::show_unreachable_types property. (set_native_xml_reader_options): Define new static function. (main): Load all types when analyzing the DWARF or the ABIXML files, if the user wants us to do so. * tools/abipkgdiff.cc (options::show_all_types): Define new data member. (options::options): Initialize it. (parse_command_line): Parse the --non-reachable-types option to set the options::show_all_types data member. (display_usage): Add a help string for the new --non-reachable-types option. (set_diff_context_from_opts): Set the dwarf_reader::read_context::show_unreachable_types property based on the options::show_all_type data member. (compare): Configure the read context to load all types while analyzing the DWARF info, depending on the options::show_all_type data member. * doc/manuals/abidiff.rst: Document the new --non-reachable-types option added to abidiff above. * doc/manuals/abipkgdiff.rst: Add documentation for the --non-reachable-types option. * tests/data/test-diff-suppr/test47-non-reachable-types-v{0,1}.c: Source code files of test binary input. * tests/data/test-diff-suppr/test47-non-reachable-types-suppr-{1,2,3,4,5}.txt: New test input files. * tests/data/test-diff-suppr/test47-non-reachable-types-report-{1,2,3,4,5,6,7,8,9,10}.txt: New test reference output files. * tests/data/test-diff-suppr/test47-non-reachable-types-v{0,1}.o.alltypes.abixml: New test input abixml. * tests/data/Makefile.am: Add the new test material to source distribution. * tests/test-diff-suppr.cc (in_out_specs): Add the new tests above to this test harness. * tests/data/test-abidiff/test-struct1-report.txt: Adjust. * tests/data/test-diff-pkg/PR24690/flatpak-debuginfo-1.2.4-3.fc30.x86_64.rpm: New input binary RPM. * tests/data/test-diff-pkg/PR24690/flatpak-debuginfo-1.4.0-1.fc30.x86_64.rpm: Likewise. * tests/data/test-diff-pkg/PR24690/flatpak-devel-1.2.4-3.fc30.x86_64.rpm: Likewise. * tests/data/test-diff-pkg/PR24690/flatpak-devel-1.4.0-1.fc30.x86_64.rpm: Likewise. * tests/data/test-diff-pkg/PR24690/flatpak-libs-1.2.4-3.fc30.x86_64.rpm: Likewise. * tests/data/test-diff-pkg/PR24690/flatpak-libs-1.4.0-1.fc30.x86_64.rpm: Likewise. * tests/data/test-diff-pkg/PR24690/flatpak-libs-debuginfo-1.2.4-3.fc30.x86_64.rpm: Likewise. * tests/data/test-diff-pkg/PR24690/flatpak-libs-debuginfo-1.4.0-1.fc30.x86_64.rpm: Likewise. * tests/data/test-diff-pkg/PR24690/PR24690-report-0.txt: New test reference output. * tests/data/Makefile.am: Add the new test material above to source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add the new test material above to this test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
847800d497 |
Bug 25128 - Handle decl-only classes that differ only in size
Because DWARF sometimes emit decl-only classes (real one, with no members) with a size property, and the rest of the time, would emit the same decl-only class without a size property, comparing the two might yield some false positives. This patch handles those beasts when comparing classes. * include/abg-comp-filter.h (is_decl_only_class_with_size_change): Declare an overload. * include/abg-fwd.h (look_through_decl_only_class): Declare an overload. * src/abg-comp-filter.cc (is_decl_only_class_with_size_change): Define an overload that takes class_or_union& type. Re-write the previous overload in terms of this new one. * src/abg-ir.cc (look_through_decl_only_class): Define a new overload that takes a class_or_union&. Rewrite the previous overload in terms of this one. (equals): In the overload for class_or_union&, use is_decl_only_class_with_size_change to detect cases of decl-only classes that differ only by their size attribute and avoid comparing them. * tests/data/test-annotate/test21-pr19092.so.abi: Adjust. * tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise. * tests/data/test-diff-filter/test41-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
1f4dbe3515 |
Bug 25128 - Leaf diff reporter shouldn't compare decl-only classes
The leaf_diff_node_marker_visitor pass which collects leaf diff nodes for the leaf diff reporter considers bogus decl-only classes (that have the is-declaration-only flag set, are empty, and yet have a non-nil size property) originated from bogus DWARF. The leaf reporter thus potentially reports size changes among decl-only classes, which does not make sense. Two decl-only classes of the same name should always be considered equal, in this context. This patch thus teaches the leaf_diff_node_marker_visitor to avoid collecting a leaf diff node that is about a size change on a true decl-only class. * include/abg-comp-filter.h (is_decl_only_class_with_size_change): Declare new function. * src/abg-comp-filter.cc (is_decl_only_class_with_size_change): Define new function. * src/abg-comparison.cc (leaf_diff_node_marker_visitor::visit_begin): Use the newly defined is_decl_only_class_with_size_change above to ignore bogus decl-only classes with a size change. * tests/data/test-diff-suppr/test45-abi-report-1.txt: New test input. * tests/data/test-diff-suppr/test45-abi-wl.xml: Likewise. * tests/data/test-diff-suppr/test45-abi.xml: Likewise. * tests/data/test-diff-suppr/test45-abi.suppr.txt: New reference output for the test input above. * tests/data/test-diff-suppr/test46-PR25128-base.xml: New test input. * tests/data/test-diff-suppr/test46-PR25128-new.xml: Likewise. * tests/data/test-diff-suppr/test46-PR25128-report-1.txt: New reference input for the test input above. * tests/data/Makefile.am: Add the new test material to source distribution. * tests/test-diff-suppr.cc (in_out_spec): Add the new test input above to this test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
b00976517f |
Support symbol_name_not_regexp in [suppress_{function, variable}]
In the suppress_function and suppress_variable directives of the suppression specification language, we lack the 'symbol_name_not_regexp' properties, that would allow users to specify which (function/variable) symbols to *keep* as opposed to specifying which symbols to suppress. This patch adds that feature. That will later allow us to make the linux kernel symbol white lists[1] functionality use this feature; that is, upon analysing the content of a kernel symbol whitelist which lists a symbol named "foo", Libabigail would automatically generate a suppression specification which contains, e.g a 'suppress_function" directive that has this new 'symbol_name_not_regexp' property which value is set to "foo". Note that the patch makes sure that feature is supported when analyzing both abixml and DWARF formats. [1]: You can learn about what a Linux Kernel symbols white list is by reading about it at https://sourceware.org/libabigail/manual/kmidiff.html#environment. * doc/manuals/libabigail-concepts.rst: Document the new symbol_name_not_regexp properties for the suppress_{function,variable} directives. * include/abg-suppression.h ({function,variable}_suppression::{g,s}et_symbol_name_not_regex_str): Declare new member functions. * src/abg-dwarf-reader.cc (read_context::is_elf_symbol_suppressed): Define new member functions. (read_context::{load_symbol_maps_from_symtab_section, populate_symbol_map_from_ksymtab, populate_symbol_map_from_ksymtab_reloc}): Drop suppressed symbols when reading symbol tables. ({function,variable}_is_suppressed): Consider that in C, the linkage name is _by default_ the same as the function/variable name. Remove local variable. * include/abg-ir.h (elf_symbol_is_{function,variable}): Add ... * src/abg-ir.cc (elf_symbol_is_{function,variable}): ... new functions. * src/abg-reader.cc (build_elf_symbol): Take an additional boolean to detect and drop suppressed symbols. (build_elf_symbol_db): Adjust the call to build_elf_symbol to make it detect and drop suppressed symbols. (read_corpus_from_input): Be mindful that the set of symbols for a given corpus can be empty because of suppression specifications. * src/abg-suppression-priv.h ({function,variable}_suppression::priv::symbol_name_not_regex[_str_]): Add new data members. (function,variable}_suppression::priv::get_symbol_name_not_regex): Add new member functions. ({function,variable}_is_suppressed): Guard against empty name. (is_elf_symbol_suppressed): Define new function template. * src/abg-suppression.cc ({function,variable}_suppression::{g,s}et_symbol_name_not_regex_str): Define new member functions. ({function,variable}_suppression::suppresses_function) (suppression_matches_{function,variable}_sym_name) (read_{function,variable}_suppression): Support the new "symbol_name_not_regex" property. * tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp-report-1.txt: New test reference report. * tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp-report-2.txt: Likewise. * tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp-v{0,1}.c: Sources of the new test input. * tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp-v{0,1}.o: New test input binaries. * tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp-v{0,1}.o.abi: New test input abixml files. * tests/data/test-diff-suppr/test44-suppr-sym-name-not-regexp.suppr.txt: Next test suppression specification. * tests/data/Makefile.am: Add the new test material above to source distribution. * tests/test-diff-suppr.cc (in_out_specs): Add the input tests above to the test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
d2c88645e8 |
Support the "name_not_regexp" property in the [suppress_type] section
When writting a suppression specification in which the user wants to keep a family of types (whose names set is specified by a regular expression) and suppress/drop all other types, one needs to write something like: [suppress_type] name_regexp = (?!the-regexp-of-the-types-to-keep) It would be nicer (like what is done for other properties that take regular expressions as value in suppression specifications) to be able to write: [suppress_type] name_not_regexp = the-regexp-of-types-to-keep This patch does just that. It augments the abigail::suppr::type_suppression type to make it carry the new 'name_not_regex' property. It updates the suppression engine to take the 'name_not_regex' property into account when interpreting instances of abigail::suppr::type_suppression. The parser for type suppression directives is updated to recognize the new name_not_regexp property. The manual has been updated accordingly to describe the new property. New regression tests have been added. * doc/manuals/libabigail-concepts.rst: Update this to document the new name_not_regexp property of the suppress_type directive. * include/abg-suppression.h (type_suppression::{g,s}et_type_name_not_regex_str): Declare new accessors. * src/abg-suppression-priv.h (type_suppression::priv::{type_name_not_regex_str_, type_name_not_regex_}): Define new data members. (type_suppression::priv::{get_type_name_not_regex, set_type_name_not_regex, get_type_name_not_regex_str, set_type_name_not_regex_str}): Define new member functions. * src/abg-suppression.cc (type_suppression::get_type_name_regex_str): Fix comments. (type_suppression::{set_type_name_not_regex_str, get_type_name_not_regex_str}): Define new data members. (suppression_matches_type_name): Adapt to support the new type_name_not_regex property. (read_type_suppression): Support parsing the type_name_not_regexp property. * tests/data/test-diff-suppr/test42-negative-suppr-type-report-0.txt: New test reference output. * tests/data/test-diff-suppr/test42-negative-suppr-type-report-1.txt: Likewise. * tests/data/test-diff-suppr/test42-negative-suppr-type-suppr-1.txt: New test input. * tests/data/test-diff-suppr/test42-negative-suppr-type-suppr-2.txt: Likewise. * tests/data/test-diff-suppr/test42-negative-suppr-type-v0.{cc, o}: Likewise. * tests/data/test-diff-suppr/test42-negative-suppr-type-v1.{cc, o}: Likewise. * tests/data/Makefile.am: Add the test files above to source distribution. * tests/test-diff-suppr.cc (int_out_specs): Add the new tests to the harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
ed9492065e |
Remove the elf_symbol::get_value property
Now that there are proper facilities to lookup ELF symbols inside the ELF/DWARF reader and get a native GElf_Sym type instance (from libelf), we don't need to carry the value of the symbol (that is relevant only that low level anyway) in the abigail::ir::elf_symbol type. This patch removes that property. * include/abg-ir.h (elf_symbol::{elf_symbol, create}): Remove the 'val' parameter. * src/abg-dwarf-reader.cc (elf_symbol::get_value): Remove this member function declaration. (lookup_symbol_from_sysv_hash_tab) (lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_symtab) (create_default_var_sym, create_default_fn_sym) (read_context::lookup_elf_symbol_from_index): Adjust calls to creating elf_symbol instances. * src/abg-ir.cc (elf_symbol::priv::value_): Remove this data member. (elf_symbol::{priv::priv, elf_symbol, create): Adjust. * src/abg-reader.cc (build_elf_symbol): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Jessica Yu
|
e6870326e0 |
Support pre and post v4.19 ksymtabs for Linux kernel modules
As described in commit
|
||
Dodji Seketeli
|
bc2d2ce660 |
Serialize canonical types to avoid testing if types have been emitted
When emitting abixml, profiling shows that we spend a great deal of time testing if a given type has been emitted already, to avoid emitting a given type more than once. This makes the serialization phase take more time than the binary analysis phase! This patch leverages the fact that we already have the set of canonical types in the system. While emitting that set entirely, we don't need to test if a type has been emitted already because we know by definition that every type is present just once in that set, more or less. OK, because there are also types that don't have canonical types (for instance, declaration-only class/structs), we'll still have to check of those types have already been emitted, but this is a very small set to handle. The patch thus organizes the canonical types per scope, so that when emitting a scope and the canonical types within it, the type is emitted in its correct namespace. Then, when emitting a translation unit and each namespaces in it, the patch emits the canonical types of those namespaces. The patch arranges for some ancillary things that are needed to make the whole picture be coherent enough for things to keep working. Testing shows that we gained ~ 30% of performance by doing this, while analysing the whole linux kernel 5.1 version. We went from ~ 3m30s minutes to less than 2m30s. With this patch, the serialization phase now takes less time than the analysis time. * include/abg-fwd.h (is_decl_slow) (peel_pointer_or_reference_type): Declare new functions. * include/abg-ir.h (struct canonical_type_hash): Define new type. (type_base_ptr_set_type, type_base_ptrs_type) (type_base_sptrs_type, canonical_type_sptr_set_type): Define new typedefs. (environment::get_canonical_types_map): Declare new member function. (scope_decl::{get_canonical_types, get_sorted_canonical_types}): Declare new member functions. * src/abg-ir.cc (is_ptr_ref_or_qual_type) (peel_pointer_or_reference_type, is_decl_slow): Define new functions. (environment::{get_canonical_types_map}): Define new member functions. (canonical_type_hash::operator()): Likewise. (scope_decl::{get_canonical_types, get_sorted_canonical_types}): Likewise. (struct type_topo_comp): Define new comparison functor type. (environment::{sorted_canonical_types_}): Define new data member. (scope_decl::priv::{canonical_types_, sorted_canonical_types_}): Likewise. (scope_decl::is_empty): Take the presence of canonical types into account when determining if a scope is empty or not. (is_decl): Make this work for cases where the artifact at hand is a type which has a declaration, as opposed to being a pure declaration like a variable or a function. (canonicalize): Add the canonical type the list of canonical types of its scope. * src/abg-dwarf-reader.cc (read_context::die_is_in_cplus_plus): Define new member function. * src/abg-writer.cc (write_type, write_canonical_types_of_scope): Define new static functions. (fn_type_ptr_set_type): Define new typedef. (write_context::{m_referenced_fn_types_set, m_referenced_non_canonical_types_set}): Add new data members. (write_context::m_referenced_types_set): Renamed m_referenced_types_map into this. (write_context::get_referenced_types): Adjust. (write_context::get_referenced_{function_types, non_canonical_types}): (write_context::record_type_as_referenced): Adjust to add the referenced type in the proper set which would be one of the three following: write_context::{get_referenced_types, get_referenced_function_types, get_referenced_non_canonical_types}. (write_context::{type_is_referenced, clear_referenced}): Adjust. (write_translation_unit): Use the new write_canonical_types_of_scope. Also emit declaration-only classes that have member types. Do not test if a given type of a given scope has been emitted, in general, as this was super slow given the number of types. Emit referenced function types (as these don't belong to any scope). Rather than using the expensive "is_function_type" on *all* the referenced types, just walk the set write_context::get_referenced_function_types. Likewise, rather than using type_base::get_naked_canonical_type on *all* the referenced types, just walk the set write_context::get_referenced_non_canonical_types (write_class): Use write_canonical_types_of_scope here. * tools/abilint.cc (main): Support linting corpus group abixml files. * tests/data/test-annotate/libtest23.so.abi: Adjust. * tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise. * tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise. * tests/data/test-annotate/test-anonymous-members-0.o.abi: Likewise. * tests/data/test-annotate/test0.abi: Likewise. * tests/data/test-annotate/test1.abi: Likewise. * tests/data/test-annotate/test13-pr18894.so.abi: Likewise. * 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/test2.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-annotate/test4.so.abi: Likewise. * tests/data/test-annotate/test6.so.abi: Likewise. * tests/data/test-annotate/test7.so.abi: Likewise. * tests/data/test-annotate/test8-qualified-this-pointer.so.abi: Likewise. * tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Likewise. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise. * tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi: Likewise. * tests/data/test-read-dwarf/libtest23.so.abi: Likewise. * tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi: Likewise. * tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test1.abi: Likewise. * tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise. * tests/data/test-read-dwarf/test11-pr18828.so.abi: 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/test16-pr18904.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/test2.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/test4.so.abi: Likewise. * tests/data/test-read-dwarf/test6.so.abi: Likewise. * tests/data/test-read-dwarf/test7.so.abi: Likewise. * tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi: Likewise. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise. * tests/data/test-read-write/test10.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test15.xml: Likewise. * tests/data/test-read-write/test17.xml: Likewise. * tests/data/test-read-write/test18.xml: Likewise. * tests/data/test-read-write/test19.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test20.xml: Likewise. * tests/data/test-read-write/test21.xml: Likewise. * tests/data/test-read-write/test22.xml: Likewise. * tests/data/test-read-write/test23.xml: Likewise. * tests/data/test-read-write/test24.xml: Likewise. * tests/data/test-read-write/test25.xml: Likewise. * tests/data/test-read-write/test26.xml: Likewise. * tests/data/test-read-write/test27.xml: Likewise. * tests/data/test-read-write/test28-without-std-fns-ref.xml: Likewise. * tests/data/test-read-write/test28-without-std-vars-ref.xml: Likewise. * tests/data/test-read-write/test3.xml: Likewise. * tests/data/test-read-write/test6.xml: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
f2437aabad |
Bug 24787 - Filter out enum changes into compatible integer types
Libabigail's filtering engine fails to recognize an enum changing into a compatible integer (or vice versa) as a harmless change. This patch fixes that. * include/abg-comparison.h (peel_typedef_or_qualified_type_diff): Declare new function. (peel_pointer_or_qualified_type_diff): Rename peel_pointer_or_qualified_type into this. * include/abg-fwd.h (is_enum_type): Declare a new overload for type_or_decl_base*. * src/abg-comp-filter.cc (has_harmless_enum_to_int_change): Define new static function. * src/abg-comparison.cc (categorize_harmless_diff_node): Use the new has_harmless_enum_to_int_change here. (peel_pointer_or_qualified_type_diff): Renamed peel_pointer_or_qualified_type into this. (is_diff_of_basic_type): Adjust. (peel_typedef_or_qualified_type_diff): Define new function. * test-diff-filter/PR24787-lib{one, two}.so: New test input binaries. * test-diff-filter/PR24787-{one, two}.c: Source files of the test input binaries above. * test-diff-filter/PR24787-report-0.txt: Test output reference. * tests/data/Makefile.am: Add the new testing material to source distribution. * tests/test-diff-filter.cc (in_out_specs): Add the new test to the test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
3df54522b8 |
Add timing to the verbose logs of abidw
While doing my recent optimization work, it became useful to have an idea of the time different parts of the processing pipeline are taking. This patch introduces an abigail::tools_utils::timer type that is easy to use to time a given part of the code and emit the elapsed time to an output stream. This abigail::tools_utils::timer type is thus used to time various parts of the processing pipeline involved in abidw. Just using the existing --verbose option now yields timing information. * include/abg-tools-utils.h (class timer): Declare new type. (operator<<(ostream&, const timer&)): Declare new streaming operator for the new timer type. * src/abg-tools-utils.cc (struct timer::priv): Define new type. (timer::{timer, start, stop, value_in_seconds, value, value_as_string, ~timer}): Define member functions. (operator<<(ostream& o, const timer& t)): Define streaming operator. (build_corpus_group_from_kernel_dist_under): Add timing logs to the linux kernel reading process. * src/abg-dwarf-reader.cc (read_context::canonicalize_types_scheduled): Add timing logs to type canonicalization. (read_debug_info_into_corpus): Add timing logs for the whole debug info loading and internal representation building process. * tools/abidw.cc (load_corpus_and_write_abixml): Add timing logs for the binary loading and serizalization process. (load_kernel_corpus_group_and_write_abixml): Add timing logs the Linux Kernel binary loading and writing process. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
400ac7a412 |
Implement fast comparison of Linux Kernel types when applicable
During type canonicalization there are observations that can speed-up type comparison significantly without impacting correctness too much. Typically, when two types are of the same name and kind, are found in the same corpus and are defined in the same translation unit, they ought to be the same type, even in C. So there is no need in this case to actually perform the structural comparison of the two types which does have a quadratic performance at best. Using this optimization made the loading of the drivers/gpu/drm/i915/i915.ko module go from a quasi inifite time (many hours on my system) to less than two minutes. I am confining this optimization to the Linux kernel case only for now, but I believe it could benefit all C programs. I am waiting for more testing before applying it more broadly. Also, while looking at this, I noticed that when loading several corpora into a given corpus group (i.e, loading several linux kernel binaries to represent a single conceptual kernel), we sometimes fail to recognize that a type defined in a header file that is included in several corpora is actually the same type, and should be re-used, rather than being re-defined in each corpus. This later adds stress (time and space) on the system as we need to canonicalize and de-duplicate these type later on. This is because the "per-corpus" type maps that we use to lookup a type by name and location when we see it (so that we know it's defined in a different corpus of our current group) should really be per-corpus-group type maps! That is a type can be defined in the corpus representing a .ko binary, and that type would be seen again in another .ko binary later. Until now, we were wrongly considering that types were to be first defined in the corpus of the vmlinux binary, and then could be re-used later. I have thus fixed the code so that whenever we add a type to its scope, the relevant per-corpus type maps are updated, as well as the per-corpus-group ones, so that we can later lookup types in those per-corpus-group type maps to know if a type is already defined in any corpus of the group. * include/abg-corpus.h (corpus::origin): Add a new LINUX_KERNEL_BINARY_ORIGIN enumerator. (corpus::{s,g}et_group): Declare new member functions. (class corpus): Make the corpus_group class friend of this one. (corpus_group::get_main_corpus): Declare new member function. * src/abg-corpus-priv.h (corpus::priv::group): Define new data member. (corpus::priv::priv): Initialize the new corpus::priv::group data member. * src/abg-corpus.cc (corpus::{g,s}et_group): Define new member functions. (corpus_group::get_main_corpus): Likewise. (corpus_group::add_corpus): Use the new corpus::set_group() here to to make the corpus be aware of the group it belongs to. * src/abg-dwarf-reader.cc (read_debug_info_into_corpus): Set the current corpus origin to the corpus::LINUX_KERNEL_BINARY_ORIGIN if we are looking at a Linux Kernel binary. (read_context::main_corpus_from_current_group): Use the corpus_group::get_main_corpus method. (should_reuse_type_from_corpus_group): Return the corpus group, rather than the main corpus. (read_debug_info_into_corpus): Add the current corpus to the current corpus group before the debug info reading is done. That way, the corpus group will be accessible from the current corpus during the construction of the internal representation. (read_and_add_corpus_to_group_from_elf): Add the corpus to the group only if it wasn't added to it before. * include/abg-ir.h (operator{==,!=}): Declare new deep equality and inequality operators for class_or_union_sptr and union_decl_sptr. * src/abg-ir.cc (types_defined_same_linux_kernel_corpus_public): Define a new static function. (type_base::get_canonical_type_for): Use the new types_defined_same_linux_kernel_corpus_public here to speed up type comparison. (equals): In the overload of class_or_union, use the new types_defined_same_linux_kernel_corpus_public as well, to speed up type comparison. (operator{==,!=}): Define new deep equality and inequality operators for class_or_union_sptr and union_decl_sptr. (maybe_update_types_lookup_map): In the overload function for type_decl_sptr, class_decl_sptr, union_decl_sptr, enum_type_decl_sptr, typedef_decl_sptr, qualified_type_def_sptr, reference_type_def_sptr, array_type_def_sptr, array_type_def::subrange_sptr, and function_type_sptr, update the type lookup maps of the containing corpus group as well, not just the ones of the current corpus. * src/abg-reader.cc (build_enum_type_decl): Forgot to set the "is-anonymous" flag. Oops, fix this. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Adjust. * tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust. * tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust. * tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Matthias Maennich
|
85f185a684 |
abg-tools-utils: add missing header include guards
* include/abg-tools-utils.h: add header include guards Signed-off-by: Matthias Maennich <maennich@google.com> |
||
Matthias Maennich
|
beededda29 |
Add compatibility layer for C++11 mode
Introduce a compatibility layer for C++11 code by adding include/abg-cxx-compat.h. abg-cxx-compat defines a new namespace abg_compat and defines abg_compat::hash abg_compat::shared_ptr abg_compat::weak_ptr abg_compat::dynamic_pointer_cast abg_compat::static_pointer_cast abg_compat::unordered_map abg_compat::unordered_set based on definitions from std::tr1 (std=gnu++98) or std:: (std=gnu++11). I decided for introducing abg_compat:: rather than polluting abigail:: to allow an easier transition to C++11 at a later time and to not subtly break existing code. As the shared_ptr in C++11 defines shared_ptr::operator bool() explicit, some locations where a shared_ptr is assigned to boolean, needed to be adjusted to explicitly cast to bool. * include/abg-cxx-compat.h: new file introducing the abg_compat namespace to provide C++11 functionality from either std::tr1 or std:: * include/Makefile.am: Add the new abg-cxx-compat.h to source distribution. * include/abg-comparison.h: replace std::tr1 usage by abg_compat and adjust includes accordingly: likewise * include/abg-diff-utils.h: likewise * include/abg-fwd.h: likewise * include/abg-ini.h: likewise * include/abg-interned-str.h: likewise * include/abg-ir.h: likewise * include/abg-libxml-utils.h: likewise * include/abg-libzip-utils.h: likewise * include/abg-reporter.h: likewise * include/abg-sptr-utils.h: likewise * include/abg-suppression.h: likewise * include/abg-tools-utils.h: likewise * include/abg-workers.h: likewise * src/abg-comp-filter.cc: likewise * src/abg-comparison-priv.h: likewise * src/abg-corpus.cc: likewise * src/abg-dwarf-reader.cc: likewise * src/abg-hash.cc: likewise * src/abg-ir.cc: likewise * src/abg-reader.cc: likewise * src/abg-suppression.cc: likewise * src/abg-tools-utils.cc: likewise * src/abg-writer.cc: likewise * tests/test-diff-filter.cc: likewise * tests/test-diff-pkg.cc: likewise * tests/test-read-dwarf.cc: likewise * tests/test-read-write.cc: likewise * tests/test-types-stability.cc: likewise * tests/test-write-read-archive.cc: likewise * tools/abicompat.cc: likewise * tools/abidiff.cc: likewise * tools/abidw.cc: likewise * tools/abilint.cc: likewise * tools/abipkgdiff.cc: likewise Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Matthias Maennich
|
42cd02a9be |
Drop requirement to compile with GNU extensions
__gnu_cxx::stdio_filebuf is a GNU extension only available in certain std libraries. It is not e.g. in libc++. In order to be able to compile with using libc++, replace the usage of __gnu_cxx::stdio_filebuf with standard C++ methods. In this case, reopen the temporary file with a std::fstream and expose that stream rather than the previously exposed std::iostream. * include/abg-tools-utils.h (get_stream): Change return type to std::fstream * src/abg-corpus.cc: remove unused #include of ext/stdio_filebuf.h * src/abg-tools-utils (temp_file::priv): remove filebuf_ member, and replace iostream_ by fstream_ with changing the shared_ptr type accordingly (temp_file::priv::priv): initialize fstream_ based on temporary file name (temp_file::priv::~priv): adjust destruction accordingly (temp_file::is_good): test the fstream rather than the fd (temp_file::get_stream): adjust return type to std::fstream and adjust implementation based on the changes in temp_file::priv * src/Makefile.am: remove gnu extension from c++ standard flag * tests/Makefile.am: likewise Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
65318dacfb |
[xml-writter] Avoid using RTTI when dynamically hashing types
When we dynamically hash types in the abixml writter, we use hash_type_or_decl. This function uses runtime type identification to determine if the (type) artifact is a decl or a type, and based on that, choose how to compute its hash value. Profiling shows that using the RTTI in hash_type_or_decl at this point is a hotspot. Because we know that the type ABI is a *type*, we obviously can avoid using RTTI there. The patch thus implements a hash_type function, and uses that in the xml writter. Emitting the abixml output is faster with this patch. * include/abg-fwd.h (hash_type): Declare new function. * src/abg-ir.cc (hash_type): Define new function. * src/abg-writer.cc (type_hasher::operator()): Use the new hash_type rather than the old hash_type_or_decl. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
c940a229c9 |
Implement a poor-man's RTTI for performance
Profiling showed that a number of use of dynamic_cast are a speed bottleneck. This patch implements a poor-man's RTTI that allows us to implement a form of dynamic_cast that is specific to the types of the internal reprenstation that are in the namespace abigail::ir. It speeds up things greatly. Basically, the base type of all ABI artifacts (abigail::ir::type_or_decl_base) now contains three new data members. The first one contains a bitmap that identifies the type of artifact. The second one contains a pointer to the dynamic type sub-object of the current instance of the artifact. The last one contains either a pointer to the type_base sub-object of the current instance of ABI artifact if it's a type, or a pointer to the type_decl sub-object of the current instance. Together these three data members allow the patch to implement the abigail::ir::{is_type(), is_decl(), is_<type_kind>_type} functions that we need to make the code base noticeably faster when using abidw on a big vmlinux binary. * include/abg-fwd.h (is_type_decl): Replace the overloads that takes a type_base* and/or a decl_base* by one that takes a type_or_decl_base*. * include/abg-ir.h (type_or_decl_base::type_or_decl_kind): Define new enum. (type_or_decl_base::{kind, runtime_type_instance, type_or_decl_base_pointer}): Declare new accessors. (operator{|,|=,&,&=): Declare new operators for the new type_or_decl_base::type_or_decl_kind enum. (global_scope::global_scope): Move the definition of this constructor to ... * src/abg-ir.cc (global_scope::global_scope): ... here. (type_or_decl_base::priv::{kind_, rtti_, type_or_decl_ptr_}): Add new data members. (type_or_decl_base::priv::priv): Take a type_or_decl_base::type_or_decl_kind enum. (type_or_decl_base::priv::kind): Define new accessors. (operator{|,|=,&,&=): Define new operators for the new type_or_decl_base::type_or_decl_kind enum. (type_or_decl_base::type_or_decl_base): Take a type_or_decl_base::type_or_decl_kind enum. (type_or_decl_base::{kind, runtime_type_instance, type_or_decl_base_pointer}): Define new accessors. (decl_base::decl_base, scope_decl::scope_decl) (type_base::type_base, scope_type_decl::scope_type_decl) (class_or_union::class_or_union) : Adjust to set the runtime type identifier of the instances of these types. (global_scope::global_scope, type_decl::type_decl) (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def array_type_def::subrange_type::subrange_type) (array_type_def::array_type_def, enum_type_decl::enum_type_decl) (typedef_decl::typedef_decl, var_decl::var_decl) (function_type::function_type, method_type::method_type) (function_decl::function_decl) (function_decl::parameter::parameter, method_decl::method_decl) (class_decl::class_decl, class_decl::base_spec::base_spec) (union_decl::union_decl, template_decl::template_decl) (type_tparameter::type_tparameter) (non_type_tparameter::non_type_tparameter) (template_tparameter::template_tparameter) (type_composition::type_composition) (function_tdecl::function_tdecl, function_tdecl::function_tdecl) (class_tdecl::class_tdecl): Likewise and call runtime_type_instance() here to set the runtime type instance pointers of the current instance. (is_decl, is_type, is_class_type, is_pointer_type): Adjust to use the new poor-man's rtti machinery. (is_type_decl): Replace the overloads that takes a type_base* and/or a decl_base* by one that takes a type_or_decl_base*. (pointer_type_def::operator==, class_decl::operator==): Use the poor-man's rtti machinery to replace dynamic_cast. hash_type_or_decl: Replace dynamic_cast<const type_base> by is_type() and dynamic_cast<const decl_base*> by is_decl(). Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
2209df1b90 |
Make abidiff --harmless show harmless changes in unions
Since the previous commit filters out harmless changes inside unions, this one allows those changes to be reported whenever the user runs abidiff with the --harmless option. The patch just displays the "before" and "after" of the union because some of the harmless changes are not tracked anymore. Because we want to display the before and after of the union we use the function get_class_or_union_flat_representation. The patch adds a "qualified_name" boolean parameter to that function so that we can choose to display union members names in a non-qualified fashion, which is the natural way of displaying those names in the context of a union (or class) representation. Because get_class_or_union_flat_representation uses type_or_decl_base::get_pretty_representation, the patch has also added a "qualified_name" boolean parameter to that function so that we can choose to display names in a non-qualified manner. * include/abg-fwd.h (get_class_or_union_flat_representation): Add a "qualified_name" boolean parameter. * include/abg-ir.h ({type_or_decl_base, decl_base, type_decl, namespace_decl, array_type_def::subrange_type, array_type_def, enum_type_decl, typedef_decl, var_decl, function_decl, function_decl::parameter, function_type, method_type, class_decl, union_decl}::get_pretty_representation): Likewise. * src/abg-ir.cc ({type_or_decl_base, decl_base, type_decl, namespace_decl, array_type_def::subrange_type, array_type_def, enum_type_decl, typedef_decl, var_decl, function_decl, function_decl::parameter, function_type, method_type, class_decl, union_decl, }::get_pretty_representation): Adjust the code to emit qualified or non-qualified names depending on the new "qualified_name" boolean parameter. (get_class_or_union_flat_representation): Likewise. * src/abg-default-reporter.cc (default_reporter::report): Use get_class_or_union_flat_representation with the new "qualified_name" boolean set to false. * tests/data/test-diff-dwarf/test38-union-report-0.txt: Adjust. * tests/test-diff-filter.cc (in_out_specs): Run the test harness on test-PR24731-v{0,1}.o make abidiff use the --harmless option. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
a11a0068ea |
Bug 24731 - Wrongly reporting union members order change
When union data members are re-ordered, abidiff reports the re-ordering as if it was a meaningful ABI change. This patch teaches Libabigail to categorize that benign type layout change as a HARMLESS_UNION_CHANGE_CATEGORY kind of change and ignore it. * include/abg-comp-filter.h (union_diff_has_harmless_changes): Declare new function and ... * src/abg-comp-filter.cc (union_diff_has_harmless_changes): ... define it here. (categorize_harmless_diff_node): Use the new union_diff_has_harmless_changes here. * include/abg-comparison.h (HARMLESS_UNION_CHANGE_CATEGORY): Add a new enumerator to diff_category enum. Adjust the value of the other enumerators. * src/abg-comparison.cc (get_default_harmless_categories_bitmap): Add the new HARMLESS_UNION_CHANGE_CATEGORY in here. (operator<<(ostream& o, diff_category c)): Support the new HARMLESS_UNION_CHANGE_CATEGORY. * tests/data/test-diff-filter/test-PR24731-report-0.txt: Likewise. * tests/data/test-diff-filter/test-PR24731-report-1.txt: Likewise. * tests/data/test-diff-filter/test-PR24731-v0.c: Likewise. * tests/data/test-diff-filter/test-PR24731-v0.o: Likewise. * tests/data/test-diff-filter/test-PR24731-v1.c: Likewise. * tests/data/test-diff-filter/test-PR24731-v1.o: Likewise. * tests/data/Makefile.am: Add the new test material above to source distribution. * tests/test-diff-filter.cc (in_out_spec): Add the new test input to this test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
bf100fcb41 |
Fully account for anonymous-ness of scopes when comparing decl names
When comparing internal decl names (as part of decl comparison), we need to take into account the fact that a given decl might be anonymous and that it might have anonymous scopes in its tree of containing scopes. For instance, "__anonymous_struct__1::foo" and "__anonymous_struct__2::foo" are considered equivalent. So are "__anonymous_struct__1::foo::__anonymous_struct__2::bar" and "__anonymous_struct__10::foo::__anonymous_struct__11::bar". But "__anonymous_struct__1::bar::__anonymous_struct__2::baz" and "__anonymous_struct__10::foo::__anonymous_struct__11::bar" are not. This patch introduces the function tools_utils::decl_names_equal that compares fully qualified names by taking into account anonymous component names. That function is thus used in the equals() function overload for decl_base types. Because tools_utils::decl_names_equal compares strings the usual way (character by character) it's slower than comparing instances of interned_string in a O(1) time. So the patch carefully tries to use tools_utils::decl_names_equal sparringly; that is, it uses it only when we are looking at decls that have some anonymous scope. That way, we use the fast interned_string comparison most of the time. By doing this, we barely see any performance degradation while running abidw --noout on a full blown vmlinux binary. * include/abg-ir.h (decl_base::{get_has_anonymous_parent, set_has_anonymous_parent, get_is_anonymous_or_has_anonymous_parent}): Declare new member functions. * src/abg-ir.cc (decl_base::priv::has_anonymous_parent_): Define new data member. (decl_base::priv): Initialize the new data member. (decl_base::{get_has_anonymous_parent, set_has_anonymous_parent, get_is_anonymous_or_has_anonymous_parent}): Define new member functions. (equals): In the overload for decl_base, use the new decl_names_equal for decls that have anonymous scopes. (scope_decl::add_member_decl): Propagate the decl_base::has_anonymous_parent_ property. * include/abg-tools-utils.h (get_anonymous_struct_internal_name_prefix) (get_anonymous_union_internal_name_prefix) (get_anonymous_enum_internal_name_prefix, decl_names_equal): Declare new functions. * src/abg-comp-filter.cc (has_harmless_name_change): Handle the case where the name change is actually from an anonymous name to another one, using the new decl_names_equal function. * src/abg-dwarf-reader.cc (get_internal_anonymous_die_prefix_name): Renamed get_internal_anonynous_die_base_name into this. Use the new get_anonymous_{struct, union, enum}_internal_name_prefix functions here. (get_internal_anonymous_die_name, die_qualified_type_name) (build_enum_type, add_or_update_class_type) (add_or_update_union_type): Adjust. * src/abg-tools-utils.cc (get_anonymous_struct_internal_name_prefix) (get_anonymous_union_internal_name_prefix) (get_anonymous_enum_internal_name_prefix, decl_names_equal): Define new functions. * tests/test-tools-utils.cc: New test file. * tests/Makefile.am: Add new runtesttoolsutils test, built from test-tools-utils.cc. * tests/data/test-diff-dwarf/test46-rust-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-3.txt: Likewise. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Matthias Maennich
|
2651a3623a |
abg-reporter.h: add missing includes / using declarations
In order to build this (external!) header file stand-alone, it required some minor fixes. I.e. adding some includes and using declarations. * include/abg-reporter.h: fix includes and using declarations Signed-off-by: Matthias Maennich <maennich@google.com> |
||
Dodji Seketeli
|
073608f47d |
Take anonymous scopes into account when comparing decls
This is another attempt at handling anonymous decls comparison. It's not the full blown method that I'd like, but this one seems to be fast enough. In this method, we take the immediate scope (and whether it's anonymous or not) of the anonymous decl into account. * include/abg-interned-str.h (interned_string::clear): Add new member function. * src/abg-ir.cc (equals): In the overload for decl_base, consider the scope of the current (anonymous) decl. If that scope is anonymous then take that into account as well. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt: Adjust. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Matthias Maennich
|
1e67db0797 |
abg-writer: drop deprecated API
Drop the deprecated overloads for write_translation_unit, write_corpus, write_corpus_group. Also remove the deprecation facilities as they are not used anymore. * include/abg-fwd.h (ABG_DEPRECATED): Remove this macro. * include/abg-writer.h (write_translation_unit, write_corpus) (write_corpus_group): Drop the deprecated overloads of these declarations. * src/abg-writer.cc (write_translation_unit, write_corpus) (write_corpus_group): Drop the deprecated overloads of these definitions. Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Matthias Maennich
|
f3f7537b6e |
abidw: add option to only emit file names (--short-locs)
Various emitted directories contain machine specific information and therefore break reproducibility of abidw's output across different build paths. Hence introduce --short-locs to only emit file names. Thanks to earlier changes, adding an option boils down to adding it to set_opts and to the write_context along with some auxiliary functions for setting and getting. * include/abg-writer.h (set_short_locs): Declare new function. (set_common_options): Use it. set_opts * src/abg-writer.cc (write_context::m_short_locs): New data member. (write_context::write_context): Initialize it. (write_context::{g,s}et_short_locs): Define new accessors. (write_location, write_translation_unit, write_corpus): Honour the new write_context::get_short_locs property. (set_short_locs): Define new function. * tools/abidw.cc (options::short_locs): New data member. (display_usage): Help string for the new --no-show-locs option. (parse_command_line): Parse the new --no-show-locs option. Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Matthias Maennich
|
bf9e8b9448 |
abidw: add option to omit the compilation directory
The compilation directory contains machine specific information therefore breaks reproducibility of abidw's output across different build paths. Hence introduce --no-comp-dir-path (as in the xml attribute). Internally I decided to not carry on the duplication of 'dir' and 'path' and used 'comp_dir'. Thanks to earlier changes, adding an option boils down to adding it to set_common_options and to the write_context along with some auxiliary functions for setting and getting. write_translation_unit uses the flag in the write_context and omits the comp-dir-path if asked for. * include/abg-writer.h (set_write_comp_dir): Declare new function. (set_common_options): Use it. * src/abg-writer.cc (write_context::m_write_comp_dir): Define new data member. (write_context::write_context): Initialize it. (write_context::{g,s}et_write_comp_dir): Define new member accessors. (set_write_comp_dir): Define new free-form getter. (write_translation_unit): Teach to respect write_comp_dir flag of write_context. * tools/abidw.cc (options::write_corpus_path): Define new data member. (options::options): Initialize it. (display_usage): Add doc string for a new command line option: --no-comp-dir-path. (parse_command_line): Parse the new command line option --no-comp-dir-path. Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Matthias Maennich
|
fca2661581 |
Make write_architecture and write_corpus_path flags in the write_context
Having write_context carry corresponding flags for output sensitive command line options, is useful to ensure these options are not lost in chains for write_* calls. In particular, these options can have various meanings depending on the context (corpus, corpus_group, etc.) Hence add them to the write_context along with getters and setters and make the writers aware of their existence. We do not need to modify the corpus or corpus group's path or architecture any longer as they get ignored for a different reason now. Finally, drop the flag handling in abidw as it is already done via set_opts, which learned about these new flags. * include/abg-writer.h (set_write_architecture) (set_write_corpus_path): Declare new getter functions. (write_corpus): Take a new "member_of_group" argument. (set_common_options): Use set_write_{architecture, corpus_path} here. * src/abg-writer.cc (write_context::m_write_{architecture, corpus_path}}): Add new data members. (write_context::write_context): Initialize the new data members. (write_context::{s,g}et_write_{architecture, corpus}): Define new accessors. (set_write_{architecture, corpus}): Define new free-form getter functions. (write_corpus): Add flag to make aware if written as part of a group. * tools/abidw.cc (load_corpus_and_write_abixml) (load_kernel_corpus_group_and_write_abixml): Drop obsolete option handling as xml_writer::set_common_options now takes care of it. Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> ldiff --git a/include/abg-writer.h b/include/abg-writer.h index 200b5f7..729b455 100644 --- a/include/abg-writer.h +++ b/include/abg-writer.h @@ -53,6 +53,11 @@ set_show_locs(write_context& ctxt, bool flag); void set_annotate(write_context& ctxt, bool flag); +void +set_write_architecture(write_context& ctxt, bool flag); + +void +set_write_corpus_path(write_context& ctxt, bool flag); /// A convenience generic function to set common options (usually used /// by Libabigail tools) from a generic options carrying-object, into @@ -69,6 +74,8 @@ set_common_options(write_context& ctxt, const OPTS& opts) { set_annotate(ctxt, opts.annotate); set_show_locs(ctxt, opts.show_locs); + set_write_architecture(ctxt, opts.write_architecture); + set_write_corpus_path(ctxt, opts.write_corpus_path); } void @@ -105,7 +112,10 @@ write_corpus_to_archive(const corpus_sptr corp, const bool annotate = false); bool -write_corpus(write_context& ctxt, const corpus_sptr& corpus, unsigned indent); +write_corpus(write_context& ctxt, + const corpus_sptr& corpus, + unsigned indent, + bool member_of_group = false); bool ABG_DEPRECATED write_corpus(const corpus_sptr& corpus, unsigned indent, write_context& ctxt); Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Matthias Maennich
|
344138e6b4 |
abidw: Consolidate setting options
When setting options meant to be used for the write_context, it is easy to forget to change all relavant locations. In order to consolidate that, introduce a set_opts function that sets various known options. We benefit from earlier refactoring as now the write_context is passed around to carry options for writers. Hence we can be sure, that if we set up the context correctly (and do not use deprecated functionality), the respective write_* function will see the options set in the context. * include/abg-writer.h (set_common_option): Declare new function. * tools/abidw.cc (load_corpus_and_write_abixml) (load_kernel_corpus_group_and_write_abixml): Use the newly introduced set_common_option. Signed-off-by: Matthias Maennich <maennich@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Matthias Maennich
|
6c07e82933 |
write_context: allow mutating the ostream used
Allowing the mutation of the ostream, allows heavy reuse of the write_context as this is the distinction in most places where write_context is used. Hence, fixup various users of write_context and use common objects where applicable. * include/abg-writer.h (set_ostream): Declare new function. * src/abg-writer.cc (write_context::m_ostream): Make this data member be a pointer rather than a reference. (write_context::{write_context, get_ostream): Adjust. member. (write_context::set_ostream): Define new member function. (set_ostream): Define new free-form function. * tools/abidw.cc (load_corpus_and_write_abixml) (load_kernel_corpus_group_and_write_abixml): Use the feature of mutating the ostream and reuse the write_context in most cases. Signed-off-by: Matthias Maennich <maennich@google.com> |