mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-16 15:04:46 +00:00
a1b6a3d351
24 Commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
Dodji Seketeli
|
a1b6a3d351 |
Bug 21730 - Make abipkgdiff compare Linux Kernel packages as expected
This is the initial patch that makes abipkgdiff recognize Linux kernel packages passed in argument and do the right thing. abipkgdiff gets the vmlinux binary from the debug info package, considers the union of that vmlinux binary and the thousands of kernel modules that we shall name "the Kernel". It then compares ABI (actually Kernel/Module Interface, a.k.a KMI) of the Kernel of the first package against the KMI of the Kernel of the second package. * include/abg-tools-utils.h (get_vmlinux_path_from_kernel_dist): Declare new function. (get_binary_paths_from_kernel_dist): Re-organize order of parameters. (file_is_kernel_package, file_is_kernel_debuginfo_package): Make the file_path parameter be const. (build_corpus_group_from_kernel_dist_under): Take an additional debug_info_root parameter. * src/abg-tools-utils.cc (file_is_kernel_package) (file_is_kernel_debuginfo_package): Const-ify the file_name parameter. (find_vmlinux_path): Define new static function. (get_binary_paths_from_kernel_dist): Re-organize the order of parameters. The debug_info_root_path parameter is now an input parameter. (get_vmlinux_path_from_kernel_dist): Define new function. (get_binary_paths_from_kernel_dist): Adjust invocation of get_binary_paths_from_kernel_dist. (build_corpus_group_from_kernel_dist_under): Take an additional debug_info_root parameter. * tools/abidw.cc (load_kernel_corpus_group_and_write_abixml): Adjust invocation to build_corpus_group_from_kernel_dist_under. * tools/abipkgdiff.cc (create_maps_of_package_content): Don't map the content of a Linux Kernel package. (compare_prepared_userspace_packages) (compare_prepared_linux_kernel_packages, compare_prepared): Define new functions. (compare): Use the new functions above here. * tools/kmidiff.cc (print_kernel_dist_binary_paths_under): Adjust the invocation of get_binary_paths_from_kernel_dist. (main): Adjust the invocation of build_corpus_group_from_kernel_dist_under. Make sure that a kernel package is accompanied by a debug info package. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
b9a7e99dda |
Add --vmlinux{1,2} option to abidw and kmidiff
When using abidw to generate an abixml for a Linux Kernel build tree, usually, people have to copy the vmlinux binary into the directory where modules are, so that the tool can find it. This --vmlinux option helps to avoid doing that copy. Simarly, when comparing two Linux Kernel build trees, --vmlinux1 and --vmlinux2 are there to make the tool find the vmlinux binaries to compare, independantly from the directories under which the modules are to be found. * include/abg-tools-utils.h (build_corpus_group_from_kernel_dist_under): Add a new vmlinux_path parameter. * src/abg-tools-utils.cc (find_vmlinux_and_module_paths): Do not try to find a vmlinux binary if we already have the path to one. (build_corpus_group_from_kernel_dist_under): Add a new vmlinux_path parameter. * tools/abidw.cc (options::vmlinux): New data member. (display_usage): Add a usage string for --vmlinux (parse_command_line): Parse the new --vmlinux option. (load_kernel_corpus_group_and_write_abixml): Fix some return code when the function fails. Verify the presence of the vmlinux binary that was given. Adjust. * tools/kmidiff.cc (options::{vmlinux1, vmlinux2}): New data members. (display_usage): Add a usage string for --vmlinux1 and --vmlinux2. (parse_command_line): Parse the --vmlinux1 and --vmlinux2 options. (main): Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
e09fc8c9e2 |
Initial support of de-serializing the KMI of a Linux Kernel Tree
With this patch, kmidiff knows how to compare a serialized corpus_group that represents a Kernel Module Interface (a .kmi file) against either another serialized .kmi file, or against a kernel tree. The patch extends the abixml reader to make it parse an 'abi-corpus-group' element. To do that, the patch modifies read_corpus_from_input to make it be capable of parsing several 'abi-corpus' in a row. That modified function is then used by a new read_corpus_group_from_input, which is itself used by the new public entry points read_corpus_group_from_native_xml_file and read_corpus_group_from_native_xml. With that read_corpus_group_from_native_xml_file building block function, the kmidiff program is modified so that it can take either two directory trees, two .kmi files or one directory tree and one .kmi file. * include/abg-libxml-utils.h (advance_to_next_sibling_element): Declare new function. * src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay) (advance_to_next_sibling_element): Define new functions. * include/abg-reader.h (read_corpus_group_from_input) (read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Declare new functions. * src/abg-reader.cc (read_context::m_corpus_group): New data member. (read_context::{get_corpus_group, set_corpus_group}): Define new member functions. (read_translation_unit_from_input): Cleanup logic. (read_corpus_from_input): Don't assume that the document is starting with an 'abi-corpus' element. Support the mode where a caller called the xmlTextReaderExpand function (and so we are given an expanded xmlNodePtr) and the mode where we need to use the xmlTextReader API to walk through the 'abi-corpus' element. Also, if we are building a corpus group, do not clear what used to be 'per-corpus' data. That data must be shared by all the corpora of a given abi-corpus-group. (read_corpus_group_from_input, read_corpus_group_from_native_xml) (read_corpus_group_from_native_xml_file): Define new functions. * include/abg-tools-utils.h (FILE_TYPE_XML_CORPUS_GROUP): New enumerator of the file_type enum. * src/abg-tools-utils.cc (operator<<): In the overload for file_type, add a case for the new FILE_TYPE_XML_CORPUS_GROUP. (guess_file_type): Dectect abi-corpus-group xml element. * tools/abidiff.cc (adjust_diff_context_for_kmidiff): Define new static function. (main): Adjust to handle the new FILE_TYPE_XML_CORPUS_GROUP. That is, compare two FILE_TYPE_XML_CORPUS_GROUP if they are present. * tools/abilint.cc (main): Likewise. * tools/kmidiff.cc (main): Detect that one of two .kmi files are passed. In that case, load the .kmi file(s), build a corpus_group of it and use it in the comparison. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
adb656cc76 |
Initial support of the serialization of the KMI of a Linux Kernel Tree
We have the kmidiff program that takes two Linux Kernel trees containing the vmlinux binary and its modules and compare their Kernel Module Interface, aka KMI. We need to be able to serialize (save in a file) a representation of that KMI. We need to load that KMI back, and compare two serialized KMIs. This patch implements the serialization of the KMI of a Linux Kernel tree. It actually serializes an instance of abigail::ir::corpus_group that is a collection of instances of abigail::ir::corpus. The KMI of each individual binary (vmlinux or kernel module) is represented by one abigail::ir::corpus. All the corpora share the same definitions of types and decls, whenever that makes sense. The patch thus factorizes the routines used to walk a Linux kernel out of the kmidiff program. These routines are then re-used in the abidw program to make it walk a Linux kernel tree (when the --linux-tree option is provided), load the vmlinux and module binaries as an instance of abigail::corpus_group and serialize it out into an output stream. * include/abg-tools-utils.h (check_dir) (get_binary_paths_from_kernel_dist) (build_corpus_group_from_kernel_dist_under): Declare new functions. The last two functions are being moved from tools/kmidiff.cc so that they can be re-used. * include/abg-writer.h (write_corpus): Declare one overload that takes a write_context parameter. (write_corpus_group): Declare three overloads of this new function. * src/abg-tools-utils.cc (check_dir): Define new function. (load_generate_apply_suppressions, is_vmlinux, is_kernel_module) (find_vmlinux_and_module_paths) (get_binary_paths_from_kernel_dist) (build_corpus_group_from_kernel_dist_under): Define new functions. * src/abg-writer.cc (write_context::set_annotate): Define new member function. (write_corpus): Add an overload that takes a write_context. Adapt the existing overload to make it use this new one. (write_corpus_group): Define this new function and two additional overloads for it. * tools/kmidiff.cc (set_suppressions, is_vmlinux) (is_kernel_module, find_vmlinux_and_module_paths) (get_binary_paths_from_kernel_dist) (build_corpus_group_from_kernel_dist_under): Remove. (main): Adjust the call to build_corpus_group_from_kernel_dist_under as its arguments are now adapted since it's been factorized out into abg-tools-utils.h. * tools/abidw.cc (options::corpus_group_for_linux): Define new data member. (options::options): Adjust. (display_usage): Add help strings for the new --linux-tree option. (load_corpus_and_write_abixml): Factorize this function out of the main function. (load_kernel_corpus_group_and_write_abixml): Define new function. (main): Use the factorized load_corpus_and_write_abixml and the new load_corpus_and_write_abixml functions. * tests/test-read-write.cc: Adjust. * doc/manuals/abidw.rst: Add documentation for the new --linux-tree option. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
5f92a183bb |
Make abipkgdiff compare two kernel packages
This patch makes abipkgdiff compare two kernel packages. At the moment the comparison is done by comparing each binary from the first package to its counterpart in the second package. No optimization is done do represent a vmlinux binary and its modules as one single entity. So this is different from what kmidiff does. * include/abg-suppression.h (variable_suppression::variable_suppression): Add default arguments to the parameters. * include/abg-tools-utils.h (dir_exists, dir_is_empty) (string_begins_with, get_rpm_name, get_rpm_arch, get_deb_name) (file_is_kernel_package, file_is_kernel_debuginfo_package): Declare new functions. * src/abg-tools-utils.cc (dir_exists, dir_is_empty) (string_begins_with, get_deb_name, get_rpm_name, get_rpm_arch) (file_is_kernel_package, file_is_kernel_debuginfo_package): Define new functions. (gen_suppr_spec_from_kernel_abi_whitelist): The kernel ABI whitelist is made of ELF symbols names that ought to match functions *and* variables that have ELF symbols with those names. So generate variable suppression specifications as well. Not just function suppression specifications. * tools/abipkgdiff.cc (options::{kabi_whitelist_package, show_symbols_not_referenced_by_debug_info, kabi_whitelist_paths, kabi_suppressions}): New data members. (options::options): Adjust. (package::KIND_KABI_WHITELISTS): New enumerator in the package::kind enum. (package::kabi_whitelist_package_): New data member. (package::{base_name, kabi_whitelist_package, }): New member functions. (display_usage): Add a help string to the new --linux-kernel-abi-whitelist and --no-unreferenced-symbols options. (parse_command_line): Parse the new --no-unreferenced-symbols, --linux-kernel-abi-whitelist and --lkaw-pkg options. (maybe_check_suppression_files): Check the presence of kabi whitelist files. (set_diff_context_from_opts): Consider (not) showing symbols not referenced by debug info. (compare): If we are looking at linux kernel packages, take the kernel abi whitelist into account, apply the suppressions resulting from the kabi whitelists to the ELF read context. (maybe_collect_kabi_whitelists) (get_kabi_whitelists_from_arch_under_dir) (maybe_handle_kabi_whitelist_pkg, maybe_collect_kabi_whitelists) (get_interesting_files_under_dir): Define new functions. (maybe_update_vector_of_package_content): Take a new file_name_to_look_for parameter. (create_maps_of_package_content) (extract_package_and_map_its_content): Consider the case of the package being a linux kernel package. (main): Take the potential --lkaw-pkg into account. * doc/manuals/abipkgdiff.rst: Add documentation for options --linux-kernel-abi-whitelist, --lkaw-pkg and --no-unreferenced-symbols. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
08e760221b |
Support Linux Kernel ABI whitelist files
Enterprise Linux (at least) kernels come with ABI whitelist files that list the names of the set of functions to be considered when looking at the ABI exposed by the kernel to its modules. This patch adds a new --linux-kernel-abi-whitelist option to abidiff so that it drops changes that relate to functions that are *NOT* defined in the whitelist. The patch reads the whitelist file and generates one or several instances of function_suppression that are applied when the two binaries are loaded. * include/abg-suppression.h (function_suppression::function_suppression): Make the declaration of the default constructor public. * src/abg-suppression-priv.h (function_suppression::priv::priv): Declare a default constructor. * src/abg-suppression.cc (function_suppression::function_suppression): Define default constructor. * include/abg-tools-utils.h (gen_suppr_spec_from_kernel_abi_whitelist): Declare new function. * src/abg-tools-utils.cc (gen_suppr_spec_from_kernel_abi_whitelist): Define new function. * tools/abidiff.cc (options::kernel_abi_whitelist_paths): (display_usage): Display a help string for the new --linux-kernel-abi-whitelist option. (parse_command_line): Parse the --linux-kernel-abi-whitelist from the command line. (maybe_check_suppression_files): Check the presence of the kernel abi whitelist files. (set_suppressions): Generate suppression specifications from the whitelist files. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
5a24ffcd61 |
Add ABG_ASSERT_NOT_REACHED macro
Adding this macro to abort at places where the execution flow shouldn't take us to. Using this is more explicit (self-documented) than using abort. This patch replaces the use of abort() in abg-dwarf-reader.cc. * include/abg-tools-utils.h (ABG_ASSERT_NOT_REACHED): New macro. * src/abg-dwarf-reader.cc (stt_to_elf_symbol_type) (stb_to_elf_symbol_binding, get_elf_class_size_in_bytes) (build_ir_node_from_die): Use the new ABG_ASSERT_NOT_REACHED macro in lieu of just calling abort(). Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
b36ca1501e |
Bug 20180 - Support system-wide suppression specifications
This patch adds support for loading system and user level suppression specifications for libabigail tools. At launch time, relevant libabigail tools (abidiff, abipkgdiff fedabipkgdiff for now) read the default system suppression specification file, if it's present, from a file which path is the value of the environment variable LIBABIGAIL_DEFAULT_SYSTEM_SUPPRESSION_FILE, if set, or from the file $libdir/libabigail/default.abignore. Then it reads the user system suppression specification file, if it's present, from a file which path is the value of the environment variable LIBABIGAIL_DEFAULT_USER_SUPPRESSION_FILE, if set, or from the file $HOME/.abignore. The content of the user system suppression file is merged with the content of default system suppression file. That content is also merged with the content of the suppression specification files that might be provided by the --suppressions command line option of the invoked tools. The resulting set of all these suppression specifications is thus used to filter the ABI change reports that are emitted. abidiff, abipkgdiff and abipkgdiff gain a --no-default-suppression option to avoid loading any of these default suppression specification files. The patch also installs a default.abignore file into $(pkglibdir). Note that on x86_64, that directory is /usr/lib64/libabigail. Now we just need to think about the content of that default.abignore file. * doc/manuals/abidiff.rst: Document the default suppression scheme, its interaction with the --supprs option and the new --no-default option. * doc/manuals/abipkgdiff.rst: Likewise. * doc/manuals/fedabipkgdiff.rst: Likewise. * configure.ac: Generate the tests/runtestdefaultsupprs.py file from the new tests/runtestdefaultsupprs.py.in template. * default.abignore: New file. * Makefile.am: Add it to source distribution. * src/Makefile.am: Define the ABIGAIL_ROOT_SYSTEM_LIBDIR preprocessor macro that is set the value of the $libdir autotools macro. * include/abg-tools-utils.h: Update copyright years. (get_system_libdir, get_default_system_suppression_file_path) (get_default_user_suppression_file_path) (load_default_system_suppressions) (load_default_user_suppressions): Declare new functions * src/abg-tools-utils.cc (get_system_libdir) (get_default_system_suppression_file_path) (get_default_user_suppression_file_path) (load_default_system_suppressions) (load_default_user_suppressions): Define new functions. (is_regular_file): Amend this so that it return true for symlinks to regular files too. (is_dir): Amend this so that it returns true for symlinks to directories too. * tools/abidiff.cc (options::no_default_supprs): New data member. (options::options): Initialize the new data member. (display_usage): Display a new help string for the new --no-default-suppression command line option. (parse_command_line): Parse this new command line option. (set_diff_context_from_opts): Load the default suppression specifications, unless --no-default-suppression or --supprs was provided. * tools/abipkgdiff.cc (options::no_default_supprs): New data member. (options::options): Initialize the new data member. (parse_command_line): Parse the new --no-default-suppression command line option. (main): Load the default suppression specifications, unless --no-default-suppression or --supprs was provided. * tools/fedabipkgdiff (abipkgdiff): Add --no-default-suppression to the invocation of abipkgdiff if it was provided on the command line. (build_commandline_args_parser): Parse the new --no-default-suppression command line option. * tests/runtestdefaultsupprs.py.in: New test harness template. * tests/Makefile.am: Add the new runtestdefaultsupprs.py to the set of tests. * tests/data/test-default-supprs/test0-type-suppr-0.suppr: New test input. * tests/data/test-default-supprs/test0-type-suppr-report-0.txt: Likewise. * tests/data/test-default-supprs/test0-type-suppr-v0.o: Likewise. * tests/data/test-default-supprs/test0-type-suppr-v1.o: Likewise. * tests/data/test-default-supprs/dirpkg-1-dir-report-0.txt: Likewise. * tests/data/test-default-supprs/dirpkg-1-dir1: Likewise. * tests/data/test-default-supprs/dirpkg-1-dir2: Likewise. * tests/data/Makefile.am: Add new the new tests input above to Makefile.am. * tests/runtestcanonicalizetypes.sh.in: Pass --no-default-suppression to abidiff invocations. * tests/runtestdefaultsupprs.py.in: Likewise. * tests/test-abidiff-exit.cc: Likewise. * tests/test-diff-dwarf-abixml.cc: Likewise. * tests/test-diff-filter.cc: Likewise. * tests/test-diff-suppr.cc: Likewise. * tools/abidiff.cc: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
e19bf5627a |
Make abi{pkg}diff filter out changes about private types
This is to address the following enhancement requests: #19588 - Add a --headers-dir1 and --headers-dir2 option to abidiff #19948 - Add --devel-pkg1 and --devel-pkg2 options to abipkgdiff When the user specifies where to find header files for two binaries (or packages) being compared, this patch generates a type suppression specification that filters out change reports about types that are defined in files that are not in the set of header files specified. The type suppression specification also suppresses change reports about changed/added/removed virtual member functions which enclosing class type matches the type suppression specification. There is a corner case that the patch handles too, and that is exhibited by the accompanying test case for abidiff. There can be a class defined by DWARF as having no source location and as being a pure declaration. This can be a class declaration that has inline virtual members only, and one or several non-defined virtual methods too. When that declaration is included in a source file, GCC generates debug info that describes that class as being a declaration-only class with no source declaration. This patch considers such a class as being non defined; you know, like a true opaque type. So it's considered being not defined in any public header file. Changes to this kind of class are thus filtered out. * include/abg-comp-filter.h: Update copyright year. * src/abg-comp-filter.cc (has_virtual_mem_fn_change): Make this static function become exported. (has_virtual_mem_fn_change): Declare new function. * include/abg-suppression.h (suppression_base::{get,set}_is_artificial): Declare new accessors. (type_suppression::get_source_locations_to_keep): Return an unordered set of strings, not a vector. Add a non-const overload. (type_suppression::set_source_locations_to_keep): Set an unordered set of strings, not a vector. * src/abg-suppression.cc (suppression_base::priv::is_artificial_): New data member. (suppression_base::priv::priv): Initialize the new data member. (suppression_base::{get,set}_is_artificial): Define new accessors. (type_suppression::priv::source_locations_to_keep_): Change the vector of strings representing source file names into unordered set of string. (type_suppression::get_source_locations_to_keep): Return an unordered set of strings, not a vector. Define a non-const overload. (type_suppression::set_source_locations_to_keep): Set an unordered set of strings, not a vector. (type_suppression::suppresses_diff): Make this suppress virtual member function diffs if the enclosing type of the changed virtual member is suppressed by the current type_suppression. (read_type_suppression): Adjust to use the fact that the source locations are not stored in an unordered set, not in a vector anymore. Otherwise, using a vector here make things too slow. (type_suppression::suppresses_type): Likewise. Also, If the type we are looking at has no location because it's a true opaque type and if the current suppression is an artificial suppression that is meant to suppress change reports about non-public types, then suppress the type. * include/abg-tools-utils.h (gen_suppr_spec_from_headers): Declare new public function. * src/abg-tools-utils.cc (PRIVATE_TYPES_SUPPR_SPEC_NAME): Define a new constant variable. (handle_fts_entry): Define new static function. (gen_suppr_spec_from_headers): Define new public function. * src/abg-comparison.cc (corpus_diff::priv::apply_suppressions_to_added_removed_fns_vars): If a type suppression suppresses a given class C, make it change added/removed virtual functions whose enclosing type is C. * tools/abidiff.cc (options::{headers_dir1, headers_dir2}): New data members. (display_usage): Add help strings for --headers-dir1 and --headers-dir2. (parse_command_line): Parse the new --headers-dir1 and --headers-dir2 options. (set_diff_context_from_opts): Generate suppression specifications to filter out changes on private types, if --headers-dir1 or --headers-dir2 is given. * tools/abipkgdiff.cc (options::{devel_package1, devel_package2}): New data members. (typedef package_sptr): New typedef. (enum package::kind): New enum. (package::kind_): New data member. This replaces ... (package::is_debug_info_): ... this data member. (package::{devel_package_, private_types_suppressions_}): New data members. (package::package): Adjust. (package::get_kind): Define new member function. This replaces ... (package::is_debug_info): ... this member function overload. (package::set_kind): Define new member functin. It replaces ... (package::is_debug_info): ... this member function overload. (package::{devel_package, private_types_suppressions}): Define new accessors. (package::erase_extraction_directies): Erase the sub-directory where development packages are extracted to. (compare_args::private_types_suppr{1,2}): New data members. (compare_args::compare_args): Adjust. (display_usage): Add help strings for --devel-pkg1/--devel-pkg2. (compare): Make the overload that compares elf files take private types suppressions. Add the private types suppressions to the diff context. (pthread_routine_compare): Adjust the call to compare. (maybe_create_private_types_suppressions): Define new static function. (pthread_routine_extract_pkg_and_map_its_content): If a devel package was specified for the main package then extract it in parallel with the other package extraction. When the extraction is done, create private types suppressions by visiting the directories that contain the header files. (compare): In the overload that compares packages by scheduling comparison of individual elf files that are in the packages, pass in the private type suppressions too. (parse_command_line): Parse the new --devel-pkg{1,2} command line options. (main): Associate the devel package to the main package, if the --devel-pkg{1,2}. * doc/manuals/abidiff.rst: Add documentation about the new --headers-dir1 and --headers-dir2 options. * doc/manuals/abipkgdiff.rst: Likewise, add documentation about the new --devel-pkg1 and --devel-pkg2 libraries. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: New test reference output. * tests/data/test-diff-pkg/tbb-devel-4.1-9.20130314.fc22.x86_64.rpm: New test input package. * tests/data/test-diff-pkg/tbb-devel-4.3-3.20141204.fc23.x86_64.rpm: Likewise. * tests/test-diff-pkg.cc b/tests/test-diff-pkg.cc (InOutSpec::{first,second}_in_devel_package_path): New data members. (in_out_specs): Adjust. Also, add a new entry describing the new test inputs above. (test_task::perform): When the new test entry contains devel packages, pass them to abipkgdiff using the --devel1 and --devel2 options. * tests/data/test-diff-suppr/test30-include-dir-v0/test30-pub-lib-v0.h: A new test input source code. * tests/data/test-diff-suppr/test30-include-dir-v1/test30-pub-lib-v1.h: Likewise. * tests/data/test-diff-suppr/test30-priv-lib-v0.cc: Likewise. * tests/data/test-diff-suppr/test30-priv-lib-v0.h: Likewise. * tests/data/test-diff-suppr/test30-priv-lib-v1.cc: Likewise. * tests/data/test-diff-suppr/test30-priv-lib-v1.h: Likewise. * tests/data/test-diff-suppr/test30-pub-lib-v0.cc: Likewise. * tests/data/test-diff-suppr/test30-pub-lib-v0.so: Add new test binary input. * tests/data/test-diff-suppr/test30-pub-lib-v1.cc: Add new test input source code. * tests/data/test-diff-suppr/test30-pub-lib-v1.so: Add new test binary input. * tests/data/test-diff-suppr/test30-report-0.txt: Add new test reference output. * tests/data/test-diff-suppr/test30-report-1.txt: Add new test reference output. * tests/test-diff-suppr.cc (InOutSpec::headers_dir{1,2}): New data members. (InOutSpec::abidiff_options): Renamed the bidiff_options data member into this. (in_out_specs): Adjust. Also, added the new test input above to this. (main): Adjust to invoke abidiff with the new --hd1 and --hd2 options if the input specs for the tests has the new InOutSpec::headers_dir{1,2} data member set. Renamed bidiff into abidiff. * tests/data/Makefile.am: Add the new test inputs to the source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
67435cf6cd |
Bug 19867 - abipkgdiff skips symbolic links
When comparing two directories, abipkgdiff skips symbolic links pointing to ELF binaries altogether. It only consider regular files. This is a problem when abipkgdiff is given two directories that only contain symbolic links. In that case, abipkgdiff just performs no comparison. This patch makes abipkgdiff resolve the symbolic link to its target file. * include/abg-tools-utils.h (maybe_get_symlink_target_file_path): Declare new function. * src/abg-tools-utils.cc (get_stat): Use lstat here, not stat. Update comment. * tools/abipkgdiff.cc (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn): Follow symbolic links to elf files to get their target paths, and only work with that target path. (maybe_get_symlink_target_file_path): Define new function. * test-diff-pkg/symlink-dir-test1-report0.txt New test material. * test-diff-pkg/symlink-dir-test1/dir1/symlinks/foo.o: Likewise. * test-diff-pkg/symlink-dir-test1/dir1/symlinks/libfoo.so: Likewise. * test-diff-pkg/symlink-dir-test1/dir1/targets/foo.c: Likewise. * test-diff-pkg/symlink-dir-test1/dir1/targets/foo.o: Likewise. * test-diff-pkg/symlink-dir-test1/dir1/targets/libfoo.so: Likewise. * test-diff-pkg/symlink-dir-test1/dir2/symlinks/foo.o: Likewise. * test-diff-pkg/symlink-dir-test1/dir2/symlinks/libfoo.so: Likewise. * test-diff-pkg/symlink-dir-test1/dir2/targets/foo.c: Likewise. * test-diff-pkg/symlink-dir-test1/dir2/targets/foo.o: Likewise. * test-diff-pkg/symlink-dir-test1/dir2/targets/libfoo.so: Likewise. * tests/data/Makefile.am: Add the new test material to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Run this test harness over the new test material above. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
61a0a8b2c0 |
Fix a typo in include/abg-tools-utils.h
* include/abg-tools-utils.h (enum abidiff_status): Fix typo in comment. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
b0335a42d5 |
Prefix abidiff error message with the 'abidiff' program name
* include/abg-tools-utils.h (emit_prefix): Declare new function. (check_file): Add a new parameter with a default value, so that existing code keeps compiling. * src/abg-tools-utils.cc (emit_prefix): Define new function. (check_file): Use the emit_prefix function and give it the program name passed as a new parameter. * tools/abidiff.cc (display_usage, main): Use the new emit_prefix to prefix error messages. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
c3869ecc7b |
Bug 19434 - invalid character in attribute value
* include/abg-tools-utils.h (string_is_ascii_identifier): Declare new function. * src/abg-tools-utils.cc (string_is_ascii_identifier): Define new function. * src/abg-dwarf-reader.cc (build_function_type): Discard parameter name if it's made of non-identifier ascii characters. * tests/data/test-types-stability/pr19434-elf0: New test binary input file. * tests/data/Makefile.am: Add the new test input to source distribution. * tests/test-types-stability.cc: Test the new test input into account. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
7b35e89315 |
Bug 19139 - DWARF reader doesn't handle garbage in function names
In this bug, the DWARF debug info of the binary (generated by Intel's ICC compiler) has interesting constructs like: [ 6b5a0] subprogram decl_line (data2) 787 decl_column (data1) 15 decl_file (data1) 46 declaration (flag) accessibility (data1) public (1) type (ref4) [ 6b56a] prototyped (flag) name (string) "ldiv" MIPS_linkage_name (string) "ldiv" [ 6b5b6] formal_parameter type (ref4) [ 5f2aa] name (string) "$Ë2" [ 6b5bf] formal_parameter type (ref4) [ 5f2aa] name (string) "$Ë3" Note the strings that make up the name of the formal parameters of the function, near the end: [ 6b5b6] formal_parameter type (ref4) [ 5f2aa] name (string) "$Ë2" [ 6b5bf] formal_parameter type (ref4) [ 5f2aa] name (string) "$Ë3" The strings "$Ë2" and $Ë3" (which are the names of the parameters of the function) are garbage. Libabigail's DWARF reader naively uses those strings as names for the function parameters, in the type of the function. Then, the abixml writer emits an XML document, with these strings as property values, representing the name of the type of the function. And of course, the XML later chokes when it tries to read that XML document, saying that the property is not valid UTF-8. This patch addresses the issue by dropping those garbage names on the floor, for function type names. In that context, any string that is not made of ASCII characters is considered as being garbage, for now. The patch, in the abixml writer, also escapes function parameters names so that they don't contain characters that are not allowed in XML. The abixml reader already handles the un-escaping of the names it reads, so I think there is nothing to do there. Ultimately, I guess I should get the unicode value of the characters of that string, encode the string into UTF-8 and use the result as the name for the parameter. That would mean using UTF-8 strings for function parameter names, and, for all declarations names. But that is too much for worfk too little gain for now. The great majority of the binaries we are dealing with are still using ASCII for declaration names. The patch also introduces a new test harness that runs "abidw --abidiff" on a bunch of input binaries. This harness runs over the binaries that were submitted in this bug report. * include/abg-tools-utils.h (string_is_ascii): Declare new function ... * src/abg-tools-utils.cc (string_is_ascii): ... and define it. * src/abg-writer.cc (write_function_type): Escape forbidden XML characters in function type names. * src/abg-dwarf-reader.cc (build_function_type): If a parameter name is not ascii, drop it on the floor. * tests/data/test-types-stability/pr19139-DomainNeighborMapInst.o: New test input binary. * tests/data/test-types-stability/pr19202-libmpi_gpfs.so.5.0: Likewise. * tests/data/Makefile.am: Add the new binaries above to the build system. * tests/test-types-stability.cc: New test harness. * tests/Makefile.am: Add the new test harness to the build system. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
4173b2a421 |
Add a missing function declaration
* include/abg-tools-utils.h (dir_name): Add missing function declaration. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
585fc4c33c |
Make abipkgdiff compare tar archives containing binaries
This patch adds support for comparing the ABI of binaries contained in a tar archive. If the archive is compressed with gzip, bzip2, lzip, lzma or xz, then abipkgdiff recognizes the usual relevant file extensions and lets the GNU tar program handle the decompression. If the archive is not compressed, abipkgdiff recognizes the UStar (Uniform Standard Tape ARchive) format, even if the archive file name doesn't end with the .tar extension, and lets the GNU tar program handle the extraction. If the file ends up with the .tar extension anyway (even if it's not in the UStar format, abipkgdiff lets the GNU tar program handle its extraction. * config.h.in (WITH_TAR): New configuration preprocessor macro. * configure.ac: Add a new --enable-tar option. It's turned on automatically if the tar program is found in the PATH. Adjust the build configuration report to add the tar archive support. * include/abg-tools-utils.h (string_ends_with): Declare new function. (enum file_type): Add a new FILE_TYPE_TAR enumerator. * src/abg-tools-utils.cc (string_ends_with): Define new function. (operator<<(ostream&, file_type)): Serialize the new FILE_TYPE_TAR enumerator. (guess_file_type): Detect UStar format file by reading its magic number. Detect compressed tar files based on the file path extension. * tools/abipkgdiff.cc (extract_tar): Define new function. (extract_package): Handle tar packages. (main): Handle tar archives. * tools/abidiff.cc (main): Handle the new FILE_TYPE_TAR enumerator. * tools/abilint.cc (main): Likewise. * tests/data/test-diff-pkg/tarpkg-0-dir{1,2}.ta{,r,.bz2, gz}: New test input tarballs. * tests/data/test-diff-pkg/tarpkg-0-report-0.txt: New test output reference. * tests/data/Makefile.am: Add the new test data file above to source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add new tests cases. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
fca8506ab9 |
Misc style fixes in abipkgdiff
* include/abg-tools-utils.h (enum file_type): Fix the comment for for the FILE_TYPE_DEB enumerator. * tools/abipkgdiff.cc (main): Fix the style of the conditions. Also, fix the text emitted. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
d7dbbf0d50 |
Make abipkgdiff compare directories containing binaries
abipkgdiff knows how to compare the ABI of binaries contained in .deb and .rpm files. This patch adds support for comparing the ABI of binaries contained in two directories. * include/abg-tools-utils.h (enum file_type): Add a new FILE_TYPE_DIR enumerator. * src/abg-tools-utils.cc (operator<<(ostream&, file_type)): Support serialization of the new FILE_TYPE_DIR enumerator. (guess_file_type): Detect that the path given is a directory. * tools/abipkgdiff.cc (package::package): If the package is a directory, then set its extracted directory path to the path of the directory. (package::erase_extraction_directory): Do not erase the extraction directory if the package is a directory provided by the user. (extract_package): If the package is a directory provided by the user, then there is nothing to extract. (main): If the first package is a directory, then the second one should be a directory as well. * tools/abidiff.cc (main): Support directories as input. * tools/abilint.cc (main): Likewise. * tests/data/test-diff-pkg/dirpkg-0-dir{1,2}/libobj-v0.so: New binary test inputs. * test/data/test-diff-pkg/dirpkg-0-report-0.txt: New input test file. * tests/data/test-diff-pkg/dirpkg-1-dir{1,2}/obj-v0.cc: Source code of the binary test inputs above. * tests/data/Makefile.am: Add the new files above to the source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add the new test input files above to the set of tests this harness has to run over. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Matthias Klose
|
4df0a4d952 |
Add support for .deb files to abipkgdiff
This lets abipkgdiff compare debian binary packages. The patch contains test cases for debian package with split debug info that is referenced by the build-id scheme. These test cases come from the bug report https://sourceware.org/bugzilla/show_bug.cgi?id=18792, more particularly from the attachment https://sourceware.org/bugzilla/attachment.cgi?id=8516. * include/abg-tools-utils.h (file_type): Add FILE_TYPE_DEB. * tools/abipkgdiff.cc (extract_deb): New. (extract_package, main): Handle FILE_TYPE_DEB. * src/abg-tools-utils.cc (operator<<): Handle FILE_TYPE_DEB. (guess_file_type): Detect FILE_TYPE_DEB. * tools/abidiff.cc (main): Handle FILE_TYPE_DEB. * tools/abilint.cc (main): Handle FILE_TYPE_DEB. * tests/data/test-diff-pkg/libsigc++-2.0-0c2a-dbgsym_2.4.0-1_amd64.ddeb: Input debian debug info package; to be compared by the test harness runtestdiffpkg. * tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64.deb: Input debian package; to be compared by the test harness runtestdiffpkg. * tests/data/test-diff-pkg/libsigc++-2.0-0v5-dbgsym_2.4.1-1ubuntu2_amd64.ddeb: Input debug info package * tests/data/test-diff-pkg/libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64.deb: Input debian package; to be compared by the test harness runtestdiffpkg. * tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt: Reference output for the comparison of the packages above. * tests/data/Makefile.am: Add the new files above to the source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add the input packages above to the set of files to be compared by this test harness. Signed-off-by: Matthias Klose <doko@debian.org> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
f681c33970 |
Remove use of tmpnam from abilint
We were using the unsafe tmpnam function in abilint. This patch creates a helper type abigail::tools_utils::temp_file that does away with the use tmpnam in abilint. * include/abg-tools-utils.h (abigail::tools_utils::temp_file): Declare new type. (abigail::tools_utils::temp_file_sptr): New typedef. * src/abg-tools-utils.cc (temp_file::priv): Define new type. (temp_file::{temp_file, is_good, get_path, get_stream, create}): Define new member functions. * tools/abilint.cc (main): Do not use tmpnam anymore. Use the new abigail::tools_utils::temp_file type instead. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
1ddde3d9d0 |
Try to avoid a race condition when abipkgdiff extracts packages.
abipkgdiff extracts the content of the first package in a directory named <tmpdir>/package1 and the content second package in <tmpdir>/package2. If two independant instances of abipkgdiff are launched at the same time, they are going to walk on each others' toes, to say the least. This patch extracts the content of each package in directory named <tmpdir>/<randomname>/package1, where randomname is supposed to be a random number, and so should be unique, most of the time. I guess we should try harder to generate a randomname that is unique when we see that the directory <tmpdir>/<randomname> exists already, but for now, what we have is good enough, or at least better than what we have had so far. * include/abg-tools-utils.h (get_random_number) (get_random_number_as_string): Declare new functions. * src/abg-tools-utils.cc (get_random_number) (get_random_number_as_string): Define them. * tools/abipkgdiff.cc (package::extracted_package_parent_dir_path): New data member. (package::package): Initialize package::extracted_package_parent_dir_path to <tmpdir>/<randomname>, with randomname being a random number represented as a string. (extract_rpm): Make sure to create a hierarchy of directories, not just a directory. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Sinny Kumari
|
b55e516d49 |
Guess RPM file type
To run abipkgdiff between two pacakges, it should know whether input files are valid pacakge file or not. This patch detects RPM and SRPM pacakge file type. abipkgdiff uses it to know whether input files are valid RPM pacakge file or not. * include/abg-tools-utils.h (file_type): Added member FILE_TYPE_RPM and FILE_TYPE_SRPM (operator<<): New function declaration. * src/abg-tools-utils.cc (file_type): Detect RPM and SRPM file type (operator<<): New function definition * tools/abidiff.cc (main): Check for RPM and SRPM file type as well. * tools/abilint.cci (main): Check for RPM and SRPM file type as well. * tools/abipkgdiff.cc (main): Check whether input files to abipkgdiff are valid RPM files or not. Signed-off-by: Sinny Kumari <sinny@redhat.com> |
||
Dodji Seketeli
|
fc55e7f343 |
Make abidiff and abicompat return meaningful exit codes
As per https://sourceware.org/bugzilla/show_bug.cgi?id=18146, abidiff the exit code of abidiff and abicompat is now a bit field that can be inspected to know if the ABI change reported is incompatible for sure, or if it needs user review of the output to decide. This patch also updates the documentation. * doc/manuals/abicompat.rst: Update documentation for abicompat exit codes. * doc/manuals/abidiff.rst: Likewise for abidiff exit codes. * include/abg-tools-utils.h (enum abidiff_status): Declare new enum. (operator{|,&,|=}): Declare new operators for the new enum abidiff_status. (abidiff_status_has_error, abidiff_status_has_abi_change) (abidiff_status_has_incompatible_abi_change): Declare new functions. * src/abg-tools-utils.cc (operator{|,&,|=}): Define these new operators. (abidiff_status_has_error, abidiff_status_has_abi_change) (abidiff_status_has_incompatible_abi_change): Define new functions. * tests/test-diff-filter.cc (main): Adjust for the new exit code of abidiff. * tests/test-diff-suppr.cc (main): Likewise. * tests/test-abicompat.cc (main): Likewise. * tools/abicompat.cc (enum abicompat_status): Remove. (operator{|,&,|=}): Remove these operators for enum abicompat_status. (perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode): Return abidiff_status instead of abicompat_status. Adjust therefore. (main): Adjust to return abidiff_status now, instead of a just zero for all non-error cases. * tools/abidiff.cc (main): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
322b0e7769 |
Expose a new libabigail::tools_utils namespace
The utilities present in this namespace were previously living in tools/abg-tools-utils.h and tools/abg-tools-utils.cc. They were not exported and were meant to be useful to the tools writting in the tools/ directory. I realized that these utilities might be useful to clients of the libabigail library in general so I am making them available generally. Note that the initial name of the namespace was libabigail::tools; so renaming it to libabigail::tools_utils required that I adjust some client code. I have also cleaned up the code, interfaces and their apidoc a little bit. * include/abg-tools-utils.h: Moved tools/abg-tools-utils.h in here. Renamed the namespace tools into tools_utils. Inject std::ostream, std::istream, std::ifstream, and std::string types into the tools_utils namespace. Adjust the function declarations accordingly. Remove the useless dirname() function declaration. * include/Makefile.am: Add abg-tools-utils.h to the list of exported headers. * src/abg-tools-utils.cc: Moved tools/abg-tools-utils.cc in here. Renamed the namespace tools into tools_utils. (get_stat): Add apidoc. (is_dir): Cleanup apidoc. (dir_name); Cleanup parameter name. (guess_file_type): Cleanup parameter type. * src/Makefile.am: Add abg-tools-utils.cc to the list of exported headers. * tools/Makefile.am: Do not build the temporary library libtoolsutils.la anymore as abg-tools-utils.{h,cc} have moved out of this directory. * tools/abicompat.cc (parse_command_line, main): Adjust for tools -> tools_utils namespace change. * tools/abidiff.cc (parse_command_line, main): Likewise. * tools/abidw.cc (parse_command_line, main): Likewise. * tools/abilint.cc (parse_command_line, main): Likewise. * tests/test-abicompat.cc (main): Adjust for tools -> tools_utils namespace change. * tests/test-abidiff.cc (main): Likewise. * tests/test-alt-dwarf-file.cc (main): Likewise. * tests/test-core-diff.cc (main): Likewise. * tests/test-diff-dwarf.cc (main): Likewise. * tests/test-diff-filter.cc (main): Likewise. * tests/test-diff-suppr.cc (main): Likewise. * tests/test-lookup-syms.cc (main): Likewise. * tests/test-read-dwarf.cc (main): Likewise. * tests/test-read-write.cc (main): Likewise. * tests/Makefile.am: Do not reference the libtoolsutils.la private library anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |