libabigail/tools/abipkgdiff.cc

3005 lines
90 KiB
C++
Raw Normal View History

// -*- Mode: C++ -*-
//
Update copyright notice for all source files Happy New Year 2018, I guess :-) * update-copyright.sh: New sed-based script to update the year in the copyright notice. * include/abg-comp-filter.h: Updated the year in the copyright notice. * include/abg-comparison.h: Likewise. * include/abg-config.h: Likewise. * include/abg-corpus.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-ir-walker.cc: Likewise. * tests/test-lookup-syms.cc: Likewise. * tests/test-read-dwarf.cc: Likewise. * tests/test-read-write.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. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2018-01-08 16:54:56 +00:00
// Copyright (C) 2015-2018 Red Hat, Inc.
//
// This file is part of the GNU Application Binary Interface Generic
// Analysis and Instrumentation Library (libabigail). This library is
// free software; you can redistribute it and/or modify it under the
// terms of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 3, or (at your option) any
// later version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this program; see the file COPYING-LGPLV3. If
// not, see <http://www.gnu.org/licenses/>.
//
// Author: Sinny Kumari
/// @file
/// This program compares the ABIs of binaries inside two packages.
///
/// For now, the supported package formats are Deb and RPM, but
/// support for other formats would be greatly appreciated.
///
/// The program takes the two packages to compare as well as their
/// associated debug info packages.
///
/// The program extracts the content of the two packages into a
/// temporary directory , looks for the ELF binaries in there,
/// compares their ABIs and emit a report about the changes.
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
/// As this program uses libpthread to perform several tasks
/// concurrently, here is a coarse grain description of the sequence
/// of actions performed, including where things are done
/// concurrently.
///
/// (steps 1/ and 2/ are performed concurrently. Then steps 3/ and 4/
/// are performed in sequence)
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
///
/// 1/ the first package and its ancillary packages (debug info and
/// devel packages) are extracted concurrently.
/// There is one thread per package being extracted. So if there are
/// 3 thread packages (one package, one debug info package and one
/// devel package), then there are 3 threads to extracts them. Then
/// when the extracting is done, another thread performs the analysis
/// of th1 extracted content.
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
///
/// 2/ A similar thing is done for the second package.
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
///
/// 3/ comparisons are performed concurrently.
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
///
/// 4/ the reports are then emitted to standard output, always in the same
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
/// order.
// In case we have a bad fts we include this before config.h because
// it can't handle _FILE_OFFSET_BITS. Everything we need here is fine
// if its declarations just come first. Also, include sys/types.h
// before fts. On some systems fts.h is not self contained.
#ifdef BAD_FTS
#include <sys/types.h>
#include <fts.h>
#endif
// For package configuration macros.
#include "config.h"
#include <assert.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <elf.h>
#include <elfutils/libdw.h>
// If fts.h is included before config.h, its indirect inclusions may
// not give us the right LFS aliases of these functions, so map them
// manually.
#ifdef BAD_FTS
#ifdef _FILE_OFFSET_BITS
#define open open64
#define fopen fopen64
#endif
#else
#include <sys/types.h>
#include <fts.h>
#endif
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <vector>
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
#include <algorithm>
#include <map>
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
#include "abg-workers.h"
Add --version option to several libabigail tools This patch changed the revision number of the libabigail library to make it reflect the fact that we are not in "release candidate" mode, before the first 1.0 release. So the revision number is now "rc0". The configuration manager has been updated to support version numbers that are strings, so that it can supports things like "rc0". Then, several libabigail tools have been modified to support the --version option to display their version number. * configure.ac: Set the version revision to "rc0". * doc/manuals/abicompat.rst: Adjust manual for new --version option. * doc/manuals/abidiff.rst: Likewise. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abilint.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-config.h (config::{m_format_minor, m_format_major}): Make these be strings. (config::{get,set}_format_minor_version_number): Make these return strings. (config::{get,set}_format_major_version_number): Make these return or take strings. (abigail_get_library_version): Make this take strings. * src/abg-config.cc (config::config): Adjust. (config::{get,set}_format_major_version_number): Make these return or take strings. (config::{get,set}_format_minor_version_number): Make these return strings. (abigail_get_library_version): Make this take strings. * include/abg-version.h.in: Make the version variables be strings. * src/abg-writer.cc (write_translation_unit): The version numbers are now strings so adjust. * tools/{abicompat,abidiff,abidw,abilint,abipkgdiff,abisym}.cc (options::display_version): New data member. (options::options): Initialize it. (display_usage): Add documentation for new --version option. (parse_command_line): Parse new --version option. (main): Support --version. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-11-16 10:39:15 +00:00
#include "abg-config.h"
#include "abg-tools-utils.h"
#include "abg-comparison.h"
Split suppression engine off of abg-comparison.{cc,h} Until now, the suppression engine was part of the comparison engine. The code of both was in the abg-comparison.{cc,h} files. For the sake of greater modularity, this patch separates the suppression engine from the comparison engine. The suppression engine now lives in include/abg-suppression.h and src/abg-suppression.cc. The patch also updates logical consumers of the suppression engine to adapt them to the change. * include/Makefile.am: Add abg-suppression.h to source distribution. * include/abg-comparison.h: Remove abg-ini.h include directive. (suppression_sptr, suppressions_type): Move these typedefs to abg-fwd.h. (class suppression_base, type_suppression) (type_suppression::insertion_range) (type_suppression::insertion_range::boundary) (type_suppression::insertion_range::integer_boundary) (type_suppression::insertion_range::fn_call_expr_boundary) (function_suppression, function_suppression::parameter_spec) (variable_suppression): Move these type definitions to the new abg-suppression.h. (read_suppressions, is_type_suppression, is_integer_boundary) (is_fn_call_expr_boundary, is_function_suppression) (is_variable_suppression, operator&) (operator|): Move these function declarations to the new abg-suppression.h. (type_suppression, type_suppression_sptr, type_suppression_type) (function_suppression, function_suppression_sptr) (function_suppressions_type, variable_suppression) (variable_suppression_sptr, variable_suppressions_type): Move these forward declaration and typedefs to the new abg-suppression.h. (diff_context::suppressions): Adjust return type to suppr::suppressions_type&. (diff_context::add_suppression): Adjust parameter type to suppr::suppressions_sptr. (diff_context::add_suppressions): Adjust parameter type suppr::suppressions_type&. (is_type_diff, is_decl_diff, is_var_diff, is_function_decl_diff) (is_pointer_diff, is_reference_diff, is_fn_parm_diff) (is_base_diff, is_child_node_of_function_parm_diff) (is_child_node_of_base_diff): Declare these new functions. They were previously static, local to abg-comparison.cc only. Now they need to be exported because they are used by the suppression engine's code that now lives in its one files. * include/abg-fwd.h (suppr::{suppression_base, suppression_sptr, suppressions_type}): Forward declare these here. * include/abg-suppression.h (class suppression_base) (type_suppression, type_suppression::insertion_range) (type_suppression::insertion_range::boundary) (type_suppression::insertion_range::integer_boundary) (type_suppression::insertion_range::fn_call_expr_boundary) (function_suppression, function_suppression::parameter_spec) (variable_suppression): Move these type definitions here, in the namespace suppr. (read_suppressions, is_type_suppression, is_integer_boundary) (is_fn_call_expr_boundary, is_function_suppression) (is_variable_suppression, operator&) (operator|): Move these function decalration here, in the namespace suppr. (type_suppression_sptr, type_suppressions_type) (function_suppression_sptr, function_suppressions_type) (variable_suppression_sptr, variable_suppressions_type): Move these typedefs here, in the namespace suppr. * src/Makefile.am: add src/abg-suppression.cc to source distribution. * src/abg-comparison.cc (is_type_diff, is_decl_diff, is_var_diff) (is_function_decl_diff, is_pointer_diff, is_reference_diff) (is_reference_or_pointer_diff, is_fn_parm_diff, is_base_diff) (is_child_node_of_function_parm_diff, is_child_node_of_base_diff): Export these functions. (*suppression*): Move all the suppression-related definitions to the new abg-suppression.cc. * src/abg-suppression.cc: New file. Contains all the *suppression* definitions from src/abg-comparison.cc, that are put in the suppr namespace. * tools/abicompat.cc: Adjust. * tools/abidiff.cc: Likewise. * tools/abipkgdiff.cc: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-07 09:28:21 +00:00
#include "abg-suppression.h"
#include "abg-dwarf-reader.h"
using std::cout;
using std::cerr;
using std::string;
using std::ostream;
using std::vector;
using std::map;
Plug leak of diff_context_sptr after calling compute_diff After the function compute_diff is invoked to compute the diff against to corpora, the reference count of the diff_context_sptr that it takes get incremented several times. So the diff_context_sptr is not automatically released (freed) when its scope is left. The reason why the reference count of diff_context_sptr is incremented is because several diff types (the diff type itself or types extending it) actually holds a reference to the diff_context_sptr they get created with. So the lifetime of the diff_context_sptr becomes tied to the lifetime the different diff objects in a hard-to-predict way. It actually creates some cyclic references that, in this case, creates a leak. The diff_context_sptr never gets released. This patch fixes that by making the diff types hold a weak reference to the diff_context_sptr they are created with. * src/abg-comparison.cc (diff::priv::ctxt_): Make this a weak_ptr. (diff::priv::get_context): Convert the weak pointer to the context into a shared_ptr and return it. (diff::priv::is_filtered_out): Adjust to use diff::priv::get_context() to access the context. (diff::context): Likewise. (corpus_diff::priv::ctxt_): Make this a weak_ptr. (corpus_diff::priv::priv): Add a new overload that takes two corpora and a diff context. (corpus_diff::priv::get_context): Convert the weak pointer to the context into a shared_ptr and return it. (corpus_diff::priv::ensure_lookup_tables_populated): Adjust to use the new corpus_diff::priv::get_context to get the context. (variable_is_suppressed): Likewise. (corpus_diff::priv::{apply_suppressions_to_added_removed_fns_vars, apply_filters_and_compute_diff_stats, emit_diff_stats, categorize_redundant_changed_sub_nodes, clear_redundancy_categorization}): Likewise. (corpus_diff::{corpus_diff, context, apply_filters_and_suppressions_before_reporting}): Adjust. * tools/abipkgdiff.cc (compare): Make the overload that compares elf binaries take a diff context output parameter. After the context is created by this function, it's return to the caller, so that it's life time is bound to the scope this function was called from. (pthread_routine_compare): Create a shared pointer to hold a reference on a diff context. Pass that shared pointer by reference to the compare function that compares elf binaries. Rather than storing corpora in the reports_map, (as those corpora would then out-live the diff context and thus create memory corruption issues), emit the report directly into an ostringstream and store that stream in reports_map. (compare): In the overoad that compares packages, rather than trying to get corpora from the report_map, just emit the content of the ostringstream that is now there. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-18 17:51:57 +00:00
using std::ostringstream;
using std::tr1::shared_ptr;
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
using std::tr1::dynamic_pointer_cast;
using abigail::workers::task;
using abigail::workers::task_sptr;
using abigail::workers::queue;
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>
2016-03-25 10:48:11 +00:00
using abigail::tools_utils::maybe_get_symlink_target_file_path;
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>
2016-05-20 07:19:51 +00:00
using abigail::tools_utils::file_exists;
using abigail::tools_utils::is_dir;
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
using abigail::tools_utils::emit_prefix;
using abigail::tools_utils::check_file;
using abigail::tools_utils::ensure_dir_path_created;
using abigail::tools_utils::guess_file_type;
using abigail::tools_utils::string_ends_with;
Bug 22488 - Make abipkgdiff handle different binaries with same basename Some packages might have different binaries with the same soname and basename, but at different paths. In that case, abipkgdiff messes things up because it only either consider the soname or the basename of the binary. This patch makes abipkgdiff to always consider the full path of the binary inside the package. * include/abg-tools-utils.h (string_suffix) (sorted_strings_common_prefix): Declare new functions. (dir_name): Take a new keep_separator_at_end parameter at the end. * src/abg-tools-utils.cc (dir_name): Take a new keep_separator_at_end parameter at the end. Add a comment for it and update. (string_suffix, sorted_strings_common_prefix): Define new functions. (common_prefix): Define new static function. * tools/abipkgdiff.cc (get_interesting_files_under_dir): Forward declare this pre-existing static function. (package::{common_paths_prefix_, elf_file_paths_}): New data members. (package::{common_paths_prefix, elf_file_paths, convert_path_to_relative, convert_path_to_unique_suffix, load_elf_file_paths}): New member functions. (create_maps_of_package_content): Use the new package::{load_elf_file_paths, convert_path_to_unique_suffix} functions. (compare_prepared_userspace_packages): Show relative paths of package elements in reported. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Update test ouptut. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-12-01 13:52:23 +00:00
using abigail::tools_utils::dir_name;
using abigail::tools_utils::string_suffix;
using abigail::tools_utils::sorted_strings_common_prefix;
using abigail::tools_utils::file_type;
using abigail::tools_utils::make_path_absolute;
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>
2016-05-20 07:19:51 +00:00
using abigail::tools_utils::base_name;
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>
2017-04-03 18:10:06 +00:00
using abigail::tools_utils::get_rpm_arch;
using abigail::tools_utils::file_is_kernel_package;
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>
2016-05-20 07:19:51 +00:00
using abigail::tools_utils::gen_suppr_spec_from_headers;
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>
2017-04-03 18:10:06 +00:00
using abigail::tools_utils::gen_suppr_spec_from_kernel_abi_whitelist;
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>
2016-05-30 08:37:48 +00:00
using abigail::tools_utils::get_default_system_suppression_file_path;
using abigail::tools_utils::get_default_user_suppression_file_path;
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>
2017-07-10 09:54:13 +00:00
using abigail::tools_utils::get_vmlinux_path_from_kernel_dist;
using abigail::tools_utils::build_corpus_group_from_kernel_dist_under;
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>
2016-05-30 08:37:48 +00:00
using abigail::tools_utils::load_default_system_suppressions;
using abigail::tools_utils::load_default_user_suppressions;
using abigail::tools_utils::abidiff_status;
using abigail::ir::corpus_sptr;
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>
2017-07-10 09:54:13 +00:00
using abigail::ir::corpus_group_sptr;
using abigail::comparison::diff_context;
using abigail::comparison::diff_context_sptr;
using abigail::comparison::compute_diff;
using abigail::comparison::corpus_diff_sptr;
Allow selective resolution of class declaration When a class is forward-declared, resolving it to a definition that appears later in the same translation unit or in another translation is an interesting problem. Until now, the declaration would be resolved to the definition of that class found in the binary. The problem is that there can be different such definitions, especially in C where there is no "One Definition Rule". In that case, the definition chosen is random. This patch resolves that randomness. For a given class declaration, if there is just one possible definition in the binary, then the declaration is resolved to that definition. If there is one definition for that declaration in the same translation unit, then the declaration is resolved to that definition. If there are more than one definitions in translation units that are not the one of the declaration, then the declaration is left unresolved. This is what I call "selective class declaration resolution". Note that an unresolved class declaration now compares different to a definition of a class of the same name. This is so that we can have an unresolved class be present in the resulting .abi file, alongside an (incompatible) definition of the same class. The change from a class declaration to its definition is filtered out by default, though. * include/abg-fwd.h (type_base_wptrs_type) (istring_type_base_wptrs_map_type): Define new typedefs. (lookup_class_types): Declare new functions. * include/abg-ir.h (environment::decl_only_class_equals_definition): Declare new accessor. (type_maps::{*_types}): Make these accessors return istring_type_base_wptrs_map_type& instead of istring_type_base_wptr_map_type&. * src/abg-dwarf-reader.cc (read_context::resolve_declaration_only_classes): Implement the new selective declaration resolution scheme. * src/abg-ir.cc (type_maps::priv::{*_types_}): Change the type of these data members from istring_type_base_wptr_map_type to istring_type_base_wptrs_map_type. (type_maps::{*_types}): Make these accessors definitions return istring_type_base_wptrs_map_type& instead of istring_type_base_wptr_map_type&. (translation_unit::bind_function_type_life_time): Adjust. (environment::priv::decl_only_class_equals_definition_): New data member. (environment::priv::priv): Initialize it. By default, a decl-only class is now considered different from its definition. (environment::decl_only_class_equals_definition): Define new accessor. (lookup_types_in_map, lookup_class_types): Define new functions. (lookup_type_in_map, lookup_union_type_per_location) (lookup_basic_type, lookup_basic_type_per_location) (lookup_class_type, lookup_class_type_per_location) (lookup_union_type, lookup_enum_type) (lookup_enum_type_per_location, lookup_typedef_type) (lookup_typedef_type_per_location, lookup_qualified_type) (lookup_pointer_type, lookup_reference_type, lookup_array_type) (lookup_function_type, maybe_update_types_lookup_map) (maybe_update_types_lookup_map<class_decl>) (maybe_update_types_lookup_map<function_type>): Adjust. (type_base::get_canonical_type_for): When doing type comparison here, we can now consider that an unresolved class declaration compares different to an incompatible class definition of the same name. So no need to look through decl-only classes in that case. (equals): In the overload for class_or_union, if environment::decl_only_class_equals_definition() is false, then an unresolved class declaration of name "N" compares different to a class definition named "N". * tests/data/test-annotate/test15-pr18892.so.abi: Adjust. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust * tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust. * tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust. * tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt: Adjust. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Adjust. * tests/data/test-diff-filter/test38/Makefile: New test material. * tests/data/test-diff-filter/test38/test38-a.c: Likewise. * tests/data/test-diff-filter/test38/test38-b.c: Likewise. * tests/data/test-diff-filter/test38/test38-c.c: Likewise. * tests/data/test-diff-filter/test38/test38-report-0.txt: Likewise. * tests/data/test-diff-filter/test38/test38-v0: Likewise. * tests/data/test-diff-filter/test38/test38-v1: Likewise. * tests/data/test-diff-filter/test38/test38.h: Likewise. * tests/data/test-diff-filter/test39/Makefile: Likewise. * tests/data/test-diff-filter/test39/test39-a-v0.c: Likewise. * tests/data/test-diff-filter/test39/test39-a-v1.c: Likewise. * tests/data/test-diff-filter/test39/test39-b-v0.c: Likewise. * tests/data/test-diff-filter/test39/test39-b-v1.c: Likewise. * tests/data/test-diff-filter/test39/test39-c-v0.c: Likewise. * tests/data/test-diff-filter/test39/test39-c-v1.c: Likewise. * tests/data/test-diff-filter/test39/test39-main.c: Likewise. * tests/data/test-diff-filter/test39/test39-report-0.txt: Likewise. * tests/data/test-diff-filter/test39/test39-v0: Likewise. * tests/data/test-diff-filter/test39/test39-v1: Likewise. * tests/data/test-diff-filter/test39/test39.h: Likewise. * tests/data/Makefile.am: Add the new test material above to the source distribution. * tests/test-diff-filter.cc (in_out_specs): Add the new test inputs above to the test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-05-17 08:19:30 +00:00
using abigail::comparison::get_default_harmless_categories_bitmap;
using abigail::comparison::get_default_harmful_categories_bitmap;
Split suppression engine off of abg-comparison.{cc,h} Until now, the suppression engine was part of the comparison engine. The code of both was in the abg-comparison.{cc,h} files. For the sake of greater modularity, this patch separates the suppression engine from the comparison engine. The suppression engine now lives in include/abg-suppression.h and src/abg-suppression.cc. The patch also updates logical consumers of the suppression engine to adapt them to the change. * include/Makefile.am: Add abg-suppression.h to source distribution. * include/abg-comparison.h: Remove abg-ini.h include directive. (suppression_sptr, suppressions_type): Move these typedefs to abg-fwd.h. (class suppression_base, type_suppression) (type_suppression::insertion_range) (type_suppression::insertion_range::boundary) (type_suppression::insertion_range::integer_boundary) (type_suppression::insertion_range::fn_call_expr_boundary) (function_suppression, function_suppression::parameter_spec) (variable_suppression): Move these type definitions to the new abg-suppression.h. (read_suppressions, is_type_suppression, is_integer_boundary) (is_fn_call_expr_boundary, is_function_suppression) (is_variable_suppression, operator&) (operator|): Move these function declarations to the new abg-suppression.h. (type_suppression, type_suppression_sptr, type_suppression_type) (function_suppression, function_suppression_sptr) (function_suppressions_type, variable_suppression) (variable_suppression_sptr, variable_suppressions_type): Move these forward declaration and typedefs to the new abg-suppression.h. (diff_context::suppressions): Adjust return type to suppr::suppressions_type&. (diff_context::add_suppression): Adjust parameter type to suppr::suppressions_sptr. (diff_context::add_suppressions): Adjust parameter type suppr::suppressions_type&. (is_type_diff, is_decl_diff, is_var_diff, is_function_decl_diff) (is_pointer_diff, is_reference_diff, is_fn_parm_diff) (is_base_diff, is_child_node_of_function_parm_diff) (is_child_node_of_base_diff): Declare these new functions. They were previously static, local to abg-comparison.cc only. Now they need to be exported because they are used by the suppression engine's code that now lives in its one files. * include/abg-fwd.h (suppr::{suppression_base, suppression_sptr, suppressions_type}): Forward declare these here. * include/abg-suppression.h (class suppression_base) (type_suppression, type_suppression::insertion_range) (type_suppression::insertion_range::boundary) (type_suppression::insertion_range::integer_boundary) (type_suppression::insertion_range::fn_call_expr_boundary) (function_suppression, function_suppression::parameter_spec) (variable_suppression): Move these type definitions here, in the namespace suppr. (read_suppressions, is_type_suppression, is_integer_boundary) (is_fn_call_expr_boundary, is_function_suppression) (is_variable_suppression, operator&) (operator|): Move these function decalration here, in the namespace suppr. (type_suppression_sptr, type_suppressions_type) (function_suppression_sptr, function_suppressions_type) (variable_suppression_sptr, variable_suppressions_type): Move these typedefs here, in the namespace suppr. * src/Makefile.am: add src/abg-suppression.cc to source distribution. * src/abg-comparison.cc (is_type_diff, is_decl_diff, is_var_diff) (is_function_decl_diff, is_pointer_diff, is_reference_diff) (is_reference_or_pointer_diff, is_fn_parm_diff, is_base_diff) (is_child_node_of_function_parm_diff, is_child_node_of_base_diff): Export these functions. (*suppression*): Move all the suppression-related definitions to the new abg-suppression.cc. * src/abg-suppression.cc: New file. Contains all the *suppression* definitions from src/abg-comparison.cc, that are put in the suppr namespace. * tools/abicompat.cc: Adjust. * tools/abidiff.cc: Likewise. * tools/abipkgdiff.cc: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-07 09:28:21 +00:00
using abigail::suppr::suppression_sptr;
using abigail::suppr::suppressions_type;
using abigail::suppr::read_suppressions;
A suppressed diff node implies suppressing all equivalent nodes too When a diff node N is suppressed (for instance, using the --headers-dir{1,2} option of abidiff}, it's only that diff node that is suppressed. We forget to suppress diff nodes that are equivalent to N. Here is why we forget to suppress diff ndoes that are equivalent. apply_suppressions walks the diff node graph to mark diff nodes as suppressed. But it does the walking by making sure each diff node's *class of equivalence* is visited once. This is not only a way to prevent infinite loops while visiting the graph, but also an optimization as it avoids walking two equivalent diff nodes. But then it can happen that we forget to categorize some diff nodes inside a given class of equivalence, even though we categorized some others. This patch makes it so that when a diff node inside a class of equivalence is categorized as SUPPRESSED, the canonical diff node of that class of equivalence is categorized as SUPPRESSED too. That way, to know if a diff node is suppressed, we just need to look at its canonical diff node. While doing this, I noticed that abidiff and abipkgdiff are not dropping private types from libabigail's internal representation, even though the Library now has that capability. The patch fixes that. But then the patch adds a --dont-drop-private-types option to abidiff to avoid dropping those private types from the IR, so that regression tests can make sure that a suppressed diff node implies suppression all equivalent nodes too. * doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst: Document the new --dont-drop-private-types option. * src/abg-comparison.cc (diff::is_filtered_out): If the canonical type was suppressed then the current diff node is filtered out. (suppression_categorization_visitor::visit_{begin,end}): Categorized the canonical node as SUPPRESSED if the current node is suppressed. * tools/abidiff.cc (options::drop_private_types): New data member. (options::options): Initialize it. (display_usage): Add new help string for the new --dont-drop-private-types option. (parse_command_line): Parse the new --dont-drop-private-types option. (set_suppressions): Generate suppression specification from header directories given in parameter and stick them to the read context. * tools/abipkgdiff.cc (compare): Likewise. * tests/data/test-diff-suppr/libtest34-v0.so: New test input. * tests/data/test-diff-suppr/libtest34-v1.so: Likewise. * tests/data/test-diff-suppr/test34-report-0.txt: New reference report. * tests/data/test-diff-suppr/test34-v0.c: Source code for the new test input. * tests/data/test-diff-suppr/test34-v1.c: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v0/test34-priv-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v1/test34-priv-include-v1.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v0/test34-pub-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v1/test34-pub-include-v1.h: Likewise. * tests/data/Makefile.am: Add new test input material above to source distribution. * tests/test-diff-suppr.cc (in_out_spec): Compare the two new test library provided. Add --dont-drop-private-types to test30*. signed-off-by: Dodji Seketeli <dodji@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-26 10:01:45 +00:00
using abigail::dwarf_reader::read_context_sptr;
using abigail::dwarf_reader::create_read_context;
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
using abigail::dwarf_reader::get_soname_of_elf_file;
using abigail::dwarf_reader::get_type_of_elf_file;
using abigail::dwarf_reader::read_corpus_from_elf;
/// The options passed to the current program.
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
class options
{
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
options();
public:
string wrong_option;
string wrong_arg;
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
string prog_name;
bool display_usage;
Add --version option to several libabigail tools This patch changed the revision number of the libabigail library to make it reflect the fact that we are not in "release candidate" mode, before the first 1.0 release. So the revision number is now "rc0". The configuration manager has been updated to support version numbers that are strings, so that it can supports things like "rc0". Then, several libabigail tools have been modified to support the --version option to display their version number. * configure.ac: Set the version revision to "rc0". * doc/manuals/abicompat.rst: Adjust manual for new --version option. * doc/manuals/abidiff.rst: Likewise. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abilint.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-config.h (config::{m_format_minor, m_format_major}): Make these be strings. (config::{get,set}_format_minor_version_number): Make these return strings. (config::{get,set}_format_major_version_number): Make these return or take strings. (abigail_get_library_version): Make this take strings. * src/abg-config.cc (config::config): Adjust. (config::{get,set}_format_major_version_number): Make these return or take strings. (config::{get,set}_format_minor_version_number): Make these return strings. (abigail_get_library_version): Make this take strings. * include/abg-version.h.in: Make the version variables be strings. * src/abg-writer.cc (write_translation_unit): The version numbers are now strings so adjust. * tools/{abicompat,abidiff,abidw,abilint,abipkgdiff,abisym}.cc (options::display_version): New data member. (options::options): Initialize it. (display_usage): Add documentation for new --version option. (parse_command_line): Parse new --version option. (main): Support --version. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-11-16 10:39:15 +00:00
bool display_version;
bool missing_operand;
bool nonexistent_file;
bool abignore;
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
bool parallel;
string package1;
string package2;
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
vector<string> debug_packages1;
vector<string> debug_packages2;
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>
2016-05-20 07:19:51 +00:00
string devel_package1;
string devel_package2;
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
size_t num_workers;
bool verbose;
Bug 21058 - abipkgdiff wrongly drops non-public types When using abipkgdiff types that are defined in files not present in the devel packages provided by the --devel1 and --devel2 option are dropped from the internal representation by default. This has been designed as such, not only to avoid showing changes on types that are not part of the public headers of a shared library, but also to help lower the memory consumption of libabigail. In this particular bug report, we see a library that uses types (in its public interface) that are defined in headers of a *different* package. For instance, suppose a particular package foo that uses types defined in headers of the glib package. And some of those Glib types can be present in its public interface. So in this case, libabigail is dropping a type that is actually part of the public interface of the library that is being analyzed, even if the type was not defined in the devel package of the current package. This patch addresses the issue by doing a number of things: 1/ If a type is defined in a file which path starts with "/usr/include/", then consider it as a public type. This is so that type coming from the public interface of other packages, and that are defined in system headers are considered as part of the public types of the package being analyzed. 2/ by default, don't drop types not defined in the associated devel package. This will hinder our ability to decrease the memory usage, but there have been a number of recent optimization that help in that regard independently. So I am hoping this shouldn't have a big impact now. Incidentally, the option --dont-drop-private-types (from abidiff) is changed into --drop-private-types, so that interested users can still drop non-private types from the model, if they wish. That --drop-private-types option is added to abipkgdiff too. As the offended types are not dropped from the model anymore, the usual filtering mechanisms of libabigail can take place. * doc/manuals/abidiff.rst (--dont-drop-private-types): Remove documentation. (--drop-private-types): Document this new option. * src/abg-tools-utils.cc: Update copyright notice (handle_fts_entry): On the generated suppression specification, do not set the flag to drop matched types. Also, don't match types defined in files which patch start with "/usr/include/". * tools/abidiff.cc (options::options): Initialize the drop_private_types data member to false. (display_usage): Remove usage string for --dont-drop-private-types. Add a new one for --drop-private-types. (parse_command_line): Don't part --dont-drop-private-types, rather, parse --drop-private-types. (set_suppressions): When the suppression for private types is generated, if --drop-private-types was provided, then instruct the suppression to drop matched types. * tools/abipkgdiff.cc (options::drop_private_types): New option. (options::options): Initialize the new drop_private_types data member to false. (display_usage): Add a usage string for --drop-private-types. (parse_command_line): Parse the new --drop-private-types option. (maybe_create_private_types_suppressions): Don't take just a package, but a package_descriptor because the latter carries the options. So when the user used the --drop-private-types option, make the generated private types suppression to drop matched types. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Adjust. * tests/test-diff-suppr.cc (in_out_specs): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-18 09:10:10 +00:00
bool drop_private_types;
Bug 20887 - Show relative change of offsets Until now, an offset change is reported by showing the old and new offsets of the data member that changed. This patch adds the string "(by +N bits)" with 'N' being the number of bits by which the offset of the data member was increased, or "(by -N bits) if the offset of the data member was decreased of N bits. The patch also emits a string that says "size hasn't changed" if the size of the structure did not change. This can be disabled by a new --no-show-relative-offset-changes option. * doc/manuals/abidiff.rst: Document the new --no-show-relative-offset-changes. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-comparison.h (diff_context::show_relative_offset_changes): New accessors. * include/abg-ir.h ({set,get}_data_member_offset): Return uint64_t instead of the less portable size_t. * src/abg-comparison.cc (diff_context::priv::show_relative_offset_changes_): New data member. (dif_context::show_relative_offset_changes): Define accessor. (maybe_show_relative_offset_change): Define new function. (represent): In the overload for var_diff, call the new maybe_show_relative_offset_change. (report_size_and_alignment_changes): If the size of the type didn't change then say it now. * src/abg-ir.cc (set_data_member_offset, get_data_member_offset): Take or return a uint64_t instead of a size_t. * tools/abidiff.cc (options::show_relative_offset_changes): New data member. (options::options): Initialize it. (display_usage): Display help string for the new --no-show-relative-offset-changes. (parse_command_line): Parse the new --no-show-relative-offset-changes options. (set_diff_context_from_opts): Set the "show-relative-offset-changes" flag according to the new option.n * tools/abipkgdiff.cc (options::show_relative_offset_changes): New data member. (options::options): Initialize it. (display_usage): Add help string for the new --no-show-relative-offset-changes option. (set_diff_context_from_opts): Set the "show-relative-offset-changes" flag according to the new option. (parse_command_line): Parse the new command line option. * tests/data/test-diff-dwarf/test40-report-0.txt: Add new reference output. * tests/data/test-diff-dwarf/test40-v0.c: Source code of the first test binary. * tests/data/test-diff-dwarf/test40-v1.c: Source code of the second test binay. * tests/data/test-diff-dwarf/libtest40-v0.so: New first test binary. * tests/data/test-diff-dwarf/libtest40-v1.so: New second test binary. * tests/test-diff-dwarf.cc (in_out_spec): Add the new test binaries above to the set of binaries that are compared. * tests/data/Makefile.am: Add the new test material to source distribution. * tests/data/test-abicompat/test7-fn-changed-report-0.txt: Adjust. * tests/data/test-abidiff/test-PR18791-report0.txt: Likewise. * tests/data/test-abidiff/test-enum0-report.txt: Likewise. * tests/data/test-abidiff/test-enum1-report.txt: Likewise. * tests/data/test-abidiff/test-struct1-report.txt: Likewise. * tests/data/test-diff-dwarf/test0-report.txt: Likewise. * tests/data/test-diff-dwarf/test1-report.txt: Likewise. * tests/data/test-diff-dwarf/test10-report.txt: Likewise. * tests/data/test-diff-dwarf/test11-report.txt: Likewise. * tests/data/test-diff-dwarf/test13-report.txt: Likewise. * tests/data/test-diff-dwarf/test15-enum-report.txt: Likewise. * tests/data/test-diff-dwarf/test27-local-base-diff-report.txt: Likewise. * tests/data/test-diff-dwarf/test32-fnptr-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test33-fnref-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test38-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test4-report.txt: Likewise. * tests/data/test-diff-dwarf/test5-report.txt: Likewise. * tests/data/test-diff-dwarf/test6-report.txt: Likewise. * tests/data/test-diff-dwarf/test8-report.txt: Likewise. * tests/data/test-diff-filter/test0-report.txt: Likewise. * tests/data/test-diff-filter/test01-report.txt: Likewise. * tests/data/test-diff-filter/test1-report.txt: Likewise. * tests/data/test-diff-filter/test13-report.txt: Likewise. * tests/data/test-diff-filter/test16-report-2.txt: Likewise. * tests/data/test-diff-filter/test16-report.txt: Likewise. * tests/data/test-diff-filter/test17-0-report.txt: Likewise. * tests/data/test-diff-filter/test17-1-report.txt: Likewise. * tests/data/test-diff-filter/test18-report.txt: Likewise. * tests/data/test-diff-filter/test19-enum-report-1.txt: Likewise. * tests/data/test-diff-filter/test2-report.txt: Likewise. * tests/data/test-diff-filter/test23-redundant-fn-parm-change-report-0.txt: Likewise. * tests/data/test-diff-filter/test24-compatible-vars-report-1.txt: Likewise. * tests/data/test-diff-filter/test25-cyclic-type-report-0.txt: Likewise. * tests/data/test-diff-filter/test25-cyclic-type-report-1.txt: Likewise. * tests/data/test-diff-filter/test26-qualified-redundant-node-report-0.t: Likewise.xt * tests/data/test-diff-filter/test26-qualified-redundant-node-report-1.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt: Likewise. * tests/data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt: Likewise. * tests/data/test-diff-filter/test3-report.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt: Likewise. * 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: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test10-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-suppr/test2-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test30-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-8.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-12-02 13:41:07 +00:00
bool show_relative_offset_changes;
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>
2016-05-30 08:37:48 +00:00
bool no_default_suppression;
bool keep_tmp_files;
bool compare_dso_only;
Add a --leaf-changes-only option to abipkgdiff This patch adds the --leaf-changes-only option to abipkgdiff, just like what we have for abidiff. The patch also emit leaf changes report by default when comparing two Linux Kernel packages. The patch also adds the --impacted-interfaces and --full-impact options. * doc/manuals/abipkgdiff.rst: Add documentation for the new --leaf-change-only, --impacted-interfaces and --full-impact options. * tools/abipkgdiff.cc (options::{leaf_changes_only, show_impacted_interfaces, show_full_impact_report): Add new data members. (options::options): Initialize them. (display_usage): Add help strings for the new --leaf-change-only, --impacted-interfaces and --full-impact|-f options. (set_diff_context_from_opts): Set the diff context for the 'leaf-changes-only' and 'show-impacted-interfaces' flags. (parse_command_line): Parse the --leaf-change-only, --impacted-interfaces and --full-impact options. Handle the case where the --linux-kernel-abi-whitelist|-w option is given a whitelist *package*. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt: New test output reference. * tests/test-diff-pkg.cc (in_out_spec): Compare data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64.rpm and data/test-diff-pkg/spice-server-0.12.8-1.el7.x86_64.rpm with the new --leaf-changes-only and --impacted-interfaces options, using the new output reference above. * tests/data/Makefile.am: Add the new test material to source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-09-18 14:00:23 +00:00
bool leaf_changes_only;
bool show_impacted_interfaces;
bool show_full_impact_report;
bool show_linkage_names;
bool show_redundant_changes;
bool show_harmless_changes;
Add the option of printing the file, line and column information about a type being reported. * bash-completion/abicompat: Complete the new "--no-show-locs" option. * bash-completion/abidiff: Likewise. * bash-completion/abidw: Likewise. * bash-completion/abipkgdiff: Likewise. * doc/manuals/abicompat.rst: Mention the new "--no-show-locs" option. * doc/manuals/abidiff.rst: Likewise. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-comparison.h (show_locs): Add declarations. * src/abg-comparison.cc: (diff_context::priv): Add a new switch called "show_locs_" and set its default value to false. (report_loc_info): New function. Outputting the extra information is conditionalized based on the associated diff contexts settings. (show_locs): define a getter/setter for diff_context::priv::show_locs_. ({distinct,pointer,reference,qualified_type,enum,class,scope,fn_parm, typedef,corpus}_diff::report): Call report_loc_info when appropriate. (maybe_report_diff_for_member): Likewise. (represent): Accept a const reference to a diff_context_sptr as a first argument and call report_loc_info on its second argument. * src/abg-dwarf-reader.cc: * tests/data/Makefile.am: Add the new test reference files. * tests/data/test-abicompat/test0-fn-changed-report-2.txt: New test reference output. * tests/data/test-abicompat/test5-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test6-var-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test7-fn-changed-report-2.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-2.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. * tests/test-abidiff.cc: Explicitly create a diff context and turn off location emitting. * tests/test-diff-dwarf.cc: Likewise. * tests/test-abicompat.cc: Add --no-show-locs to all existing test arguments. Run a few of the existing tests again, but without this option. * tests/test-diff-filter.cc: Likewise. * tests/test-diff-pkg.cc: Likewise. * tests/test-diff-suppr.cc: Likewise. * tools/abicompat.cc: Handle the new "--no-show-locs" option. * tools/abidiff.cc: Likewise. * tools/abidw.cc: Likewise. * tools/abipkgdiff.cc: Likewise. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-16 09:55:28 +00:00
bool show_locs;
bool show_added_syms;
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>
2017-04-03 18:10:06 +00:00
bool show_symbols_not_referenced_by_debug_info;
bool show_added_binaries;
bool fail_if_no_debug_info;
Make fedabipkgdiff consistent with Libabigail's other tests In the libabigail project, almost all the tests for the tools follow a similar pattern. The test contains a set of input files to compare. The result of the comparison is thus compared to a set of reference comparison result. This approach is already documented in the CONTRIBUTING file. There are several interesting properties with this scheme. First, it capture the behaviour of the tools, including what is shown to the user. Second, it eases the job of a hacker who wants to add a new test for a new behaviour of a given tool. The user just has to provide: 1/ A new reference output of the new use case of the tool (that is easily constructed by using the tool itself and saving its output) and add an entry to array of entries that describe what to compare 2/ A new set of inputs to the tool And voila. Unfortunately, fedabipkgdiff tests don't follow this scheme. That make them surprising to hackers who read the source code of the existing tests, at very least. Also, the fedabipkgdiff tests were only unit tests. They were not testing the tool as used by users in general. This patch makes the fedabipkgdiff tests follow the general approach of the tests of the other Libabigail tools. The patch first craetes a program names tests/mockfedabipkgdiff. It's a wrapper around tools/fedabipkgdiff. It overloads the Koji client of fedabipkgdiff with a fake Koji client that gets the Fedora packages locally, from tests/data/test-fedabipkgdiff/packages. In other words, mockfedabipkgdiff is fedabipkgdiff without going to the network. I believe that in the future, tests/mockfedabipkgdiff should be killed when fedabipkgdiff is able to cache a local description of a local partial view of a Koji repository, along with the build packages that were already downloaded. That way, calling fedabipkgdiff twice with the same set of option should make the tool perform correctly without going to the netword on the second invocation. We should be able to save the local partial view of the Koji repository under e.g, tests/data/test-fedabipkgdiff/local-koji and tell fedabipkgdiff to use that, instead of using the network. But we are not there yet. So for now, I am using mockfedabipkgdiff. Then, tests/runtestfedabipkdiff.py.in has been re-written to use tests/mockfedabipkgdiff and to look like what is described in CONTRIBUTING as far as how Libabigail tools' tests are organized: mockfedabipkgdiff is called to perform a comparison. The result of the comparison is then compared (using GNU diff) to a reference comparison result file. Please note that tests/runtestfedabipkdiff.py is relatively fast for the moment. But when it contains much more tests and start becoming slow, then we'll need to change the code to run several comparisons in parallel, just like we do today in tests/test-diff-filter.cc. At that point, I believe I'll just re-write this in C++, just like tests/test-diff-filter.cc because that will allow us to have true concurrent code based on the abigail:workers API. For now, I am keeping this in Python also because I think that keeps Chenxiong happy ;-) To be sure that fedabipkgdiff (and its underlying abipkgdiff) are really comparing all the packages they are supposed to compare and also all the binaries in those packages, I have added a new --show-identical-binaries to abipkgdiff and fedabipkgdiff. That option shows the name of the binaries (and packages) that are compared, *even if* the ABI of those binaries are identical. Because otherwise, today, if two binaries (or packages) have the same ABI, nothing is displayed. For instance, here is the result of comparing a package against itself, using this new --show-identical-binaries options: dodji@adjoa:patches$ ./tools/fedabipkgdiff --abipkgdiff ./build/tools/abipkgdiff --show-identical-binaries dbus-glib-0.80-3.fc12.x86_64.rpm dbus-glib-0.80-3.fc12.x86_64.rpm Comparing the ABI of binaries between dbus-glib-0.80-3.fc12.x86_64.rpm and dbus-glib-0.80-3.fc12.x86_64.rpm: ================ changes of 'dbus-binding-tool'=============== No ABI change detected ================ end of changes of 'dbus-binding-tool'=============== ================ changes of 'libdbus-glib-1.so.2.1.0'=============== No ABI change detected ================ end of changes of 'libdbus-glib-1.so.2.1.0'=============== dodji@adjoa:patches$ And here is what this command before that patch would do: dodji@adjoa:patches$ ./tools/fedabipkgdiff --abipkgdiff ../master/build/tools/abipkgdiff dbus-glib-0.80-3.fc12.x86_64.rpm dbus-glib-0.80-3.fc12.x86_64.rpm Comparing the ABI of binaries between dbus-glib-0.80-3.fc12.x86_64.rpm and dbus-glib-0.80-3.fc12.x86_64.rpm: dodji@adjoa:patches$ The rest of the patch is mostly new test inputs material and the necessary adjustments following all the changes above. * configure.ac: Do not require Python dependencies itertools, unittest and StringIO anymore as they are not used anymore. Require new module tempfile now. Generate new executable script tests/mockfedabipkgdiff from tests/mockfedabipkgdiff.in. * doc/manuals/abipkgdiff.rst: Add doc for new option --show-identical-binaries to abipkgdiff * doc/manuals/fedabipkgdiff.rst: Add doc for new options --show-identical-binaries to fedabipkgdiff. * tools/abipkgdiff.cc (options::show_identical_binaries): New data member. (options::options): Initialize new data member. (display_usage): Add a new help string for the new --show-identical-binaries option. (parse_command_line): Parse the newq --show-identical-binaries command line switch. (pthread_routine_compare): When the comparison of two binaries is empty, if --show-identical-binaries was provided, then emit some output saying the comparison did yield the empty set. * tools/fedabipkgdiff (DEFAULT_ABIPKGDIFF): Store the default path to abipkgdiff in this new global variable. Naming this default path is useful because it can then be cleanly overloaded when using mock.patch. (build_path_to_abipkgdiff): Return the new DEFAULT_ABIPKGDIFF global variable. (cmd): Parse the new --show-identical-binaries command line switch. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: New reference output. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/mockfedabipkgdiff.in: New uninstalled script template. * tests/runtestfedabipkgdiff.py.in (counter) (temp_file_or_dir_prefix, UtilsTest, RPMTest, LocalRPMTest) (RunAbipkgdiffTest, GetPackageLatestBuildTest, DownloadRPMTest) (BrewListRPMsTest, AssertionHelper, MockGlobalConfig) (BUILT_ABIPKGDIFF, CompareABIFromCommandLineTest): Remove these classes, global variables and functions. (FEDABIPKGDIFF, TEST_SRC_DIR, TEST_BUILD_DIR, INPUT_DIR) (OUTPUT_DIR, FEDABIPKGDIFF_TEST_SPECS): New global variables. (ensure_output_dir_created, run_fedabipkgdiff_tests, main): New functions. * tests/test-diff-pkg.cc (in_out_specs): Add tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt to the set of reference outputs to consider. * tests/Makefile.am: Add non-installed script mockfedabipkgdiff to source distribution. Also added tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt, tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt, tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt, tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt and tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt to source distribution. Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-07-06 09:51:13 +00:00
bool show_identical_binaries;
vector<string> kabi_whitelist_packages;
vector<string> suppression_paths;
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>
2017-04-03 18:10:06 +00:00
vector<string> kabi_whitelist_paths;
suppressions_type kabi_suppressions;
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
options(const string& program_name)
: prog_name(program_name),
display_usage(),
Add --version option to several libabigail tools This patch changed the revision number of the libabigail library to make it reflect the fact that we are not in "release candidate" mode, before the first 1.0 release. So the revision number is now "rc0". The configuration manager has been updated to support version numbers that are strings, so that it can supports things like "rc0". Then, several libabigail tools have been modified to support the --version option to display their version number. * configure.ac: Set the version revision to "rc0". * doc/manuals/abicompat.rst: Adjust manual for new --version option. * doc/manuals/abidiff.rst: Likewise. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abilint.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-config.h (config::{m_format_minor, m_format_major}): Make these be strings. (config::{get,set}_format_minor_version_number): Make these return strings. (config::{get,set}_format_major_version_number): Make these return or take strings. (abigail_get_library_version): Make this take strings. * src/abg-config.cc (config::config): Adjust. (config::{get,set}_format_major_version_number): Make these return or take strings. (config::{get,set}_format_minor_version_number): Make these return strings. (abigail_get_library_version): Make this take strings. * include/abg-version.h.in: Make the version variables be strings. * src/abg-writer.cc (write_translation_unit): The version numbers are now strings so adjust. * tools/{abicompat,abidiff,abidw,abilint,abipkgdiff,abisym}.cc (options::display_version): New data member. (options::options): Initialize it. (display_usage): Add documentation for new --version option. (parse_command_line): Parse new --version option. (main): Support --version. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-11-16 10:39:15 +00:00
display_version(),
missing_operand(),
nonexistent_file(),
abignore(true),
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
parallel(true),
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
verbose(false),
Bug 21058 - abipkgdiff wrongly drops non-public types When using abipkgdiff types that are defined in files not present in the devel packages provided by the --devel1 and --devel2 option are dropped from the internal representation by default. This has been designed as such, not only to avoid showing changes on types that are not part of the public headers of a shared library, but also to help lower the memory consumption of libabigail. In this particular bug report, we see a library that uses types (in its public interface) that are defined in headers of a *different* package. For instance, suppose a particular package foo that uses types defined in headers of the glib package. And some of those Glib types can be present in its public interface. So in this case, libabigail is dropping a type that is actually part of the public interface of the library that is being analyzed, even if the type was not defined in the devel package of the current package. This patch addresses the issue by doing a number of things: 1/ If a type is defined in a file which path starts with "/usr/include/", then consider it as a public type. This is so that type coming from the public interface of other packages, and that are defined in system headers are considered as part of the public types of the package being analyzed. 2/ by default, don't drop types not defined in the associated devel package. This will hinder our ability to decrease the memory usage, but there have been a number of recent optimization that help in that regard independently. So I am hoping this shouldn't have a big impact now. Incidentally, the option --dont-drop-private-types (from abidiff) is changed into --drop-private-types, so that interested users can still drop non-private types from the model, if they wish. That --drop-private-types option is added to abipkgdiff too. As the offended types are not dropped from the model anymore, the usual filtering mechanisms of libabigail can take place. * doc/manuals/abidiff.rst (--dont-drop-private-types): Remove documentation. (--drop-private-types): Document this new option. * src/abg-tools-utils.cc: Update copyright notice (handle_fts_entry): On the generated suppression specification, do not set the flag to drop matched types. Also, don't match types defined in files which patch start with "/usr/include/". * tools/abidiff.cc (options::options): Initialize the drop_private_types data member to false. (display_usage): Remove usage string for --dont-drop-private-types. Add a new one for --drop-private-types. (parse_command_line): Don't part --dont-drop-private-types, rather, parse --drop-private-types. (set_suppressions): When the suppression for private types is generated, if --drop-private-types was provided, then instruct the suppression to drop matched types. * tools/abipkgdiff.cc (options::drop_private_types): New option. (options::options): Initialize the new drop_private_types data member to false. (display_usage): Add a usage string for --drop-private-types. (parse_command_line): Parse the new --drop-private-types option. (maybe_create_private_types_suppressions): Don't take just a package, but a package_descriptor because the latter carries the options. So when the user used the --drop-private-types option, make the generated private types suppression to drop matched types. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Adjust. * tests/test-diff-suppr.cc (in_out_specs): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-18 09:10:10 +00:00
drop_private_types(false),
Bug 20887 - Show relative change of offsets Until now, an offset change is reported by showing the old and new offsets of the data member that changed. This patch adds the string "(by +N bits)" with 'N' being the number of bits by which the offset of the data member was increased, or "(by -N bits) if the offset of the data member was decreased of N bits. The patch also emits a string that says "size hasn't changed" if the size of the structure did not change. This can be disabled by a new --no-show-relative-offset-changes option. * doc/manuals/abidiff.rst: Document the new --no-show-relative-offset-changes. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-comparison.h (diff_context::show_relative_offset_changes): New accessors. * include/abg-ir.h ({set,get}_data_member_offset): Return uint64_t instead of the less portable size_t. * src/abg-comparison.cc (diff_context::priv::show_relative_offset_changes_): New data member. (dif_context::show_relative_offset_changes): Define accessor. (maybe_show_relative_offset_change): Define new function. (represent): In the overload for var_diff, call the new maybe_show_relative_offset_change. (report_size_and_alignment_changes): If the size of the type didn't change then say it now. * src/abg-ir.cc (set_data_member_offset, get_data_member_offset): Take or return a uint64_t instead of a size_t. * tools/abidiff.cc (options::show_relative_offset_changes): New data member. (options::options): Initialize it. (display_usage): Display help string for the new --no-show-relative-offset-changes. (parse_command_line): Parse the new --no-show-relative-offset-changes options. (set_diff_context_from_opts): Set the "show-relative-offset-changes" flag according to the new option.n * tools/abipkgdiff.cc (options::show_relative_offset_changes): New data member. (options::options): Initialize it. (display_usage): Add help string for the new --no-show-relative-offset-changes option. (set_diff_context_from_opts): Set the "show-relative-offset-changes" flag according to the new option. (parse_command_line): Parse the new command line option. * tests/data/test-diff-dwarf/test40-report-0.txt: Add new reference output. * tests/data/test-diff-dwarf/test40-v0.c: Source code of the first test binary. * tests/data/test-diff-dwarf/test40-v1.c: Source code of the second test binay. * tests/data/test-diff-dwarf/libtest40-v0.so: New first test binary. * tests/data/test-diff-dwarf/libtest40-v1.so: New second test binary. * tests/test-diff-dwarf.cc (in_out_spec): Add the new test binaries above to the set of binaries that are compared. * tests/data/Makefile.am: Add the new test material to source distribution. * tests/data/test-abicompat/test7-fn-changed-report-0.txt: Adjust. * tests/data/test-abidiff/test-PR18791-report0.txt: Likewise. * tests/data/test-abidiff/test-enum0-report.txt: Likewise. * tests/data/test-abidiff/test-enum1-report.txt: Likewise. * tests/data/test-abidiff/test-struct1-report.txt: Likewise. * tests/data/test-diff-dwarf/test0-report.txt: Likewise. * tests/data/test-diff-dwarf/test1-report.txt: Likewise. * tests/data/test-diff-dwarf/test10-report.txt: Likewise. * tests/data/test-diff-dwarf/test11-report.txt: Likewise. * tests/data/test-diff-dwarf/test13-report.txt: Likewise. * tests/data/test-diff-dwarf/test15-enum-report.txt: Likewise. * tests/data/test-diff-dwarf/test27-local-base-diff-report.txt: Likewise. * tests/data/test-diff-dwarf/test32-fnptr-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test33-fnref-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test38-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test4-report.txt: Likewise. * tests/data/test-diff-dwarf/test5-report.txt: Likewise. * tests/data/test-diff-dwarf/test6-report.txt: Likewise. * tests/data/test-diff-dwarf/test8-report.txt: Likewise. * tests/data/test-diff-filter/test0-report.txt: Likewise. * tests/data/test-diff-filter/test01-report.txt: Likewise. * tests/data/test-diff-filter/test1-report.txt: Likewise. * tests/data/test-diff-filter/test13-report.txt: Likewise. * tests/data/test-diff-filter/test16-report-2.txt: Likewise. * tests/data/test-diff-filter/test16-report.txt: Likewise. * tests/data/test-diff-filter/test17-0-report.txt: Likewise. * tests/data/test-diff-filter/test17-1-report.txt: Likewise. * tests/data/test-diff-filter/test18-report.txt: Likewise. * tests/data/test-diff-filter/test19-enum-report-1.txt: Likewise. * tests/data/test-diff-filter/test2-report.txt: Likewise. * tests/data/test-diff-filter/test23-redundant-fn-parm-change-report-0.txt: Likewise. * tests/data/test-diff-filter/test24-compatible-vars-report-1.txt: Likewise. * tests/data/test-diff-filter/test25-cyclic-type-report-0.txt: Likewise. * tests/data/test-diff-filter/test25-cyclic-type-report-1.txt: Likewise. * tests/data/test-diff-filter/test26-qualified-redundant-node-report-0.t: Likewise.xt * tests/data/test-diff-filter/test26-qualified-redundant-node-report-1.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt: Likewise. * tests/data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt: Likewise. * tests/data/test-diff-filter/test3-report.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt: Likewise. * 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: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test10-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-suppr/test2-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test30-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-8.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-12-02 13:41:07 +00:00
show_relative_offset_changes(true),
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>
2016-05-30 08:37:48 +00:00
no_default_suppression(),
keep_tmp_files(),
compare_dso_only(),
Add a --leaf-changes-only option to abipkgdiff This patch adds the --leaf-changes-only option to abipkgdiff, just like what we have for abidiff. The patch also emit leaf changes report by default when comparing two Linux Kernel packages. The patch also adds the --impacted-interfaces and --full-impact options. * doc/manuals/abipkgdiff.rst: Add documentation for the new --leaf-change-only, --impacted-interfaces and --full-impact options. * tools/abipkgdiff.cc (options::{leaf_changes_only, show_impacted_interfaces, show_full_impact_report): Add new data members. (options::options): Initialize them. (display_usage): Add help strings for the new --leaf-change-only, --impacted-interfaces and --full-impact|-f options. (set_diff_context_from_opts): Set the diff context for the 'leaf-changes-only' and 'show-impacted-interfaces' flags. (parse_command_line): Parse the --leaf-change-only, --impacted-interfaces and --full-impact options. Handle the case where the --linux-kernel-abi-whitelist|-w option is given a whitelist *package*. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt: New test output reference. * tests/test-diff-pkg.cc (in_out_spec): Compare data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64.rpm and data/test-diff-pkg/spice-server-0.12.8-1.el7.x86_64.rpm with the new --leaf-changes-only and --impacted-interfaces options, using the new output reference above. * tests/data/Makefile.am: Add the new test material to source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-09-18 14:00:23 +00:00
leaf_changes_only(),
show_impacted_interfaces(),
show_full_impact_report(),
show_linkage_names(true),
show_redundant_changes(),
show_harmless_changes(),
Add the option of printing the file, line and column information about a type being reported. * bash-completion/abicompat: Complete the new "--no-show-locs" option. * bash-completion/abidiff: Likewise. * bash-completion/abidw: Likewise. * bash-completion/abipkgdiff: Likewise. * doc/manuals/abicompat.rst: Mention the new "--no-show-locs" option. * doc/manuals/abidiff.rst: Likewise. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-comparison.h (show_locs): Add declarations. * src/abg-comparison.cc: (diff_context::priv): Add a new switch called "show_locs_" and set its default value to false. (report_loc_info): New function. Outputting the extra information is conditionalized based on the associated diff contexts settings. (show_locs): define a getter/setter for diff_context::priv::show_locs_. ({distinct,pointer,reference,qualified_type,enum,class,scope,fn_parm, typedef,corpus}_diff::report): Call report_loc_info when appropriate. (maybe_report_diff_for_member): Likewise. (represent): Accept a const reference to a diff_context_sptr as a first argument and call report_loc_info on its second argument. * src/abg-dwarf-reader.cc: * tests/data/Makefile.am: Add the new test reference files. * tests/data/test-abicompat/test0-fn-changed-report-2.txt: New test reference output. * tests/data/test-abicompat/test5-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test6-var-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test7-fn-changed-report-2.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-2.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. * tests/test-abidiff.cc: Explicitly create a diff context and turn off location emitting. * tests/test-diff-dwarf.cc: Likewise. * tests/test-abicompat.cc: Add --no-show-locs to all existing test arguments. Run a few of the existing tests again, but without this option. * tests/test-diff-filter.cc: Likewise. * tests/test-diff-pkg.cc: Likewise. * tests/test-diff-suppr.cc: Likewise. * tools/abicompat.cc: Handle the new "--no-show-locs" option. * tools/abidiff.cc: Likewise. * tools/abidw.cc: Likewise. * tools/abipkgdiff.cc: Likewise. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-16 09:55:28 +00:00
show_locs(true),
show_added_syms(true),
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>
2017-04-03 18:10:06 +00:00
show_symbols_not_referenced_by_debug_info(true),
show_added_binaries(true),
Make fedabipkgdiff consistent with Libabigail's other tests In the libabigail project, almost all the tests for the tools follow a similar pattern. The test contains a set of input files to compare. The result of the comparison is thus compared to a set of reference comparison result. This approach is already documented in the CONTRIBUTING file. There are several interesting properties with this scheme. First, it capture the behaviour of the tools, including what is shown to the user. Second, it eases the job of a hacker who wants to add a new test for a new behaviour of a given tool. The user just has to provide: 1/ A new reference output of the new use case of the tool (that is easily constructed by using the tool itself and saving its output) and add an entry to array of entries that describe what to compare 2/ A new set of inputs to the tool And voila. Unfortunately, fedabipkgdiff tests don't follow this scheme. That make them surprising to hackers who read the source code of the existing tests, at very least. Also, the fedabipkgdiff tests were only unit tests. They were not testing the tool as used by users in general. This patch makes the fedabipkgdiff tests follow the general approach of the tests of the other Libabigail tools. The patch first craetes a program names tests/mockfedabipkgdiff. It's a wrapper around tools/fedabipkgdiff. It overloads the Koji client of fedabipkgdiff with a fake Koji client that gets the Fedora packages locally, from tests/data/test-fedabipkgdiff/packages. In other words, mockfedabipkgdiff is fedabipkgdiff without going to the network. I believe that in the future, tests/mockfedabipkgdiff should be killed when fedabipkgdiff is able to cache a local description of a local partial view of a Koji repository, along with the build packages that were already downloaded. That way, calling fedabipkgdiff twice with the same set of option should make the tool perform correctly without going to the netword on the second invocation. We should be able to save the local partial view of the Koji repository under e.g, tests/data/test-fedabipkgdiff/local-koji and tell fedabipkgdiff to use that, instead of using the network. But we are not there yet. So for now, I am using mockfedabipkgdiff. Then, tests/runtestfedabipkdiff.py.in has been re-written to use tests/mockfedabipkgdiff and to look like what is described in CONTRIBUTING as far as how Libabigail tools' tests are organized: mockfedabipkgdiff is called to perform a comparison. The result of the comparison is then compared (using GNU diff) to a reference comparison result file. Please note that tests/runtestfedabipkdiff.py is relatively fast for the moment. But when it contains much more tests and start becoming slow, then we'll need to change the code to run several comparisons in parallel, just like we do today in tests/test-diff-filter.cc. At that point, I believe I'll just re-write this in C++, just like tests/test-diff-filter.cc because that will allow us to have true concurrent code based on the abigail:workers API. For now, I am keeping this in Python also because I think that keeps Chenxiong happy ;-) To be sure that fedabipkgdiff (and its underlying abipkgdiff) are really comparing all the packages they are supposed to compare and also all the binaries in those packages, I have added a new --show-identical-binaries to abipkgdiff and fedabipkgdiff. That option shows the name of the binaries (and packages) that are compared, *even if* the ABI of those binaries are identical. Because otherwise, today, if two binaries (or packages) have the same ABI, nothing is displayed. For instance, here is the result of comparing a package against itself, using this new --show-identical-binaries options: dodji@adjoa:patches$ ./tools/fedabipkgdiff --abipkgdiff ./build/tools/abipkgdiff --show-identical-binaries dbus-glib-0.80-3.fc12.x86_64.rpm dbus-glib-0.80-3.fc12.x86_64.rpm Comparing the ABI of binaries between dbus-glib-0.80-3.fc12.x86_64.rpm and dbus-glib-0.80-3.fc12.x86_64.rpm: ================ changes of 'dbus-binding-tool'=============== No ABI change detected ================ end of changes of 'dbus-binding-tool'=============== ================ changes of 'libdbus-glib-1.so.2.1.0'=============== No ABI change detected ================ end of changes of 'libdbus-glib-1.so.2.1.0'=============== dodji@adjoa:patches$ And here is what this command before that patch would do: dodji@adjoa:patches$ ./tools/fedabipkgdiff --abipkgdiff ../master/build/tools/abipkgdiff dbus-glib-0.80-3.fc12.x86_64.rpm dbus-glib-0.80-3.fc12.x86_64.rpm Comparing the ABI of binaries between dbus-glib-0.80-3.fc12.x86_64.rpm and dbus-glib-0.80-3.fc12.x86_64.rpm: dodji@adjoa:patches$ The rest of the patch is mostly new test inputs material and the necessary adjustments following all the changes above. * configure.ac: Do not require Python dependencies itertools, unittest and StringIO anymore as they are not used anymore. Require new module tempfile now. Generate new executable script tests/mockfedabipkgdiff from tests/mockfedabipkgdiff.in. * doc/manuals/abipkgdiff.rst: Add doc for new option --show-identical-binaries to abipkgdiff * doc/manuals/fedabipkgdiff.rst: Add doc for new options --show-identical-binaries to fedabipkgdiff. * tools/abipkgdiff.cc (options::show_identical_binaries): New data member. (options::options): Initialize new data member. (display_usage): Add a new help string for the new --show-identical-binaries option. (parse_command_line): Parse the newq --show-identical-binaries command line switch. (pthread_routine_compare): When the comparison of two binaries is empty, if --show-identical-binaries was provided, then emit some output saying the comparison did yield the empty set. * tools/fedabipkgdiff (DEFAULT_ABIPKGDIFF): Store the default path to abipkgdiff in this new global variable. Naming this default path is useful because it can then be cleanly overloaded when using mock.patch. (build_path_to_abipkgdiff): Return the new DEFAULT_ABIPKGDIFF global variable. (cmd): Parse the new --show-identical-binaries command line switch. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: New reference output. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/mockfedabipkgdiff.in: New uninstalled script template. * tests/runtestfedabipkgdiff.py.in (counter) (temp_file_or_dir_prefix, UtilsTest, RPMTest, LocalRPMTest) (RunAbipkgdiffTest, GetPackageLatestBuildTest, DownloadRPMTest) (BrewListRPMsTest, AssertionHelper, MockGlobalConfig) (BUILT_ABIPKGDIFF, CompareABIFromCommandLineTest): Remove these classes, global variables and functions. (FEDABIPKGDIFF, TEST_SRC_DIR, TEST_BUILD_DIR, INPUT_DIR) (OUTPUT_DIR, FEDABIPKGDIFF_TEST_SPECS): New global variables. (ensure_output_dir_created, run_fedabipkgdiff_tests, main): New functions. * tests/test-diff-pkg.cc (in_out_specs): Add tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt to the set of reference outputs to consider. * tests/Makefile.am: Add non-installed script mockfedabipkgdiff to source distribution. Also added tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt, tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt, tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt, tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt and tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt to source distribution. Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-07-06 09:51:13 +00:00
fail_if_no_debug_info(),
show_identical_binaries()
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
{
// set num_workers to the default number of threads of the
// underlying maching. This is the default value for the number
// of workers to use in workers queues throughout the code.
num_workers = abigail::workers::get_number_of_threads();
}
};
Bug 22488 - Make abipkgdiff handle different binaries with same basename Some packages might have different binaries with the same soname and basename, but at different paths. In that case, abipkgdiff messes things up because it only either consider the soname or the basename of the binary. This patch makes abipkgdiff to always consider the full path of the binary inside the package. * include/abg-tools-utils.h (string_suffix) (sorted_strings_common_prefix): Declare new functions. (dir_name): Take a new keep_separator_at_end parameter at the end. * src/abg-tools-utils.cc (dir_name): Take a new keep_separator_at_end parameter at the end. Add a comment for it and update. (string_suffix, sorted_strings_common_prefix): Define new functions. (common_prefix): Define new static function. * tools/abipkgdiff.cc (get_interesting_files_under_dir): Forward declare this pre-existing static function. (package::{common_paths_prefix_, elf_file_paths_}): New data members. (package::{common_paths_prefix, elf_file_paths, convert_path_to_relative, convert_path_to_unique_suffix, load_elf_file_paths}): New member functions. (create_maps_of_package_content): Use the new package::{load_elf_file_paths, convert_path_to_unique_suffix} functions. (compare_prepared_userspace_packages): Show relative paths of package elements in reported. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Update test ouptut. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-12-01 13:52:23 +00:00
static bool
get_interesting_files_under_dir(const string dir,
const string& file_name_to_look_for,
options& opts,
vector<string>& interesting_files);
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
/// Abstract ELF files from the packages which ABIs ought to be
/// compared
class elf_file
{
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
private:
elf_file();
public:
string path;
string name;
string soname;
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
off_t size;
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
abigail::dwarf_reader::elf_type type;
/// The path to the elf file.
///
/// @param path the path to the elf file.
elf_file(const string& path)
: path(path)
{
abigail::tools_utils::base_name(path, name);
get_soname_of_elf_file(path, soname);
get_type_of_elf_file(path, type);
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
struct stat estat;
stat(path.c_str(), &estat);
size = estat.st_size;
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
}
};
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
/// A convenience typedef for a shared pointer to elf_file.
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
typedef shared_ptr<elf_file> elf_file_sptr;
/// Abstract the result of comparing two packages.
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
///
/// This contains the the paths of the set of added binaries, removed
/// binaries, and binaries whic ABI changed.
struct abi_diff
{
vector<elf_file_sptr> added_binaries;
vector<elf_file_sptr> removed_binaries;
vector<string> changed_binaries;
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
/// Test if the current diff carries changes.
///
/// @return true iff the current diff carries changes.
bool
has_changes()
{
return (!added_binaries.empty()
|| !removed_binaries.empty()
||!changed_binaries.empty());
}
};
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>
2016-05-20 07:19:51 +00:00
class package;
/// Convenience typedef for a shared pointer to a @ref package.
typedef shared_ptr<package> package_sptr;
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
/// Abstracts a package.
class package
{
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>
2016-05-20 07:19:51 +00:00
public:
/// The kind of package we are looking at.
enum kind
{
/// Main package. Contains binaries to ABI-compare.
KIND_MAIN = 0,
/// Devel package. Contains public headers files in which public
/// types are defined.
KIND_DEVEL,
/// Debug info package. Contains the debug info for the binaries
/// int he main packge.
KIND_DEBUG_INFO,
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>
2017-04-03 18:10:06 +00:00
/// Contains kernel ABI whitelists
KIND_KABI_WHITELISTS,
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>
2016-05-20 07:19:51 +00:00
/// Source package. Contains the source of the binaries in the
/// main package.
KIND_SRC
};
private:
string path_;
string extracted_dir_path_;
Bug 22488 - Make abipkgdiff handle different binaries with same basename Some packages might have different binaries with the same soname and basename, but at different paths. In that case, abipkgdiff messes things up because it only either consider the soname or the basename of the binary. This patch makes abipkgdiff to always consider the full path of the binary inside the package. * include/abg-tools-utils.h (string_suffix) (sorted_strings_common_prefix): Declare new functions. (dir_name): Take a new keep_separator_at_end parameter at the end. * src/abg-tools-utils.cc (dir_name): Take a new keep_separator_at_end parameter at the end. Add a comment for it and update. (string_suffix, sorted_strings_common_prefix): Define new functions. (common_prefix): Define new static function. * tools/abipkgdiff.cc (get_interesting_files_under_dir): Forward declare this pre-existing static function. (package::{common_paths_prefix_, elf_file_paths_}): New data members. (package::{common_paths_prefix, elf_file_paths, convert_path_to_relative, convert_path_to_unique_suffix, load_elf_file_paths}): New member functions. (create_maps_of_package_content): Use the new package::{load_elf_file_paths, convert_path_to_unique_suffix} functions. (compare_prepared_userspace_packages): Show relative paths of package elements in reported. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Update test ouptut. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-12-01 13:52:23 +00:00
string common_paths_prefix_;
abigail::tools_utils::file_type type_;
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>
2016-05-20 07:19:51 +00:00
kind kind_;
map<string, elf_file_sptr> path_elf_file_sptr_map_;
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
vector<package_sptr> debug_info_packages_;
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>
2016-05-20 07:19:51 +00:00
package_sptr devel_package_;
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>
2017-04-03 18:10:06 +00:00
package_sptr kabi_whitelist_package_;
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>
2016-05-20 07:19:51 +00:00
suppressions_type private_types_suppressions_;
Bug 22488 - Make abipkgdiff handle different binaries with same basename Some packages might have different binaries with the same soname and basename, but at different paths. In that case, abipkgdiff messes things up because it only either consider the soname or the basename of the binary. This patch makes abipkgdiff to always consider the full path of the binary inside the package. * include/abg-tools-utils.h (string_suffix) (sorted_strings_common_prefix): Declare new functions. (dir_name): Take a new keep_separator_at_end parameter at the end. * src/abg-tools-utils.cc (dir_name): Take a new keep_separator_at_end parameter at the end. Add a comment for it and update. (string_suffix, sorted_strings_common_prefix): Define new functions. (common_prefix): Define new static function. * tools/abipkgdiff.cc (get_interesting_files_under_dir): Forward declare this pre-existing static function. (package::{common_paths_prefix_, elf_file_paths_}): New data members. (package::{common_paths_prefix, elf_file_paths, convert_path_to_relative, convert_path_to_unique_suffix, load_elf_file_paths}): New member functions. (create_maps_of_package_content): Use the new package::{load_elf_file_paths, convert_path_to_unique_suffix} functions. (compare_prepared_userspace_packages): Show relative paths of package elements in reported. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Update test ouptut. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-12-01 13:52:23 +00:00
vector<string> elf_file_paths_;
public:
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
/// Constructor for the @ref package type.
///
/// @param path the path to the package.
///
/// @parm dir the temporary directory where to extract the content
/// of the package.
///
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>
2016-05-20 07:19:51 +00:00
/// @param pkg_kind the kind of package.
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
package(const string& path,
const string& dir,
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>
2016-05-20 07:19:51 +00:00
kind pkg_kind = package::KIND_MAIN)
: path_(path),
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>
2016-05-20 07:19:51 +00:00
kind_(pkg_kind)
{
type_ = guess_file_type(path);
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>
2015-08-22 09:44:08 +00:00
if (type_ == abigail::tools_utils::FILE_TYPE_DIR)
extracted_dir_path_ = path;
else
extracted_dir_path_ = extracted_packages_parent_dir() + "/" + dir;
}
/// Getter of the path of the package.
///
/// @return the path of the package.
const string&
path() const
{return path_;}
/// Setter of the path of the package.
///
/// @param s the new path.
void
path(const string& s)
{path_ = s;}
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>
2017-04-03 18:10:06 +00:00
/// Getter of the base name of the package.
///
/// @return the base name of the package.
string
base_name() const
{
string name;
abigail::tools_utils::base_name(path(), name);
return name;
}
/// Getter for the path to the root dir where the packages are
/// extracted.
///
/// @return the path to the root dir where the packages are
/// extracted.
static const string&
extracted_packages_parent_dir();
/// Getter for the path to the directory where the packages are
/// extracted for the current thread.
///
/// @return the path to the directory where the packages are
/// extracted for the current thread.
const string&
extracted_dir_path() const
{return extracted_dir_path_;}
/// Setter for the path to the directory where the packages are
/// extracted for the current thread.
///
/// @param p the new path.
void
extracted_dir_path(const string& p)
{extracted_dir_path_ = p;}
Bug 22488 - Make abipkgdiff handle different binaries with same basename Some packages might have different binaries with the same soname and basename, but at different paths. In that case, abipkgdiff messes things up because it only either consider the soname or the basename of the binary. This patch makes abipkgdiff to always consider the full path of the binary inside the package. * include/abg-tools-utils.h (string_suffix) (sorted_strings_common_prefix): Declare new functions. (dir_name): Take a new keep_separator_at_end parameter at the end. * src/abg-tools-utils.cc (dir_name): Take a new keep_separator_at_end parameter at the end. Add a comment for it and update. (string_suffix, sorted_strings_common_prefix): Define new functions. (common_prefix): Define new static function. * tools/abipkgdiff.cc (get_interesting_files_under_dir): Forward declare this pre-existing static function. (package::{common_paths_prefix_, elf_file_paths_}): New data members. (package::{common_paths_prefix, elf_file_paths, convert_path_to_relative, convert_path_to_unique_suffix, load_elf_file_paths}): New member functions. (create_maps_of_package_content): Use the new package::{load_elf_file_paths, convert_path_to_unique_suffix} functions. (compare_prepared_userspace_packages): Show relative paths of package elements in reported. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Update test ouptut. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-12-01 13:52:23 +00:00
/// Getter of the the prefix that is common to all the paths of all
/// the elements of the package.
///
/// @return the common path prefix of package elements.
const string&
common_paths_prefix() const
{return common_paths_prefix_;}
/// Getter of the the prefix that is common to all the paths of all
/// the elements of the package.
///
/// @return the common path prefix of package elements.
string&
common_paths_prefix()
{return common_paths_prefix_;}
/// Setter of the the prefix that is common to all the paths of all
/// the elements of the package.
///
///
///@param p the new prefix.
void
common_paths_prefix(const string& p)
{common_paths_prefix_ = p;}
/// Getter for the file type of the current package.
///
/// @return the file type of the current package.
abigail::tools_utils::file_type
type() const
{return type_;}
/// Setter for the file type of the current package.
///
/// @param t the new file type.
void type(abigail::tools_utils::file_type t)
{type_ = t;}
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>
2016-05-20 07:19:51 +00:00
/// Get the package kind
///
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>
2016-05-20 07:19:51 +00:00
/// @return the package kind
kind
get_kind() const
{return kind_;}
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>
2016-05-20 07:19:51 +00:00
/// Set the package kind
///
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>
2016-05-20 07:19:51 +00:00
/// @param k the package kind.
void
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>
2016-05-20 07:19:51 +00:00
set_kind(kind k)
{kind_ = k;}
/// Getter for the path <-> elf_file map.
///
/// @return the the path <-> elf_file map.
const map<string, elf_file_sptr>&
path_elf_file_sptr_map() const
{return path_elf_file_sptr_map_;}
/// Getter for the path <-> elf_file map.
///
/// @return the the path <-> elf_file map.
map<string, elf_file_sptr>&
path_elf_file_sptr_map()
{return path_elf_file_sptr_map_;}
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
/// Getter for the debug info packages associated to the current
/// package.
///
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
/// There can indeed be several debug info packages needed for one
/// input package, as the debug info for that input package can be
/// split across several debuginfo packages.
///
/// @return the debug info packages associated to the current
/// package.
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
const vector<package_sptr>&
debug_info_packages() const
{return debug_info_packages_;}
/// Getter for the debug info packages associated to the current
/// package.
///
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
/// There can indeed be several debug info packages needed for one
/// input package, as the debug info for that input package can be
/// split across several debuginfo packages.
///
/// @return the debug info packages associated to the current
/// package.
vector<package_sptr>&
debug_info_packages()
{return debug_info_packages_;}
/// Setter for the debug info packages associated to the current
/// package.
///
/// There can indeed be several debug info packages needed for one
/// input package, as the debug info for that input package can be
/// split across several debuginfo packages.
///
/// @param p the new debug info package.
void
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
debug_info_packages(const vector<package_sptr> &p)
{debug_info_packages_ = p;}
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>
2016-05-20 07:19:51 +00:00
/// Getter for the devel package associated to the current package.
///
/// @return the devel package associated to the current package.
const package_sptr&
devel_package() const
{return devel_package_;}
/// Setter of the devel package associated to the current package.
///
/// @param p the new devel package associated to the current package.
void
devel_package(const package_sptr& p)
{devel_package_ = p;}
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>
2017-04-03 18:10:06 +00:00
/// Getter of the associated kernel abi whitelist package, if any.
///
/// @return the associated kernel abi whitelist package.
const package_sptr
kabi_whitelist_package() const
{return kabi_whitelist_package_;}
/// Setter of the associated kernel abi whitelist package.
///
/// @param p the new kernel abi whitelist package.
void
kabi_whitelist_package(const package_sptr& p)
{kabi_whitelist_package_ = p;}
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>
2016-05-20 07:19:51 +00:00
/// Getter of the specifications to suppress change reports about
/// private types.
///
/// @return the vector of specifications to suppress change reports
/// about private types.
const suppressions_type&
private_types_suppressions() const
{return private_types_suppressions_;}
/// Getter of the specifications to suppress change reports about
/// private types.
///
/// @return the vector of specifications to suppress change reports
/// about private types.
suppressions_type&
private_types_suppressions()
{return private_types_suppressions_;}
Bug 22488 - Make abipkgdiff handle different binaries with same basename Some packages might have different binaries with the same soname and basename, but at different paths. In that case, abipkgdiff messes things up because it only either consider the soname or the basename of the binary. This patch makes abipkgdiff to always consider the full path of the binary inside the package. * include/abg-tools-utils.h (string_suffix) (sorted_strings_common_prefix): Declare new functions. (dir_name): Take a new keep_separator_at_end parameter at the end. * src/abg-tools-utils.cc (dir_name): Take a new keep_separator_at_end parameter at the end. Add a comment for it and update. (string_suffix, sorted_strings_common_prefix): Define new functions. (common_prefix): Define new static function. * tools/abipkgdiff.cc (get_interesting_files_under_dir): Forward declare this pre-existing static function. (package::{common_paths_prefix_, elf_file_paths_}): New data members. (package::{common_paths_prefix, elf_file_paths, convert_path_to_relative, convert_path_to_unique_suffix, load_elf_file_paths}): New member functions. (create_maps_of_package_content): Use the new package::{load_elf_file_paths, convert_path_to_unique_suffix} functions. (compare_prepared_userspace_packages): Show relative paths of package elements in reported. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Update test ouptut. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-12-01 13:52:23 +00:00
/// Getter of the path to the elf files of the package.
///
/// @return the path tothe elf files of the package.
const vector<string>&
elf_file_paths() const
{return elf_file_paths_;}
/// Getter of the path to the elf files of the package.
///
/// @return the path tothe elf files of the package.
vector<string>&
elf_file_paths()
{return elf_file_paths_;}
/// Convert the absolute path of an element of this package into a
/// path relative to the root path pointing to this package.
///
/// That is, suppose the content of a package named 'pkg' is located
/// at /root/path/pkg. Suppose an element of that package is named
/// is at '/root/path/pkg/somewhere/inside/element'.
///
/// This function will return the path:
/// /pkg/somewhere/inside/element.
///
/// @param path the path to consider.
///
/// @param converted_path the resulting converted path. This is set
/// iff the function returns true.
///
/// @return true if the path could be converted to being relative to
/// the extracted directory.
bool
convert_path_to_relative(const string& path, string& converted_path) const
{return string_suffix(path, extracted_dir_path(), converted_path);}
// Convert the absolute path of an element of this package into a
// path relative to the prefix common to the paths of all elements
// of the package.
//
// @param path the path to conver.
//
// @param converted_path the resulting converted path. This is set
// iff the function returns true.
//
// @return true iff the function could successfully convert @p path
// and put the result into @p converted_path.
bool
convert_path_to_unique_suffix(const string& path,
string& converted_path) const
{return string_suffix(path, common_paths_prefix(), converted_path);}
/// Retrieve the set of "interesting" package element paths by
/// walking the package.
///
/// And then compute the path prefix that is common to all the
/// collected elements.
///
/// @param the options of this application.
void
load_elf_file_paths(options& opts)
{
if (!common_paths_prefix().empty()
|| !elf_file_paths().empty())
// We have already loaded the elf file paths, don't do it again.
return;
get_interesting_files_under_dir(extracted_dir_path(),
/*file_name_to_look_for=*/"",
opts, elf_file_paths());
std::sort(elf_file_paths().begin(), elf_file_paths().end());
string common_prefix;
sorted_strings_common_prefix(elf_file_paths(), common_paths_prefix());
}
/// Erase the content of the temporary extraction directory that has
/// been populated by the @ref extract_package() function;
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
///
/// @param opts the options passed to the current program.
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
void
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
erase_extraction_directory(const options &opts) const
{
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>
2015-08-22 09:44:08 +00:00
if (type() == abigail::tools_utils::FILE_TYPE_DIR)
// If we are comparing two directories, do not erase the
// directory as it was provided by the user; it's not a
// temporary directory we created ourselves.
return;
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Erasing temporary extraction directory "
<< extracted_dir_path()
<< " ...";
string cmd = "rm -rf " + extracted_dir_path();
if (system(cmd.c_str()))
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr) << " FAILED\n";
}
else
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr) << " DONE\n";
}
}
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
/// Erase the content of all the temporary extraction directories.
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
///
/// @param opts the options passed to the current program.
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
void
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
erase_extraction_directories(const options &opts) const
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
erase_extraction_directory(opts);
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
if (!debug_info_packages().empty())
debug_info_packages().front()->erase_extraction_directory(opts);
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>
2016-05-20 07:19:51 +00:00
if (devel_package())
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
devel_package()->erase_extraction_directory(opts);
if (kabi_whitelist_package())
kabi_whitelist_package()->erase_extraction_directory(opts);
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
}; // end class package.
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// Arguments passed to the comparison tasks.
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
struct compare_args
{
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>
2017-04-03 18:10:06 +00:00
const elf_file elf1;
const string& debug_dir1;
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>
2016-05-20 07:19:51 +00:00
const suppressions_type& private_types_suppr1;
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>
2017-04-03 18:10:06 +00:00
const elf_file elf2;
const string& debug_dir2;
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>
2016-05-20 07:19:51 +00:00
const suppressions_type& private_types_suppr2;
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>
2017-04-03 18:10:06 +00:00
const options& opts;
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
/// Constructor for compare_args, which is used to pass
/// information to the comparison threads.
///
/// @param elf1 the first elf file to consider.
///
/// @param debug_dir1 the directory where the debug info file for @p
/// elf1 is stored.
///
/// @param elf2 the second elf file to consider.
///
/// @param debug_dir2 the directory where the debug info file for @p
/// elf2 is stored.
///
/// @param opts the options the current program has been called with.
compare_args(const elf_file &elf1, const string& debug_dir1,
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>
2016-05-20 07:19:51 +00:00
const suppressions_type& priv_types_suppr1,
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
const elf_file &elf2, const string& debug_dir2,
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>
2016-05-20 07:19:51 +00:00
const suppressions_type& priv_types_suppr2,
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
const options& opts)
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>
2016-05-20 07:19:51 +00:00
: elf1(elf1), debug_dir1(debug_dir1),
private_types_suppr1(priv_types_suppr1),
elf2(elf2), debug_dir2(debug_dir2),
private_types_suppr2(priv_types_suppr2),
opts(opts)
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
{}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
}; // end struct compare_args
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
/// A convenience typedef for arguments passed to the comparison workers.
typedef shared_ptr<compare_args> compare_args_sptr;
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
static bool extract_package_and_map_its_content(const package_sptr &pkg,
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
options &opts);
/// Getter for the path to the parent directory under which packages
/// extracted by the current thread are placed.
///
/// @return the path to the parent directory under which packages
/// extracted by the current thread are placed.
const string&
package::extracted_packages_parent_dir()
{
// I tried to declare this in thread-local storage, but GCC 4.4.7
// won't let me. So for now, I am just making it static. I'll deal
// with this later when I have to.
//static __thread string p;
static string p;
if (p.empty())
{
const char *cachedir = getenv("XDG_CACHE_HOME");
if (cachedir != NULL)
p = cachedir;
else
{
const char* s = getenv("HOME");
if (s != NULL)
p = s;
if (p.empty())
{
s = getenv("TMPDIR");
if (s != NULL)
p = s;
else
p = "/tmp";
}
p += "/.cache/libabigail";
}
// Create the cache directory if it doesn't exist
bool cache_dir_is_created = ensure_dir_path_created(p);
assert(cache_dir_is_created);
string libabigail_tmp_dir_template = p;
libabigail_tmp_dir_template += "/abipkgdiff-tmp-dir-XXXXXX";
if (!mkdtemp(const_cast<char*>(libabigail_tmp_dir_template.c_str())))
abort();
p = libabigail_tmp_dir_template;
}
return p;
}
/// A convenience typedef for shared_ptr of package.
typedef shared_ptr<package> package_sptr;
/// Show the usage of this program.
///
/// @param prog_name the name of the program.
///
/// @param out the output stream to emit the usage to .
static void
display_usage(const string& prog_name, ostream& out)
{
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix(prog_name, out)
<< "usage: " << prog_name << " [options] <package1> <package2>\n"
<< " where options can be:\n"
<< " --debug-info-pkg1|--d1 <path> path of debug-info package of package1\n"
<< " --debug-info-pkg2|--d2 <path> path of debug-info package of package2\n"
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>
2016-05-20 07:19:51 +00:00
<< " --devel-pkg1|--devel1 <path> path of devel package of pakage1\n"
<< " --devel-pkg2|--devel2 <path> path of devel package of pakage1\n"
<< " --drop-private-types drop private types from "
Bug 21058 - abipkgdiff wrongly drops non-public types When using abipkgdiff types that are defined in files not present in the devel packages provided by the --devel1 and --devel2 option are dropped from the internal representation by default. This has been designed as such, not only to avoid showing changes on types that are not part of the public headers of a shared library, but also to help lower the memory consumption of libabigail. In this particular bug report, we see a library that uses types (in its public interface) that are defined in headers of a *different* package. For instance, suppose a particular package foo that uses types defined in headers of the glib package. And some of those Glib types can be present in its public interface. So in this case, libabigail is dropping a type that is actually part of the public interface of the library that is being analyzed, even if the type was not defined in the devel package of the current package. This patch addresses the issue by doing a number of things: 1/ If a type is defined in a file which path starts with "/usr/include/", then consider it as a public type. This is so that type coming from the public interface of other packages, and that are defined in system headers are considered as part of the public types of the package being analyzed. 2/ by default, don't drop types not defined in the associated devel package. This will hinder our ability to decrease the memory usage, but there have been a number of recent optimization that help in that regard independently. So I am hoping this shouldn't have a big impact now. Incidentally, the option --dont-drop-private-types (from abidiff) is changed into --drop-private-types, so that interested users can still drop non-private types from the model, if they wish. That --drop-private-types option is added to abipkgdiff too. As the offended types are not dropped from the model anymore, the usual filtering mechanisms of libabigail can take place. * doc/manuals/abidiff.rst (--dont-drop-private-types): Remove documentation. (--drop-private-types): Document this new option. * src/abg-tools-utils.cc: Update copyright notice (handle_fts_entry): On the generated suppression specification, do not set the flag to drop matched types. Also, don't match types defined in files which patch start with "/usr/include/". * tools/abidiff.cc (options::options): Initialize the drop_private_types data member to false. (display_usage): Remove usage string for --dont-drop-private-types. Add a new one for --drop-private-types. (parse_command_line): Don't part --dont-drop-private-types, rather, parse --drop-private-types. (set_suppressions): When the suppression for private types is generated, if --drop-private-types was provided, then instruct the suppression to drop matched types. * tools/abipkgdiff.cc (options::drop_private_types): New option. (options::options): Initialize the new drop_private_types data member to false. (display_usage): Add a usage string for --drop-private-types. (parse_command_line): Parse the new --drop-private-types option. (maybe_create_private_types_suppressions): Don't take just a package, but a package_descriptor because the latter carries the options. So when the user used the --drop-private-types option, make the generated private types suppression to drop matched types. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Adjust. * tests/test-diff-suppr.cc (in_out_specs): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-18 09:10:10 +00:00
"internal representation\n"
<< " --no-default-suppression don't load any default "
"suppression specifications\n"
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
<< " --suppressions|--suppr <path> specify supression specification path\n"
<< " --linux-kernel-abi-whitelist|-w path to a "
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>
2017-04-03 18:10:06 +00:00
"linux kernel abi whitelist\n"
<< " --wp <path> path to a linux kernel abi whitelist package\n"
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
<< " --keep-tmp-files don't erase created temporary files\n"
<< " --dso-only compare shared libraries only\n"
Add a --leaf-changes-only option to abipkgdiff This patch adds the --leaf-changes-only option to abipkgdiff, just like what we have for abidiff. The patch also emit leaf changes report by default when comparing two Linux Kernel packages. The patch also adds the --impacted-interfaces and --full-impact options. * doc/manuals/abipkgdiff.rst: Add documentation for the new --leaf-change-only, --impacted-interfaces and --full-impact options. * tools/abipkgdiff.cc (options::{leaf_changes_only, show_impacted_interfaces, show_full_impact_report): Add new data members. (options::options): Initialize them. (display_usage): Add help strings for the new --leaf-change-only, --impacted-interfaces and --full-impact|-f options. (set_diff_context_from_opts): Set the diff context for the 'leaf-changes-only' and 'show-impacted-interfaces' flags. (parse_command_line): Parse the --leaf-change-only, --impacted-interfaces and --full-impact options. Handle the case where the --linux-kernel-abi-whitelist|-w option is given a whitelist *package*. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt: New test output reference. * tests/test-diff-pkg.cc (in_out_spec): Compare data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64.rpm and data/test-diff-pkg/spice-server-0.12.8-1.el7.x86_64.rpm with the new --leaf-changes-only and --impacted-interfaces options, using the new output reference above. * tests/data/Makefile.am: Add the new test material to source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-09-18 14:00:23 +00:00
<< " --leaf-changes-only|-l only show leaf changes, "
"so no change impact analysis\n"
<< " --impacted-interfaces|-i when in leaf mode, show "
"interfaces impacted by ABI changes\n"
<< " --full-impact|-f when comparing kernel packages, show the "
"full impact analysis report rather than the default leaf changes reports\n"
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>
2016-05-20 07:19:51 +00:00
<< " --no-linkage-name do not display linkage names of "
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
"added/removed/changed\n"
<< " --redundant display redundant changes\n"
<< " --harmless display the harmless changes\n"
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
<< " --no-show-locs do not show location information\n"
Bug 20887 - Show relative change of offsets Until now, an offset change is reported by showing the old and new offsets of the data member that changed. This patch adds the string "(by +N bits)" with 'N' being the number of bits by which the offset of the data member was increased, or "(by -N bits) if the offset of the data member was decreased of N bits. The patch also emits a string that says "size hasn't changed" if the size of the structure did not change. This can be disabled by a new --no-show-relative-offset-changes option. * doc/manuals/abidiff.rst: Document the new --no-show-relative-offset-changes. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-comparison.h (diff_context::show_relative_offset_changes): New accessors. * include/abg-ir.h ({set,get}_data_member_offset): Return uint64_t instead of the less portable size_t. * src/abg-comparison.cc (diff_context::priv::show_relative_offset_changes_): New data member. (dif_context::show_relative_offset_changes): Define accessor. (maybe_show_relative_offset_change): Define new function. (represent): In the overload for var_diff, call the new maybe_show_relative_offset_change. (report_size_and_alignment_changes): If the size of the type didn't change then say it now. * src/abg-ir.cc (set_data_member_offset, get_data_member_offset): Take or return a uint64_t instead of a size_t. * tools/abidiff.cc (options::show_relative_offset_changes): New data member. (options::options): Initialize it. (display_usage): Display help string for the new --no-show-relative-offset-changes. (parse_command_line): Parse the new --no-show-relative-offset-changes options. (set_diff_context_from_opts): Set the "show-relative-offset-changes" flag according to the new option.n * tools/abipkgdiff.cc (options::show_relative_offset_changes): New data member. (options::options): Initialize it. (display_usage): Add help string for the new --no-show-relative-offset-changes option. (set_diff_context_from_opts): Set the "show-relative-offset-changes" flag according to the new option. (parse_command_line): Parse the new command line option. * tests/data/test-diff-dwarf/test40-report-0.txt: Add new reference output. * tests/data/test-diff-dwarf/test40-v0.c: Source code of the first test binary. * tests/data/test-diff-dwarf/test40-v1.c: Source code of the second test binay. * tests/data/test-diff-dwarf/libtest40-v0.so: New first test binary. * tests/data/test-diff-dwarf/libtest40-v1.so: New second test binary. * tests/test-diff-dwarf.cc (in_out_spec): Add the new test binaries above to the set of binaries that are compared. * tests/data/Makefile.am: Add the new test material to source distribution. * tests/data/test-abicompat/test7-fn-changed-report-0.txt: Adjust. * tests/data/test-abidiff/test-PR18791-report0.txt: Likewise. * tests/data/test-abidiff/test-enum0-report.txt: Likewise. * tests/data/test-abidiff/test-enum1-report.txt: Likewise. * tests/data/test-abidiff/test-struct1-report.txt: Likewise. * tests/data/test-diff-dwarf/test0-report.txt: Likewise. * tests/data/test-diff-dwarf/test1-report.txt: Likewise. * tests/data/test-diff-dwarf/test10-report.txt: Likewise. * tests/data/test-diff-dwarf/test11-report.txt: Likewise. * tests/data/test-diff-dwarf/test13-report.txt: Likewise. * tests/data/test-diff-dwarf/test15-enum-report.txt: Likewise. * tests/data/test-diff-dwarf/test27-local-base-diff-report.txt: Likewise. * tests/data/test-diff-dwarf/test32-fnptr-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test33-fnref-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test38-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test4-report.txt: Likewise. * tests/data/test-diff-dwarf/test5-report.txt: Likewise. * tests/data/test-diff-dwarf/test6-report.txt: Likewise. * tests/data/test-diff-dwarf/test8-report.txt: Likewise. * tests/data/test-diff-filter/test0-report.txt: Likewise. * tests/data/test-diff-filter/test01-report.txt: Likewise. * tests/data/test-diff-filter/test1-report.txt: Likewise. * tests/data/test-diff-filter/test13-report.txt: Likewise. * tests/data/test-diff-filter/test16-report-2.txt: Likewise. * tests/data/test-diff-filter/test16-report.txt: Likewise. * tests/data/test-diff-filter/test17-0-report.txt: Likewise. * tests/data/test-diff-filter/test17-1-report.txt: Likewise. * tests/data/test-diff-filter/test18-report.txt: Likewise. * tests/data/test-diff-filter/test19-enum-report-1.txt: Likewise. * tests/data/test-diff-filter/test2-report.txt: Likewise. * tests/data/test-diff-filter/test23-redundant-fn-parm-change-report-0.txt: Likewise. * tests/data/test-diff-filter/test24-compatible-vars-report-1.txt: Likewise. * tests/data/test-diff-filter/test25-cyclic-type-report-0.txt: Likewise. * tests/data/test-diff-filter/test25-cyclic-type-report-1.txt: Likewise. * tests/data/test-diff-filter/test26-qualified-redundant-node-report-0.t: Likewise.xt * tests/data/test-diff-filter/test26-qualified-redundant-node-report-1.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt: Likewise. * tests/data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt: Likewise. * tests/data/test-diff-filter/test3-report.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt: Likewise. * 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: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test10-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-suppr/test2-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test30-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-8.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-12-02 13:41:07 +00:00
<< " --no-show-relative-offset-changes do not show relative"
" offset changes\n"
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
<< " --no-added-syms do not display added functions or variables\n"
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>
2017-04-03 18:10:06 +00:00
<< " --no-unreferenced-symbols do not display changes "
"about symbols not referenced by debug info\n"
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
<< " --no-added-binaries do not display added binaries\n"
<< " --no-abignore do not look for *.abignore files\n"
<< " --no-parallel do not execute in parallel\n"
<< " --fail-no-dbg fail if no debug info was found\n"
Make fedabipkgdiff consistent with Libabigail's other tests In the libabigail project, almost all the tests for the tools follow a similar pattern. The test contains a set of input files to compare. The result of the comparison is thus compared to a set of reference comparison result. This approach is already documented in the CONTRIBUTING file. There are several interesting properties with this scheme. First, it capture the behaviour of the tools, including what is shown to the user. Second, it eases the job of a hacker who wants to add a new test for a new behaviour of a given tool. The user just has to provide: 1/ A new reference output of the new use case of the tool (that is easily constructed by using the tool itself and saving its output) and add an entry to array of entries that describe what to compare 2/ A new set of inputs to the tool And voila. Unfortunately, fedabipkgdiff tests don't follow this scheme. That make them surprising to hackers who read the source code of the existing tests, at very least. Also, the fedabipkgdiff tests were only unit tests. They were not testing the tool as used by users in general. This patch makes the fedabipkgdiff tests follow the general approach of the tests of the other Libabigail tools. The patch first craetes a program names tests/mockfedabipkgdiff. It's a wrapper around tools/fedabipkgdiff. It overloads the Koji client of fedabipkgdiff with a fake Koji client that gets the Fedora packages locally, from tests/data/test-fedabipkgdiff/packages. In other words, mockfedabipkgdiff is fedabipkgdiff without going to the network. I believe that in the future, tests/mockfedabipkgdiff should be killed when fedabipkgdiff is able to cache a local description of a local partial view of a Koji repository, along with the build packages that were already downloaded. That way, calling fedabipkgdiff twice with the same set of option should make the tool perform correctly without going to the netword on the second invocation. We should be able to save the local partial view of the Koji repository under e.g, tests/data/test-fedabipkgdiff/local-koji and tell fedabipkgdiff to use that, instead of using the network. But we are not there yet. So for now, I am using mockfedabipkgdiff. Then, tests/runtestfedabipkdiff.py.in has been re-written to use tests/mockfedabipkgdiff and to look like what is described in CONTRIBUTING as far as how Libabigail tools' tests are organized: mockfedabipkgdiff is called to perform a comparison. The result of the comparison is then compared (using GNU diff) to a reference comparison result file. Please note that tests/runtestfedabipkdiff.py is relatively fast for the moment. But when it contains much more tests and start becoming slow, then we'll need to change the code to run several comparisons in parallel, just like we do today in tests/test-diff-filter.cc. At that point, I believe I'll just re-write this in C++, just like tests/test-diff-filter.cc because that will allow us to have true concurrent code based on the abigail:workers API. For now, I am keeping this in Python also because I think that keeps Chenxiong happy ;-) To be sure that fedabipkgdiff (and its underlying abipkgdiff) are really comparing all the packages they are supposed to compare and also all the binaries in those packages, I have added a new --show-identical-binaries to abipkgdiff and fedabipkgdiff. That option shows the name of the binaries (and packages) that are compared, *even if* the ABI of those binaries are identical. Because otherwise, today, if two binaries (or packages) have the same ABI, nothing is displayed. For instance, here is the result of comparing a package against itself, using this new --show-identical-binaries options: dodji@adjoa:patches$ ./tools/fedabipkgdiff --abipkgdiff ./build/tools/abipkgdiff --show-identical-binaries dbus-glib-0.80-3.fc12.x86_64.rpm dbus-glib-0.80-3.fc12.x86_64.rpm Comparing the ABI of binaries between dbus-glib-0.80-3.fc12.x86_64.rpm and dbus-glib-0.80-3.fc12.x86_64.rpm: ================ changes of 'dbus-binding-tool'=============== No ABI change detected ================ end of changes of 'dbus-binding-tool'=============== ================ changes of 'libdbus-glib-1.so.2.1.0'=============== No ABI change detected ================ end of changes of 'libdbus-glib-1.so.2.1.0'=============== dodji@adjoa:patches$ And here is what this command before that patch would do: dodji@adjoa:patches$ ./tools/fedabipkgdiff --abipkgdiff ../master/build/tools/abipkgdiff dbus-glib-0.80-3.fc12.x86_64.rpm dbus-glib-0.80-3.fc12.x86_64.rpm Comparing the ABI of binaries between dbus-glib-0.80-3.fc12.x86_64.rpm and dbus-glib-0.80-3.fc12.x86_64.rpm: dodji@adjoa:patches$ The rest of the patch is mostly new test inputs material and the necessary adjustments following all the changes above. * configure.ac: Do not require Python dependencies itertools, unittest and StringIO anymore as they are not used anymore. Require new module tempfile now. Generate new executable script tests/mockfedabipkgdiff from tests/mockfedabipkgdiff.in. * doc/manuals/abipkgdiff.rst: Add doc for new option --show-identical-binaries to abipkgdiff * doc/manuals/fedabipkgdiff.rst: Add doc for new options --show-identical-binaries to fedabipkgdiff. * tools/abipkgdiff.cc (options::show_identical_binaries): New data member. (options::options): Initialize new data member. (display_usage): Add a new help string for the new --show-identical-binaries option. (parse_command_line): Parse the newq --show-identical-binaries command line switch. (pthread_routine_compare): When the comparison of two binaries is empty, if --show-identical-binaries was provided, then emit some output saying the comparison did yield the empty set. * tools/fedabipkgdiff (DEFAULT_ABIPKGDIFF): Store the default path to abipkgdiff in this new global variable. Naming this default path is useful because it can then be cleanly overloaded when using mock.patch. (build_path_to_abipkgdiff): Return the new DEFAULT_ABIPKGDIFF global variable. (cmd): Parse the new --show-identical-binaries command line switch. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: New reference output. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/mockfedabipkgdiff.in: New uninstalled script template. * tests/runtestfedabipkgdiff.py.in (counter) (temp_file_or_dir_prefix, UtilsTest, RPMTest, LocalRPMTest) (RunAbipkgdiffTest, GetPackageLatestBuildTest, DownloadRPMTest) (BrewListRPMsTest, AssertionHelper, MockGlobalConfig) (BUILT_ABIPKGDIFF, CompareABIFromCommandLineTest): Remove these classes, global variables and functions. (FEDABIPKGDIFF, TEST_SRC_DIR, TEST_BUILD_DIR, INPUT_DIR) (OUTPUT_DIR, FEDABIPKGDIFF_TEST_SPECS): New global variables. (ensure_output_dir_created, run_fedabipkgdiff_tests, main): New functions. * tests/test-diff-pkg.cc (in_out_specs): Add tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt to the set of reference outputs to consider. * tests/Makefile.am: Add non-installed script mockfedabipkgdiff to source distribution. Also added tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt, tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt, tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt, tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt and tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt to source distribution. Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-07-06 09:51:13 +00:00
<< " --show-identical-binaries show the names of identical binaries\n"
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
<< " --verbose emit verbose progress messages\n"
<< " --help|-h display this help message\n"
<< " --version|-v display program version information"
" and exit\n";
}
Make the support of RPM and DEB package formats conditional If at configure time the libabigail source tarball detects that rpm2cpio and cpio are present then it enables the support for rpm files. Users can explicitly enable or disable that support by passing --enable-rpm or --disable-rpm to configure. Similarly if it detects that dpkg is present at configure time then it enables the support for deb files. Users can explicitly enable or disable that support by passing --enable-deb or --disable-deb to configure. * config.h.in: Define WITH_DEB and WITH_RPM pre-processor macros. * configure.ac: Add --enable-{rpm,deb} switches. Check for rpm2cpio and cpio programs, unless --disable-rpm was provided. If they are found and if --enable-rpm=auto was provided, then consider that --enable-rpm=yes was provided. In that case, set the WITH_RPM macro to 1. Otherwise, undefine that macro. Similarly, check for dpkg unless --disable-deb was provided. If it's found and if --enable-deb=auto was provided, consider that --enable-deb=yes was provided. In that case, set the WITH_DEB macro to 1. Otherwise, undefine that macro. Define the ENABLE_RPM and ENABLE_DEB conditional automake variables, if the rpm resp. deb support is enabled. Emit a notice about the rpm and deb features being enabled or not, at the end of the configure process. * tests/test-diff-pkg.cc: Include the config.h header. (in_out_spec): Guard rpm tests by the WITH_RPM macro. Similarly, guard deb tests by the WITH_DEB macro. * tools/abipkgdiff.cc: Include the config.h header. (extract_rpm): Guard this function definition with the WITH_RPM macro. (extract_deb): Guard this function definition with the WITH_DEB macro. (extract_package): Guard the handling of rpm packages with the WITH_RPM macro and the handling of deb package with the WITH_DEB macro. If a package not-support package format is encountered, emit an appropriate error message and error out. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 10:49:57 +00:00
#ifdef WITH_RPM
/// Extract an RPM package.
///
/// @param package_path the path to the package to extract.
///
/// @param extracted_package_dir_path the path where to extract the
/// package to.
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// @param opts the options passed to the current program.
///
/// @return true upon successful completion, false otherwise.
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
static bool
extract_rpm(const string& package_path,
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
const string& extracted_package_dir_path,
const options &opts)
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Extracting package "
<< package_path
<< " to "
<< extracted_package_dir_path
<< " ...";
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
string cmd = "test -d " + extracted_package_dir_path
+ " || mkdir -p " + extracted_package_dir_path + " ; cd " +
extracted_package_dir_path + " && rpm2cpio " + package_path +
" | cpio -dium --quiet";
if (system(cmd.c_str()))
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr) << " FAILED\n";
return false;
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr) << " DONE\n";
return true;
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
}
Make the support of RPM and DEB package formats conditional If at configure time the libabigail source tarball detects that rpm2cpio and cpio are present then it enables the support for rpm files. Users can explicitly enable or disable that support by passing --enable-rpm or --disable-rpm to configure. Similarly if it detects that dpkg is present at configure time then it enables the support for deb files. Users can explicitly enable or disable that support by passing --enable-deb or --disable-deb to configure. * config.h.in: Define WITH_DEB and WITH_RPM pre-processor macros. * configure.ac: Add --enable-{rpm,deb} switches. Check for rpm2cpio and cpio programs, unless --disable-rpm was provided. If they are found and if --enable-rpm=auto was provided, then consider that --enable-rpm=yes was provided. In that case, set the WITH_RPM macro to 1. Otherwise, undefine that macro. Similarly, check for dpkg unless --disable-deb was provided. If it's found and if --enable-deb=auto was provided, consider that --enable-deb=yes was provided. In that case, set the WITH_DEB macro to 1. Otherwise, undefine that macro. Define the ENABLE_RPM and ENABLE_DEB conditional automake variables, if the rpm resp. deb support is enabled. Emit a notice about the rpm and deb features being enabled or not, at the end of the configure process. * tests/test-diff-pkg.cc: Include the config.h header. (in_out_spec): Guard rpm tests by the WITH_RPM macro. Similarly, guard deb tests by the WITH_DEB macro. * tools/abipkgdiff.cc: Include the config.h header. (extract_rpm): Guard this function definition with the WITH_RPM macro. (extract_deb): Guard this function definition with the WITH_DEB macro. (extract_package): Guard the handling of rpm packages with the WITH_RPM macro and the handling of deb package with the WITH_DEB macro. If a package not-support package format is encountered, emit an appropriate error message and error out. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 10:49:57 +00:00
#endif // WITH_RPM
#ifdef WITH_DEB
/// Extract a Debian binary package.
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>
2015-08-07 08:48:17 +00:00
///
/// @param package_path the path to the package to extract.
///
/// @param extracted_package_dir_path the path where to extract the
/// package to.
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// @param opts the options passed to the current program.
///
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>
2015-08-07 08:48:17 +00:00
/// @return true upon successful completion, false otherwise.
static bool
extract_deb(const string& package_path,
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
const string& extracted_package_dir_path,
const options &opts)
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>
2015-08-07 08:48:17 +00:00
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Extracting package "
<< package_path
<< " to "
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
<< extracted_package_dir_path
<< " ...";
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>
2015-08-07 08:48:17 +00:00
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
string cmd = "mkdir -p " + extracted_package_dir_path + " && dpkg -x " +
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>
2015-08-07 08:48:17 +00:00
package_path + " " + extracted_package_dir_path;
if (system(cmd.c_str()))
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr) << " FAILED\n";
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>
2015-08-07 08:48:17 +00:00
return false;
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr) << " DONE\n";
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>
2015-08-07 08:48:17 +00:00
return true;
}
Make the support of RPM and DEB package formats conditional If at configure time the libabigail source tarball detects that rpm2cpio and cpio are present then it enables the support for rpm files. Users can explicitly enable or disable that support by passing --enable-rpm or --disable-rpm to configure. Similarly if it detects that dpkg is present at configure time then it enables the support for deb files. Users can explicitly enable or disable that support by passing --enable-deb or --disable-deb to configure. * config.h.in: Define WITH_DEB and WITH_RPM pre-processor macros. * configure.ac: Add --enable-{rpm,deb} switches. Check for rpm2cpio and cpio programs, unless --disable-rpm was provided. If they are found and if --enable-rpm=auto was provided, then consider that --enable-rpm=yes was provided. In that case, set the WITH_RPM macro to 1. Otherwise, undefine that macro. Similarly, check for dpkg unless --disable-deb was provided. If it's found and if --enable-deb=auto was provided, consider that --enable-deb=yes was provided. In that case, set the WITH_DEB macro to 1. Otherwise, undefine that macro. Define the ENABLE_RPM and ENABLE_DEB conditional automake variables, if the rpm resp. deb support is enabled. Emit a notice about the rpm and deb features being enabled or not, at the end of the configure process. * tests/test-diff-pkg.cc: Include the config.h header. (in_out_spec): Guard rpm tests by the WITH_RPM macro. Similarly, guard deb tests by the WITH_DEB macro. * tools/abipkgdiff.cc: Include the config.h header. (extract_rpm): Guard this function definition with the WITH_RPM macro. (extract_deb): Guard this function definition with the WITH_DEB macro. (extract_package): Guard the handling of rpm packages with the WITH_RPM macro and the handling of deb package with the WITH_DEB macro. If a package not-support package format is encountered, emit an appropriate error message and error out. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 10:49:57 +00:00
#endif // WITH_DEB
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>
2015-08-22 11:59:18 +00:00
#ifdef WITH_TAR
/// Extract a GNU Tar archive.
///
/// @param package_path the path to the archive to extract.
///
/// @param extracted_package_dir_path the path where to extract the
/// archive to.
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// @param opts the options passed to the current program.
///
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>
2015-08-22 11:59:18 +00:00
/// @return true upon successful completion, false otherwise.
static bool
extract_tar(const string& package_path,
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
const string& extracted_package_dir_path,
const options &opts)
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>
2015-08-22 11:59:18 +00:00
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Extracting tar archive "
<< package_path
<< " to "
<< extracted_package_dir_path
<< " ...";
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>
2015-08-22 11:59:18 +00:00
string cmd = "test -d " +
extracted_package_dir_path +
" && rm -rf " + extracted_package_dir_path;
if (system(cmd.c_str()))
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr) << "command " << cmd << " FAILED\n";
}
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>
2015-08-22 11:59:18 +00:00
cmd = "mkdir -p " + extracted_package_dir_path + " && cd " +
extracted_package_dir_path + " && tar -xf " + package_path;
if (system(cmd.c_str()))
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr) << " FAILED\n";
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>
2015-08-22 11:59:18 +00:00
return false;
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr) << " DONE\n";
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>
2015-08-22 11:59:18 +00:00
return true;
}
#endif // WITH_TAR
/// Erase the temporary directories created for the extraction of two
/// packages.
///
/// @param first_package the first package to consider.
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// @param opts the options passed to the current program.
///
/// @param second_package the second package to consider.
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
static void
erase_created_temporary_directories(const package& first_package,
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
const package& second_package,
const options &opts)
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
first_package.erase_extraction_directories(opts);
second_package.erase_extraction_directories(opts);
}
/// Erase the root of all the temporary directories created by the
/// current thread.
static void
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
erase_created_temporary_directories_parent(const options &opts)
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Erasing temporary extraction parent directory "
<< package::extracted_packages_parent_dir()
<< " ...";
string cmd = "rm -rf " + package::extracted_packages_parent_dir();
if (system(cmd.c_str()))
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr) << "FAILED\n";
}
else
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr) << "DONE\n";
}
}
/// Extract the content of a package.
///
/// @param package the package we are looking at.
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
///
/// @param opts the options passed to the current program.
static bool
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
extract_package(const package& package,
const options &opts)
{
switch(package.type())
{
case abigail::tools_utils::FILE_TYPE_RPM:
Make the support of RPM and DEB package formats conditional If at configure time the libabigail source tarball detects that rpm2cpio and cpio are present then it enables the support for rpm files. Users can explicitly enable or disable that support by passing --enable-rpm or --disable-rpm to configure. Similarly if it detects that dpkg is present at configure time then it enables the support for deb files. Users can explicitly enable or disable that support by passing --enable-deb or --disable-deb to configure. * config.h.in: Define WITH_DEB and WITH_RPM pre-processor macros. * configure.ac: Add --enable-{rpm,deb} switches. Check for rpm2cpio and cpio programs, unless --disable-rpm was provided. If they are found and if --enable-rpm=auto was provided, then consider that --enable-rpm=yes was provided. In that case, set the WITH_RPM macro to 1. Otherwise, undefine that macro. Similarly, check for dpkg unless --disable-deb was provided. If it's found and if --enable-deb=auto was provided, consider that --enable-deb=yes was provided. In that case, set the WITH_DEB macro to 1. Otherwise, undefine that macro. Define the ENABLE_RPM and ENABLE_DEB conditional automake variables, if the rpm resp. deb support is enabled. Emit a notice about the rpm and deb features being enabled or not, at the end of the configure process. * tests/test-diff-pkg.cc: Include the config.h header. (in_out_spec): Guard rpm tests by the WITH_RPM macro. Similarly, guard deb tests by the WITH_DEB macro. * tools/abipkgdiff.cc: Include the config.h header. (extract_rpm): Guard this function definition with the WITH_RPM macro. (extract_deb): Guard this function definition with the WITH_DEB macro. (extract_package): Guard the handling of rpm packages with the WITH_RPM macro and the handling of deb package with the WITH_DEB macro. If a package not-support package format is encountered, emit an appropriate error message and error out. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 10:49:57 +00:00
#ifdef WITH_RPM
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (!extract_rpm(package.path(), package.extracted_dir_path(), opts))
{
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Error while extracting package " << package.path() << "\n";
return false;
}
return true;
Make the support of RPM and DEB package formats conditional If at configure time the libabigail source tarball detects that rpm2cpio and cpio are present then it enables the support for rpm files. Users can explicitly enable or disable that support by passing --enable-rpm or --disable-rpm to configure. Similarly if it detects that dpkg is present at configure time then it enables the support for deb files. Users can explicitly enable or disable that support by passing --enable-deb or --disable-deb to configure. * config.h.in: Define WITH_DEB and WITH_RPM pre-processor macros. * configure.ac: Add --enable-{rpm,deb} switches. Check for rpm2cpio and cpio programs, unless --disable-rpm was provided. If they are found and if --enable-rpm=auto was provided, then consider that --enable-rpm=yes was provided. In that case, set the WITH_RPM macro to 1. Otherwise, undefine that macro. Similarly, check for dpkg unless --disable-deb was provided. If it's found and if --enable-deb=auto was provided, consider that --enable-deb=yes was provided. In that case, set the WITH_DEB macro to 1. Otherwise, undefine that macro. Define the ENABLE_RPM and ENABLE_DEB conditional automake variables, if the rpm resp. deb support is enabled. Emit a notice about the rpm and deb features being enabled or not, at the end of the configure process. * tests/test-diff-pkg.cc: Include the config.h header. (in_out_spec): Guard rpm tests by the WITH_RPM macro. Similarly, guard deb tests by the WITH_DEB macro. * tools/abipkgdiff.cc: Include the config.h header. (extract_rpm): Guard this function definition with the WITH_RPM macro. (extract_deb): Guard this function definition with the WITH_DEB macro. (extract_package): Guard the handling of rpm packages with the WITH_RPM macro and the handling of deb package with the WITH_DEB macro. If a package not-support package format is encountered, emit an appropriate error message and error out. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 10:49:57 +00:00
#else
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Support for rpm hasn't been enabled. Please consider "
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
"enabling it at package configure time\n";
Make the support of RPM and DEB package formats conditional If at configure time the libabigail source tarball detects that rpm2cpio and cpio are present then it enables the support for rpm files. Users can explicitly enable or disable that support by passing --enable-rpm or --disable-rpm to configure. Similarly if it detects that dpkg is present at configure time then it enables the support for deb files. Users can explicitly enable or disable that support by passing --enable-deb or --disable-deb to configure. * config.h.in: Define WITH_DEB and WITH_RPM pre-processor macros. * configure.ac: Add --enable-{rpm,deb} switches. Check for rpm2cpio and cpio programs, unless --disable-rpm was provided. If they are found and if --enable-rpm=auto was provided, then consider that --enable-rpm=yes was provided. In that case, set the WITH_RPM macro to 1. Otherwise, undefine that macro. Similarly, check for dpkg unless --disable-deb was provided. If it's found and if --enable-deb=auto was provided, consider that --enable-deb=yes was provided. In that case, set the WITH_DEB macro to 1. Otherwise, undefine that macro. Define the ENABLE_RPM and ENABLE_DEB conditional automake variables, if the rpm resp. deb support is enabled. Emit a notice about the rpm and deb features being enabled or not, at the end of the configure process. * tests/test-diff-pkg.cc: Include the config.h header. (in_out_spec): Guard rpm tests by the WITH_RPM macro. Similarly, guard deb tests by the WITH_DEB macro. * tools/abipkgdiff.cc: Include the config.h header. (extract_rpm): Guard this function definition with the WITH_RPM macro. (extract_deb): Guard this function definition with the WITH_DEB macro. (extract_package): Guard the handling of rpm packages with the WITH_RPM macro and the handling of deb package with the WITH_DEB macro. If a package not-support package format is encountered, emit an appropriate error message and error out. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 10:49:57 +00:00
return false;
#endif // WITH_RPM
break;
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>
2015-08-07 08:48:17 +00:00
case abigail::tools_utils::FILE_TYPE_DEB:
Make the support of RPM and DEB package formats conditional If at configure time the libabigail source tarball detects that rpm2cpio and cpio are present then it enables the support for rpm files. Users can explicitly enable or disable that support by passing --enable-rpm or --disable-rpm to configure. Similarly if it detects that dpkg is present at configure time then it enables the support for deb files. Users can explicitly enable or disable that support by passing --enable-deb or --disable-deb to configure. * config.h.in: Define WITH_DEB and WITH_RPM pre-processor macros. * configure.ac: Add --enable-{rpm,deb} switches. Check for rpm2cpio and cpio programs, unless --disable-rpm was provided. If they are found and if --enable-rpm=auto was provided, then consider that --enable-rpm=yes was provided. In that case, set the WITH_RPM macro to 1. Otherwise, undefine that macro. Similarly, check for dpkg unless --disable-deb was provided. If it's found and if --enable-deb=auto was provided, consider that --enable-deb=yes was provided. In that case, set the WITH_DEB macro to 1. Otherwise, undefine that macro. Define the ENABLE_RPM and ENABLE_DEB conditional automake variables, if the rpm resp. deb support is enabled. Emit a notice about the rpm and deb features being enabled or not, at the end of the configure process. * tests/test-diff-pkg.cc: Include the config.h header. (in_out_spec): Guard rpm tests by the WITH_RPM macro. Similarly, guard deb tests by the WITH_DEB macro. * tools/abipkgdiff.cc: Include the config.h header. (extract_rpm): Guard this function definition with the WITH_RPM macro. (extract_deb): Guard this function definition with the WITH_DEB macro. (extract_package): Guard the handling of rpm packages with the WITH_RPM macro and the handling of deb package with the WITH_DEB macro. If a package not-support package format is encountered, emit an appropriate error message and error out. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 10:49:57 +00:00
#ifdef WITH_DEB
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (!extract_deb(package.path(), package.extracted_dir_path(), opts))
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>
2015-08-07 08:48:17 +00:00
{
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Error while extracting package" << package.path() << "\n";
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>
2015-08-07 08:48:17 +00:00
return false;
}
return true;
Make the support of RPM and DEB package formats conditional If at configure time the libabigail source tarball detects that rpm2cpio and cpio are present then it enables the support for rpm files. Users can explicitly enable or disable that support by passing --enable-rpm or --disable-rpm to configure. Similarly if it detects that dpkg is present at configure time then it enables the support for deb files. Users can explicitly enable or disable that support by passing --enable-deb or --disable-deb to configure. * config.h.in: Define WITH_DEB and WITH_RPM pre-processor macros. * configure.ac: Add --enable-{rpm,deb} switches. Check for rpm2cpio and cpio programs, unless --disable-rpm was provided. If they are found and if --enable-rpm=auto was provided, then consider that --enable-rpm=yes was provided. In that case, set the WITH_RPM macro to 1. Otherwise, undefine that macro. Similarly, check for dpkg unless --disable-deb was provided. If it's found and if --enable-deb=auto was provided, consider that --enable-deb=yes was provided. In that case, set the WITH_DEB macro to 1. Otherwise, undefine that macro. Define the ENABLE_RPM and ENABLE_DEB conditional automake variables, if the rpm resp. deb support is enabled. Emit a notice about the rpm and deb features being enabled or not, at the end of the configure process. * tests/test-diff-pkg.cc: Include the config.h header. (in_out_spec): Guard rpm tests by the WITH_RPM macro. Similarly, guard deb tests by the WITH_DEB macro. * tools/abipkgdiff.cc: Include the config.h header. (extract_rpm): Guard this function definition with the WITH_RPM macro. (extract_deb): Guard this function definition with the WITH_DEB macro. (extract_package): Guard the handling of rpm packages with the WITH_RPM macro and the handling of deb package with the WITH_DEB macro. If a package not-support package format is encountered, emit an appropriate error message and error out. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 10:49:57 +00:00
#else
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Support for deb hasn't been enabled. Please consider "
Make the support of RPM and DEB package formats conditional If at configure time the libabigail source tarball detects that rpm2cpio and cpio are present then it enables the support for rpm files. Users can explicitly enable or disable that support by passing --enable-rpm or --disable-rpm to configure. Similarly if it detects that dpkg is present at configure time then it enables the support for deb files. Users can explicitly enable or disable that support by passing --enable-deb or --disable-deb to configure. * config.h.in: Define WITH_DEB and WITH_RPM pre-processor macros. * configure.ac: Add --enable-{rpm,deb} switches. Check for rpm2cpio and cpio programs, unless --disable-rpm was provided. If they are found and if --enable-rpm=auto was provided, then consider that --enable-rpm=yes was provided. In that case, set the WITH_RPM macro to 1. Otherwise, undefine that macro. Similarly, check for dpkg unless --disable-deb was provided. If it's found and if --enable-deb=auto was provided, consider that --enable-deb=yes was provided. In that case, set the WITH_DEB macro to 1. Otherwise, undefine that macro. Define the ENABLE_RPM and ENABLE_DEB conditional automake variables, if the rpm resp. deb support is enabled. Emit a notice about the rpm and deb features being enabled or not, at the end of the configure process. * tests/test-diff-pkg.cc: Include the config.h header. (in_out_spec): Guard rpm tests by the WITH_RPM macro. Similarly, guard deb tests by the WITH_DEB macro. * tools/abipkgdiff.cc: Include the config.h header. (extract_rpm): Guard this function definition with the WITH_RPM macro. (extract_deb): Guard this function definition with the WITH_DEB macro. (extract_package): Guard the handling of rpm packages with the WITH_RPM macro and the handling of deb package with the WITH_DEB macro. If a package not-support package format is encountered, emit an appropriate error message and error out. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-08-14 10:49:57 +00:00
"enabling it at package configure time\n";
return false;
#endif // WITH_DEB
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>
2015-08-07 08:48:17 +00:00
break;
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>
2015-08-22 09:44:08 +00:00
case abigail::tools_utils::FILE_TYPE_DIR:
// The input package is just a directory that contains binaries,
// there is nothing to extract.
break;
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>
2015-08-22 11:59:18 +00:00
case abigail::tools_utils::FILE_TYPE_TAR:
#ifdef WITH_TAR
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (!extract_tar(package.path(), package.extracted_dir_path(), opts))
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>
2015-08-22 11:59:18 +00:00
{
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Error while extracting GNU tar archive "
<< package.path() << "\n";
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>
2015-08-22 11:59:18 +00:00
return false;
}
return true;
#else
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Support for GNU tar hasn't been enabled. Please consider "
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>
2015-08-22 11:59:18 +00:00
"enabling it at package configure time\n";
return false;
#endif // WITH_TAR
break;
default:
return false;
}
return true;
}
/// Check that the suppression specification files supplied are
/// present. If not, emit an error on stderr.
///
/// @param opts the options instance to use.
///
/// @return true if all suppression specification files are present,
/// false otherwise.
static bool
maybe_check_suppression_files(const options& opts)
{
for (vector<string>::const_iterator i = opts.suppression_paths.begin();
i != opts.suppression_paths.end();
++i)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
if (!check_file(*i, cerr, opts.prog_name))
return false;
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>
2017-04-03 18:10:06 +00:00
for (vector<string>::const_iterator i =
opts.kabi_whitelist_paths.begin();
i != opts.kabi_whitelist_paths.end();
++i)
if (!check_file(*i, cerr, "abidiff"))
return false;
return true;
}
/// Update the diff context from the @ref options data structure.
///
/// @param ctxt the diff context to update.
///
/// @param opts the instance of @ref options to consider.
static void
set_diff_context_from_opts(diff_context_sptr ctxt,
const options& opts)
{
ctxt->default_output_stream(&cout);
ctxt->error_output_stream(&cerr);
Add a --leaf-changes-only option to abipkgdiff This patch adds the --leaf-changes-only option to abipkgdiff, just like what we have for abidiff. The patch also emit leaf changes report by default when comparing two Linux Kernel packages. The patch also adds the --impacted-interfaces and --full-impact options. * doc/manuals/abipkgdiff.rst: Add documentation for the new --leaf-change-only, --impacted-interfaces and --full-impact options. * tools/abipkgdiff.cc (options::{leaf_changes_only, show_impacted_interfaces, show_full_impact_report): Add new data members. (options::options): Initialize them. (display_usage): Add help strings for the new --leaf-change-only, --impacted-interfaces and --full-impact|-f options. (set_diff_context_from_opts): Set the diff context for the 'leaf-changes-only' and 'show-impacted-interfaces' flags. (parse_command_line): Parse the --leaf-change-only, --impacted-interfaces and --full-impact options. Handle the case where the --linux-kernel-abi-whitelist|-w option is given a whitelist *package*. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt: New test output reference. * tests/test-diff-pkg.cc (in_out_spec): Compare data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64.rpm and data/test-diff-pkg/spice-server-0.12.8-1.el7.x86_64.rpm with the new --leaf-changes-only and --impacted-interfaces options, using the new output reference above. * tests/data/Makefile.am: Add the new test material to source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-09-18 14:00:23 +00:00
ctxt->show_leaf_changes_only(opts.leaf_changes_only);
ctxt->show_impacted_interfaces(opts.show_impacted_interfaces);
Bug 20887 - Show relative change of offsets Until now, an offset change is reported by showing the old and new offsets of the data member that changed. This patch adds the string "(by +N bits)" with 'N' being the number of bits by which the offset of the data member was increased, or "(by -N bits) if the offset of the data member was decreased of N bits. The patch also emits a string that says "size hasn't changed" if the size of the structure did not change. This can be disabled by a new --no-show-relative-offset-changes option. * doc/manuals/abidiff.rst: Document the new --no-show-relative-offset-changes. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-comparison.h (diff_context::show_relative_offset_changes): New accessors. * include/abg-ir.h ({set,get}_data_member_offset): Return uint64_t instead of the less portable size_t. * src/abg-comparison.cc (diff_context::priv::show_relative_offset_changes_): New data member. (dif_context::show_relative_offset_changes): Define accessor. (maybe_show_relative_offset_change): Define new function. (represent): In the overload for var_diff, call the new maybe_show_relative_offset_change. (report_size_and_alignment_changes): If the size of the type didn't change then say it now. * src/abg-ir.cc (set_data_member_offset, get_data_member_offset): Take or return a uint64_t instead of a size_t. * tools/abidiff.cc (options::show_relative_offset_changes): New data member. (options::options): Initialize it. (display_usage): Display help string for the new --no-show-relative-offset-changes. (parse_command_line): Parse the new --no-show-relative-offset-changes options. (set_diff_context_from_opts): Set the "show-relative-offset-changes" flag according to the new option.n * tools/abipkgdiff.cc (options::show_relative_offset_changes): New data member. (options::options): Initialize it. (display_usage): Add help string for the new --no-show-relative-offset-changes option. (set_diff_context_from_opts): Set the "show-relative-offset-changes" flag according to the new option. (parse_command_line): Parse the new command line option. * tests/data/test-diff-dwarf/test40-report-0.txt: Add new reference output. * tests/data/test-diff-dwarf/test40-v0.c: Source code of the first test binary. * tests/data/test-diff-dwarf/test40-v1.c: Source code of the second test binay. * tests/data/test-diff-dwarf/libtest40-v0.so: New first test binary. * tests/data/test-diff-dwarf/libtest40-v1.so: New second test binary. * tests/test-diff-dwarf.cc (in_out_spec): Add the new test binaries above to the set of binaries that are compared. * tests/data/Makefile.am: Add the new test material to source distribution. * tests/data/test-abicompat/test7-fn-changed-report-0.txt: Adjust. * tests/data/test-abidiff/test-PR18791-report0.txt: Likewise. * tests/data/test-abidiff/test-enum0-report.txt: Likewise. * tests/data/test-abidiff/test-enum1-report.txt: Likewise. * tests/data/test-abidiff/test-struct1-report.txt: Likewise. * tests/data/test-diff-dwarf/test0-report.txt: Likewise. * tests/data/test-diff-dwarf/test1-report.txt: Likewise. * tests/data/test-diff-dwarf/test10-report.txt: Likewise. * tests/data/test-diff-dwarf/test11-report.txt: Likewise. * tests/data/test-diff-dwarf/test13-report.txt: Likewise. * tests/data/test-diff-dwarf/test15-enum-report.txt: Likewise. * tests/data/test-diff-dwarf/test27-local-base-diff-report.txt: Likewise. * tests/data/test-diff-dwarf/test32-fnptr-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test33-fnref-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test38-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test4-report.txt: Likewise. * tests/data/test-diff-dwarf/test5-report.txt: Likewise. * tests/data/test-diff-dwarf/test6-report.txt: Likewise. * tests/data/test-diff-dwarf/test8-report.txt: Likewise. * tests/data/test-diff-filter/test0-report.txt: Likewise. * tests/data/test-diff-filter/test01-report.txt: Likewise. * tests/data/test-diff-filter/test1-report.txt: Likewise. * tests/data/test-diff-filter/test13-report.txt: Likewise. * tests/data/test-diff-filter/test16-report-2.txt: Likewise. * tests/data/test-diff-filter/test16-report.txt: Likewise. * tests/data/test-diff-filter/test17-0-report.txt: Likewise. * tests/data/test-diff-filter/test17-1-report.txt: Likewise. * tests/data/test-diff-filter/test18-report.txt: Likewise. * tests/data/test-diff-filter/test19-enum-report-1.txt: Likewise. * tests/data/test-diff-filter/test2-report.txt: Likewise. * tests/data/test-diff-filter/test23-redundant-fn-parm-change-report-0.txt: Likewise. * tests/data/test-diff-filter/test24-compatible-vars-report-1.txt: Likewise. * tests/data/test-diff-filter/test25-cyclic-type-report-0.txt: Likewise. * tests/data/test-diff-filter/test25-cyclic-type-report-1.txt: Likewise. * tests/data/test-diff-filter/test26-qualified-redundant-node-report-0.t: Likewise.xt * tests/data/test-diff-filter/test26-qualified-redundant-node-report-1.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt: Likewise. * tests/data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt: Likewise. * tests/data/test-diff-filter/test3-report.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt: Likewise. * 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: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test10-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-suppr/test2-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test30-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-8.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-12-02 13:41:07 +00:00
ctxt->show_relative_offset_changes(opts.show_relative_offset_changes);
ctxt->show_redundant_changes(opts.show_redundant_changes);
Add the option of printing the file, line and column information about a type being reported. * bash-completion/abicompat: Complete the new "--no-show-locs" option. * bash-completion/abidiff: Likewise. * bash-completion/abidw: Likewise. * bash-completion/abipkgdiff: Likewise. * doc/manuals/abicompat.rst: Mention the new "--no-show-locs" option. * doc/manuals/abidiff.rst: Likewise. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-comparison.h (show_locs): Add declarations. * src/abg-comparison.cc: (diff_context::priv): Add a new switch called "show_locs_" and set its default value to false. (report_loc_info): New function. Outputting the extra information is conditionalized based on the associated diff contexts settings. (show_locs): define a getter/setter for diff_context::priv::show_locs_. ({distinct,pointer,reference,qualified_type,enum,class,scope,fn_parm, typedef,corpus}_diff::report): Call report_loc_info when appropriate. (maybe_report_diff_for_member): Likewise. (represent): Accept a const reference to a diff_context_sptr as a first argument and call report_loc_info on its second argument. * src/abg-dwarf-reader.cc: * tests/data/Makefile.am: Add the new test reference files. * tests/data/test-abicompat/test0-fn-changed-report-2.txt: New test reference output. * tests/data/test-abicompat/test5-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test6-var-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test7-fn-changed-report-2.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-2.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. * tests/test-abidiff.cc: Explicitly create a diff context and turn off location emitting. * tests/test-diff-dwarf.cc: Likewise. * tests/test-abicompat.cc: Add --no-show-locs to all existing test arguments. Run a few of the existing tests again, but without this option. * tests/test-diff-filter.cc: Likewise. * tests/test-diff-pkg.cc: Likewise. * tests/test-diff-suppr.cc: Likewise. * tools/abicompat.cc: Handle the new "--no-show-locs" option. * tools/abidiff.cc: Likewise. * tools/abidw.cc: Likewise. * tools/abipkgdiff.cc: Likewise. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-16 09:55:28 +00:00
ctxt->show_locs(opts.show_locs);
ctxt->show_linkage_names(opts.show_linkage_names);
ctxt->show_added_fns(opts.show_added_syms);
ctxt->show_added_vars(opts.show_added_syms);
ctxt->show_added_symbols_unreferenced_by_debug_info
(opts.show_added_syms);
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>
2017-04-03 18:10:06 +00:00
ctxt->show_symbols_unreferenced_by_debug_info
(opts.show_symbols_not_referenced_by_debug_info);
if (!opts.show_harmless_changes)
Allow selective resolution of class declaration When a class is forward-declared, resolving it to a definition that appears later in the same translation unit or in another translation is an interesting problem. Until now, the declaration would be resolved to the definition of that class found in the binary. The problem is that there can be different such definitions, especially in C where there is no "One Definition Rule". In that case, the definition chosen is random. This patch resolves that randomness. For a given class declaration, if there is just one possible definition in the binary, then the declaration is resolved to that definition. If there is one definition for that declaration in the same translation unit, then the declaration is resolved to that definition. If there are more than one definitions in translation units that are not the one of the declaration, then the declaration is left unresolved. This is what I call "selective class declaration resolution". Note that an unresolved class declaration now compares different to a definition of a class of the same name. This is so that we can have an unresolved class be present in the resulting .abi file, alongside an (incompatible) definition of the same class. The change from a class declaration to its definition is filtered out by default, though. * include/abg-fwd.h (type_base_wptrs_type) (istring_type_base_wptrs_map_type): Define new typedefs. (lookup_class_types): Declare new functions. * include/abg-ir.h (environment::decl_only_class_equals_definition): Declare new accessor. (type_maps::{*_types}): Make these accessors return istring_type_base_wptrs_map_type& instead of istring_type_base_wptr_map_type&. * src/abg-dwarf-reader.cc (read_context::resolve_declaration_only_classes): Implement the new selective declaration resolution scheme. * src/abg-ir.cc (type_maps::priv::{*_types_}): Change the type of these data members from istring_type_base_wptr_map_type to istring_type_base_wptrs_map_type. (type_maps::{*_types}): Make these accessors definitions return istring_type_base_wptrs_map_type& instead of istring_type_base_wptr_map_type&. (translation_unit::bind_function_type_life_time): Adjust. (environment::priv::decl_only_class_equals_definition_): New data member. (environment::priv::priv): Initialize it. By default, a decl-only class is now considered different from its definition. (environment::decl_only_class_equals_definition): Define new accessor. (lookup_types_in_map, lookup_class_types): Define new functions. (lookup_type_in_map, lookup_union_type_per_location) (lookup_basic_type, lookup_basic_type_per_location) (lookup_class_type, lookup_class_type_per_location) (lookup_union_type, lookup_enum_type) (lookup_enum_type_per_location, lookup_typedef_type) (lookup_typedef_type_per_location, lookup_qualified_type) (lookup_pointer_type, lookup_reference_type, lookup_array_type) (lookup_function_type, maybe_update_types_lookup_map) (maybe_update_types_lookup_map<class_decl>) (maybe_update_types_lookup_map<function_type>): Adjust. (type_base::get_canonical_type_for): When doing type comparison here, we can now consider that an unresolved class declaration compares different to an incompatible class definition of the same name. So no need to look through decl-only classes in that case. (equals): In the overload for class_or_union, if environment::decl_only_class_equals_definition() is false, then an unresolved class declaration of name "N" compares different to a class definition named "N". * tests/data/test-annotate/test15-pr18892.so.abi: Adjust. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust * tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust. * tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust. * tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt: Adjust. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Adjust. * tests/data/test-diff-filter/test38/Makefile: New test material. * tests/data/test-diff-filter/test38/test38-a.c: Likewise. * tests/data/test-diff-filter/test38/test38-b.c: Likewise. * tests/data/test-diff-filter/test38/test38-c.c: Likewise. * tests/data/test-diff-filter/test38/test38-report-0.txt: Likewise. * tests/data/test-diff-filter/test38/test38-v0: Likewise. * tests/data/test-diff-filter/test38/test38-v1: Likewise. * tests/data/test-diff-filter/test38/test38.h: Likewise. * tests/data/test-diff-filter/test39/Makefile: Likewise. * tests/data/test-diff-filter/test39/test39-a-v0.c: Likewise. * tests/data/test-diff-filter/test39/test39-a-v1.c: Likewise. * tests/data/test-diff-filter/test39/test39-b-v0.c: Likewise. * tests/data/test-diff-filter/test39/test39-b-v1.c: Likewise. * tests/data/test-diff-filter/test39/test39-c-v0.c: Likewise. * tests/data/test-diff-filter/test39/test39-c-v1.c: Likewise. * tests/data/test-diff-filter/test39/test39-main.c: Likewise. * tests/data/test-diff-filter/test39/test39-report-0.txt: Likewise. * tests/data/test-diff-filter/test39/test39-v0: Likewise. * tests/data/test-diff-filter/test39/test39-v1: Likewise. * tests/data/test-diff-filter/test39/test39.h: Likewise. * tests/data/Makefile.am: Add the new test material above to the source distribution. * tests/test-diff-filter.cc (in_out_specs): Add the new test inputs above to the test harness. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-05-17 08:19:30 +00:00
ctxt->switch_categories_off(get_default_harmless_categories_bitmap());
suppressions_type supprs;
for (vector<string>::const_iterator i = opts.suppression_paths.begin();
i != opts.suppression_paths.end();
++i)
read_suppressions(*i, supprs);
ctxt->add_suppressions(supprs);
}
/// Compare the ABI two elf files, using their associated debug info.
///
/// The result of the comparison is emitted to standard output.
///
/// @param elf1 the first elf file to consider.
///
/// @param debug_dir1 the directory where the debug info file for @p
/// elf1 is stored.
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
/// The result of the comparison is saved to a global corpus map.
///
/// @param elf2 the second eld file to consider.
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
/// @args the list of argument sets used for comparison
///
/// @param debug_dir2 the directory where the debug info file for @p
/// elf2 is stored.
///
/// @param opts the options the current program has been called with.
///
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
/// @param env the environment encapsulating the entire comparison.
///
/// @param diff the shared pointer to be set to the result of the comparison.
///
/// @param detailed_error_status is this pointer is non-null and if
/// the function returns ABIDIFF_ERROR, then the function sets the
/// pointed-to parameter to the abigail::dwarf_reader::status value
/// that gives details about the rror.
///
/// @return the status of the comparison.
static abidiff_status
compare(const elf_file& elf1,
const string& debug_dir1,
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>
2016-05-20 07:19:51 +00:00
const suppressions_type& priv_types_supprs1,
const elf_file& elf2,
const string& debug_dir2,
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>
2016-05-20 07:19:51 +00:00
const suppressions_type& priv_types_supprs2,
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
const options& opts,
abigail::ir::environment_sptr &env,
Plug leak of diff_context_sptr after calling compute_diff After the function compute_diff is invoked to compute the diff against to corpora, the reference count of the diff_context_sptr that it takes get incremented several times. So the diff_context_sptr is not automatically released (freed) when its scope is left. The reason why the reference count of diff_context_sptr is incremented is because several diff types (the diff type itself or types extending it) actually holds a reference to the diff_context_sptr they get created with. So the lifetime of the diff_context_sptr becomes tied to the lifetime the different diff objects in a hard-to-predict way. It actually creates some cyclic references that, in this case, creates a leak. The diff_context_sptr never gets released. This patch fixes that by making the diff types hold a weak reference to the diff_context_sptr they are created with. * src/abg-comparison.cc (diff::priv::ctxt_): Make this a weak_ptr. (diff::priv::get_context): Convert the weak pointer to the context into a shared_ptr and return it. (diff::priv::is_filtered_out): Adjust to use diff::priv::get_context() to access the context. (diff::context): Likewise. (corpus_diff::priv::ctxt_): Make this a weak_ptr. (corpus_diff::priv::priv): Add a new overload that takes two corpora and a diff context. (corpus_diff::priv::get_context): Convert the weak pointer to the context into a shared_ptr and return it. (corpus_diff::priv::ensure_lookup_tables_populated): Adjust to use the new corpus_diff::priv::get_context to get the context. (variable_is_suppressed): Likewise. (corpus_diff::priv::{apply_suppressions_to_added_removed_fns_vars, apply_filters_and_compute_diff_stats, emit_diff_stats, categorize_redundant_changed_sub_nodes, clear_redundancy_categorization}): Likewise. (corpus_diff::{corpus_diff, context, apply_filters_and_suppressions_before_reporting}): Adjust. * tools/abipkgdiff.cc (compare): Make the overload that compares elf binaries take a diff context output parameter. After the context is created by this function, it's return to the caller, so that it's life time is bound to the scope this function was called from. (pthread_routine_compare): Create a shared pointer to hold a reference on a diff context. Pass that shared pointer by reference to the compare function that compares elf binaries. Rather than storing corpora in the reports_map, (as those corpora would then out-live the diff context and thus create memory corruption issues), emit the report directly into an ostringstream and store that stream in reports_map. (compare): In the overoad that compares packages, rather than trying to get corpora from the report_map, just emit the content of the ostringstream that is now there. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-18 17:51:57 +00:00
corpus_diff_sptr &diff,
diff_context_sptr &ctxt,
abigail::dwarf_reader::status *detailed_error_status = 0)
{
char *di_dir1 = (char*) debug_dir1.c_str(),
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
*di_dir2 = (char*) debug_dir2.c_str();
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Comparing the ABIs of file "
<< elf1.path
<< " and "
<< elf2.path
<< "...\n";
abigail::dwarf_reader::status c1_status = abigail::dwarf_reader::STATUS_OK,
c2_status = abigail::dwarf_reader::STATUS_OK;
Plug leak of diff_context_sptr after calling compute_diff After the function compute_diff is invoked to compute the diff against to corpora, the reference count of the diff_context_sptr that it takes get incremented several times. So the diff_context_sptr is not automatically released (freed) when its scope is left. The reason why the reference count of diff_context_sptr is incremented is because several diff types (the diff type itself or types extending it) actually holds a reference to the diff_context_sptr they get created with. So the lifetime of the diff_context_sptr becomes tied to the lifetime the different diff objects in a hard-to-predict way. It actually creates some cyclic references that, in this case, creates a leak. The diff_context_sptr never gets released. This patch fixes that by making the diff types hold a weak reference to the diff_context_sptr they are created with. * src/abg-comparison.cc (diff::priv::ctxt_): Make this a weak_ptr. (diff::priv::get_context): Convert the weak pointer to the context into a shared_ptr and return it. (diff::priv::is_filtered_out): Adjust to use diff::priv::get_context() to access the context. (diff::context): Likewise. (corpus_diff::priv::ctxt_): Make this a weak_ptr. (corpus_diff::priv::priv): Add a new overload that takes two corpora and a diff context. (corpus_diff::priv::get_context): Convert the weak pointer to the context into a shared_ptr and return it. (corpus_diff::priv::ensure_lookup_tables_populated): Adjust to use the new corpus_diff::priv::get_context to get the context. (variable_is_suppressed): Likewise. (corpus_diff::priv::{apply_suppressions_to_added_removed_fns_vars, apply_filters_and_compute_diff_stats, emit_diff_stats, categorize_redundant_changed_sub_nodes, clear_redundancy_categorization}): Likewise. (corpus_diff::{corpus_diff, context, apply_filters_and_suppressions_before_reporting}): Adjust. * tools/abipkgdiff.cc (compare): Make the overload that compares elf binaries take a diff context output parameter. After the context is created by this function, it's return to the caller, so that it's life time is bound to the scope this function was called from. (pthread_routine_compare): Create a shared pointer to hold a reference on a diff context. Pass that shared pointer by reference to the compare function that compares elf binaries. Rather than storing corpora in the reports_map, (as those corpora would then out-live the diff context and thus create memory corruption issues), emit the report directly into an ostringstream and store that stream in reports_map. (compare): In the overoad that compares packages, rather than trying to get corpora from the report_map, just emit the content of the ostringstream that is now there. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-18 17:51:57 +00:00
ctxt.reset(new diff_context);
Implement a [suppress_file] suppression directive abidiff, abipkgdiff and abicompat now recognize a [suppress_file] directive in suppression specifications. That directive instructs the tool to avoid loading some binaries altogether. This is the first directive that won't act on the result of the comparison of two binaries. It actually acts earlier and prevents the tool from loading some binaries altogether. The directive looks like: [suppress_file] # Don't load any library named lib_private*.so file_name_regexp = lib_private.*\\.so This prevents the tool from loading (and thus comparing) any library which name matches the pattern "lib_private*.so". [suppress_file] # Only load libraries name lib_public*.so file_name_not_regexp = lib_public.*\\.so This instructs the tool to only load (and compare) files which name match the pattern "lib_public*.so". * doc/manuals/libabigail-concepts.rst: Document the new 'suppress_file' directive. * include/abg-suppression.h (file_suppression): Define new class. (file_suppression_sptr): Define new typedef. (is_file_suppression, file_is_suppressed): Declare new functions. * src/abg-suppression.cc (): (read_file_suppression, is_file_suppression, file_is_suppressed): Define new functions. (file_suppression::{file_suppression, suppresses_file, ~file_suppression}): Define new member functions. * tools/abidiff.cc (main): If a suppression specification suppresses one of the input files, then do not perform the comparison. * tools/abipkgdiff.cc (compare): If a suppression specification suppresses a file that is to be compared, then do not perform the comparison. * tools/abicompat.cc (create_diff_context): New static function. (perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode): Adjust to take a context in parameter. Do not create a diff context here anymore, do not load suppression files here either. (main): Use the new create_diff_context to create a diff context and initialize it, including loading suppression specifications. If any suppression specification suppresses a file to load, then do not load perform any compatibility checking. Adjust invocations of perform_compat_check_in_weak_mode and perform_compat_check_in_normal_mode to pass the diff context. * tests/data/test-diff-suppr/test0-type-suppr-3.suppr: New test input. * tests/data/test-diff-suppr/test0-type-suppr-4.suppr: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-5.suppr: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-6.suppr: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-6.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Likewise. * tests/test-diff-suppr.cc (in_out_specs): Use the new test inputs. * tests/data/test-abicompat/test0-fn-changed-1.suppr: New test input. * tests/data/test-abicompat/test0-fn-changed-report-3.txt: Likewise. * tests/test-abicompat.cc (in_out_specs):: Use the new test inputs. * tests/data/Makefile.am: Add the new test material to source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-07 17:51:08 +00:00
set_diff_context_from_opts(ctxt, opts);
suppressions_type& supprs = ctxt->suppressions();
bool files_suppressed = (file_is_suppressed(elf1.path, supprs)
||file_is_suppressed(elf2.path, supprs));
if (files_suppressed)
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Implement a [suppress_file] suppression directive abidiff, abipkgdiff and abicompat now recognize a [suppress_file] directive in suppression specifications. That directive instructs the tool to avoid loading some binaries altogether. This is the first directive that won't act on the result of the comparison of two binaries. It actually acts earlier and prevents the tool from loading some binaries altogether. The directive looks like: [suppress_file] # Don't load any library named lib_private*.so file_name_regexp = lib_private.*\\.so This prevents the tool from loading (and thus comparing) any library which name matches the pattern "lib_private*.so". [suppress_file] # Only load libraries name lib_public*.so file_name_not_regexp = lib_public.*\\.so This instructs the tool to only load (and compare) files which name match the pattern "lib_public*.so". * doc/manuals/libabigail-concepts.rst: Document the new 'suppress_file' directive. * include/abg-suppression.h (file_suppression): Define new class. (file_suppression_sptr): Define new typedef. (is_file_suppression, file_is_suppressed): Declare new functions. * src/abg-suppression.cc (): (read_file_suppression, is_file_suppression, file_is_suppressed): Define new functions. (file_suppression::{file_suppression, suppresses_file, ~file_suppression}): Define new member functions. * tools/abidiff.cc (main): If a suppression specification suppresses one of the input files, then do not perform the comparison. * tools/abipkgdiff.cc (compare): If a suppression specification suppresses a file that is to be compared, then do not perform the comparison. * tools/abicompat.cc (create_diff_context): New static function. (perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode): Adjust to take a context in parameter. Do not create a diff context here anymore, do not load suppression files here either. (main): Use the new create_diff_context to create a diff context and initialize it, including loading suppression specifications. If any suppression specification suppresses a file to load, then do not load perform any compatibility checking. Adjust invocations of perform_compat_check_in_weak_mode and perform_compat_check_in_normal_mode to pass the diff context. * tests/data/test-diff-suppr/test0-type-suppr-3.suppr: New test input. * tests/data/test-diff-suppr/test0-type-suppr-4.suppr: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-5.suppr: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-6.suppr: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-6.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Likewise. * tests/test-diff-suppr.cc (in_out_specs): Use the new test inputs. * tests/data/test-abicompat/test0-fn-changed-1.suppr: New test input. * tests/data/test-abicompat/test0-fn-changed-report-3.txt: Likewise. * tests/test-abicompat.cc (in_out_specs):: Use the new test inputs. * tests/data/Makefile.am: Add the new test material to source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-07 17:51:08 +00:00
emit_prefix("abipkgdiff", cerr)
<< " input file "
<< elf1.path << " or " << elf2.path
<< " has been suppressed by a suppression specification.\n"
<< " Not reading any of them\n";
return abigail::tools_utils::ABIDIFF_OK;
}
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>
2016-05-20 07:19:51 +00:00
// Add the first private type suppressions set to the set of
// suppressions.
for (suppressions_type::const_iterator i = priv_types_supprs1.begin();
i != priv_types_supprs1.end();
++i)
supprs.push_back(*i);
// Add the second private type suppressions set to the set of
// suppressions.
for (suppressions_type::const_iterator i = priv_types_supprs2.begin();
i != priv_types_supprs2.end();
++i)
supprs.push_back(*i);
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< " Reading file "
<< elf1.path
<< " ...\n";
A suppressed diff node implies suppressing all equivalent nodes too When a diff node N is suppressed (for instance, using the --headers-dir{1,2} option of abidiff}, it's only that diff node that is suppressed. We forget to suppress diff nodes that are equivalent to N. Here is why we forget to suppress diff ndoes that are equivalent. apply_suppressions walks the diff node graph to mark diff nodes as suppressed. But it does the walking by making sure each diff node's *class of equivalence* is visited once. This is not only a way to prevent infinite loops while visiting the graph, but also an optimization as it avoids walking two equivalent diff nodes. But then it can happen that we forget to categorize some diff nodes inside a given class of equivalence, even though we categorized some others. This patch makes it so that when a diff node inside a class of equivalence is categorized as SUPPRESSED, the canonical diff node of that class of equivalence is categorized as SUPPRESSED too. That way, to know if a diff node is suppressed, we just need to look at its canonical diff node. While doing this, I noticed that abidiff and abipkgdiff are not dropping private types from libabigail's internal representation, even though the Library now has that capability. The patch fixes that. But then the patch adds a --dont-drop-private-types option to abidiff to avoid dropping those private types from the IR, so that regression tests can make sure that a suppressed diff node implies suppression all equivalent nodes too. * doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst: Document the new --dont-drop-private-types option. * src/abg-comparison.cc (diff::is_filtered_out): If the canonical type was suppressed then the current diff node is filtered out. (suppression_categorization_visitor::visit_{begin,end}): Categorized the canonical node as SUPPRESSED if the current node is suppressed. * tools/abidiff.cc (options::drop_private_types): New data member. (options::options): Initialize it. (display_usage): Add new help string for the new --dont-drop-private-types option. (parse_command_line): Parse the new --dont-drop-private-types option. (set_suppressions): Generate suppression specification from header directories given in parameter and stick them to the read context. * tools/abipkgdiff.cc (compare): Likewise. * tests/data/test-diff-suppr/libtest34-v0.so: New test input. * tests/data/test-diff-suppr/libtest34-v1.so: Likewise. * tests/data/test-diff-suppr/test34-report-0.txt: New reference report. * tests/data/test-diff-suppr/test34-v0.c: Source code for the new test input. * tests/data/test-diff-suppr/test34-v1.c: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v0/test34-priv-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v1/test34-priv-include-v1.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v0/test34-pub-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v1/test34-pub-include-v1.h: Likewise. * tests/data/Makefile.am: Add new test input material above to source distribution. * tests/test-diff-suppr.cc (in_out_spec): Compare the two new test library provided. Add --dont-drop-private-types to test30*. signed-off-by: Dodji Seketeli <dodji@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-26 10:01:45 +00:00
corpus_sptr corpus1;
{
read_context_sptr c = create_read_context(elf1.path, &di_dir1, env.get(),
/*load_all_types=*/false);
add_read_context_suppressions(*c, priv_types_supprs1);
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>
2017-04-03 18:10:06 +00:00
if (!opts.kabi_suppressions.empty())
add_read_context_suppressions(*c, opts.kabi_suppressions);
A suppressed diff node implies suppressing all equivalent nodes too When a diff node N is suppressed (for instance, using the --headers-dir{1,2} option of abidiff}, it's only that diff node that is suppressed. We forget to suppress diff nodes that are equivalent to N. Here is why we forget to suppress diff ndoes that are equivalent. apply_suppressions walks the diff node graph to mark diff nodes as suppressed. But it does the walking by making sure each diff node's *class of equivalence* is visited once. This is not only a way to prevent infinite loops while visiting the graph, but also an optimization as it avoids walking two equivalent diff nodes. But then it can happen that we forget to categorize some diff nodes inside a given class of equivalence, even though we categorized some others. This patch makes it so that when a diff node inside a class of equivalence is categorized as SUPPRESSED, the canonical diff node of that class of equivalence is categorized as SUPPRESSED too. That way, to know if a diff node is suppressed, we just need to look at its canonical diff node. While doing this, I noticed that abidiff and abipkgdiff are not dropping private types from libabigail's internal representation, even though the Library now has that capability. The patch fixes that. But then the patch adds a --dont-drop-private-types option to abidiff to avoid dropping those private types from the IR, so that regression tests can make sure that a suppressed diff node implies suppression all equivalent nodes too. * doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst: Document the new --dont-drop-private-types option. * src/abg-comparison.cc (diff::is_filtered_out): If the canonical type was suppressed then the current diff node is filtered out. (suppression_categorization_visitor::visit_{begin,end}): Categorized the canonical node as SUPPRESSED if the current node is suppressed. * tools/abidiff.cc (options::drop_private_types): New data member. (options::options): Initialize it. (display_usage): Add new help string for the new --dont-drop-private-types option. (parse_command_line): Parse the new --dont-drop-private-types option. (set_suppressions): Generate suppression specification from header directories given in parameter and stick them to the read context. * tools/abipkgdiff.cc (compare): Likewise. * tests/data/test-diff-suppr/libtest34-v0.so: New test input. * tests/data/test-diff-suppr/libtest34-v1.so: Likewise. * tests/data/test-diff-suppr/test34-report-0.txt: New reference report. * tests/data/test-diff-suppr/test34-v0.c: Source code for the new test input. * tests/data/test-diff-suppr/test34-v1.c: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v0/test34-priv-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v1/test34-priv-include-v1.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v0/test34-pub-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v1/test34-pub-include-v1.h: Likewise. * tests/data/Makefile.am: Add new test input material above to source distribution. * tests/test-diff-suppr.cc (in_out_spec): Compare the two new test library provided. Add --dont-drop-private-types to test30*. signed-off-by: Dodji Seketeli <dodji@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-26 10:01:45 +00:00
corpus1 = read_corpus_from_elf(*c, c1_status);
Bug 22438 - Emit a clear message when debug info is not found The alternate debug info file referred to a binary can be missing, even though the rest of the debug info is not. In that case, libabigail starts loading the debug info and then it crashes when trying to get DIEs that are part of the missing alternate debug info. This patch detects when the alternate debug info is missing, so that abidiff and abipkgdiff can gracefully bail out, yielding a meaningful error message. * include/abg-dwarf-reader.h (enum abigail::dwarf_reader::status): Add a new STATUS_ALT_DEBUG_INFO_NOT_FOUND enumerator there. (refers_to_alt_debug_info): Declare new function. * src/abg-dwarf-reader.cc (read_corpus_from_elf): Detect when the referred-to alternate debug info file is not found and flip the STATUS_ALT_DEBUG_INFO_NOT_FOUND bit of the status accordingly. If the debug info was found but not the alternate debug info, then do not try to read the debug info at all. (refers_to_alt_debug_info): Define new function. * tools/abidiff.cc (handle_error): Define new static function. (main): Use it, rather than handling errors preventing libabigail from reading the corpus on a case by case basis. tools/abipkgdiff.cc (compare): Handle the case where no alternate debug info was found. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: New test output reference. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm: New test input RPM. * tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm: Likewise. * tests/data/Makefile.am: Add the new test files above to source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add a new test case from the new input files above. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-21 10:09:00 +00:00
bool bail_out = false;
A suppressed diff node implies suppressing all equivalent nodes too When a diff node N is suppressed (for instance, using the --headers-dir{1,2} option of abidiff}, it's only that diff node that is suppressed. We forget to suppress diff nodes that are equivalent to N. Here is why we forget to suppress diff ndoes that are equivalent. apply_suppressions walks the diff node graph to mark diff nodes as suppressed. But it does the walking by making sure each diff node's *class of equivalence* is visited once. This is not only a way to prevent infinite loops while visiting the graph, but also an optimization as it avoids walking two equivalent diff nodes. But then it can happen that we forget to categorize some diff nodes inside a given class of equivalence, even though we categorized some others. This patch makes it so that when a diff node inside a class of equivalence is categorized as SUPPRESSED, the canonical diff node of that class of equivalence is categorized as SUPPRESSED too. That way, to know if a diff node is suppressed, we just need to look at its canonical diff node. While doing this, I noticed that abidiff and abipkgdiff are not dropping private types from libabigail's internal representation, even though the Library now has that capability. The patch fixes that. But then the patch adds a --dont-drop-private-types option to abidiff to avoid dropping those private types from the IR, so that regression tests can make sure that a suppressed diff node implies suppression all equivalent nodes too. * doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst: Document the new --dont-drop-private-types option. * src/abg-comparison.cc (diff::is_filtered_out): If the canonical type was suppressed then the current diff node is filtered out. (suppression_categorization_visitor::visit_{begin,end}): Categorized the canonical node as SUPPRESSED if the current node is suppressed. * tools/abidiff.cc (options::drop_private_types): New data member. (options::options): Initialize it. (display_usage): Add new help string for the new --dont-drop-private-types option. (parse_command_line): Parse the new --dont-drop-private-types option. (set_suppressions): Generate suppression specification from header directories given in parameter and stick them to the read context. * tools/abipkgdiff.cc (compare): Likewise. * tests/data/test-diff-suppr/libtest34-v0.so: New test input. * tests/data/test-diff-suppr/libtest34-v1.so: Likewise. * tests/data/test-diff-suppr/test34-report-0.txt: New reference report. * tests/data/test-diff-suppr/test34-v0.c: Source code for the new test input. * tests/data/test-diff-suppr/test34-v1.c: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v0/test34-priv-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v1/test34-priv-include-v1.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v0/test34-pub-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v1/test34-pub-include-v1.h: Likewise. * tests/data/Makefile.am: Add new test input material above to source distribution. * tests/test-diff-suppr.cc (in_out_spec): Compare the two new test library provided. Add --dont-drop-private-types to test30*. signed-off-by: Dodji Seketeli <dodji@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-26 10:01:45 +00:00
if (!(c1_status & abigail::dwarf_reader::STATUS_OK))
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
A suppressed diff node implies suppressing all equivalent nodes too When a diff node N is suppressed (for instance, using the --headers-dir{1,2} option of abidiff}, it's only that diff node that is suppressed. We forget to suppress diff nodes that are equivalent to N. Here is why we forget to suppress diff ndoes that are equivalent. apply_suppressions walks the diff node graph to mark diff nodes as suppressed. But it does the walking by making sure each diff node's *class of equivalence* is visited once. This is not only a way to prevent infinite loops while visiting the graph, but also an optimization as it avoids walking two equivalent diff nodes. But then it can happen that we forget to categorize some diff nodes inside a given class of equivalence, even though we categorized some others. This patch makes it so that when a diff node inside a class of equivalence is categorized as SUPPRESSED, the canonical diff node of that class of equivalence is categorized as SUPPRESSED too. That way, to know if a diff node is suppressed, we just need to look at its canonical diff node. While doing this, I noticed that abidiff and abipkgdiff are not dropping private types from libabigail's internal representation, even though the Library now has that capability. The patch fixes that. But then the patch adds a --dont-drop-private-types option to abidiff to avoid dropping those private types from the IR, so that regression tests can make sure that a suppressed diff node implies suppression all equivalent nodes too. * doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst: Document the new --dont-drop-private-types option. * src/abg-comparison.cc (diff::is_filtered_out): If the canonical type was suppressed then the current diff node is filtered out. (suppression_categorization_visitor::visit_{begin,end}): Categorized the canonical node as SUPPRESSED if the current node is suppressed. * tools/abidiff.cc (options::drop_private_types): New data member. (options::options): Initialize it. (display_usage): Add new help string for the new --dont-drop-private-types option. (parse_command_line): Parse the new --dont-drop-private-types option. (set_suppressions): Generate suppression specification from header directories given in parameter and stick them to the read context. * tools/abipkgdiff.cc (compare): Likewise. * tests/data/test-diff-suppr/libtest34-v0.so: New test input. * tests/data/test-diff-suppr/libtest34-v1.so: Likewise. * tests/data/test-diff-suppr/test34-report-0.txt: New reference report. * tests/data/test-diff-suppr/test34-v0.c: Source code for the new test input. * tests/data/test-diff-suppr/test34-v1.c: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v0/test34-priv-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v1/test34-priv-include-v1.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v0/test34-pub-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v1/test34-pub-include-v1.h: Likewise. * tests/data/Makefile.am: Add new test input material above to source distribution. * tests/test-diff-suppr.cc (in_out_spec): Compare the two new test library provided. Add --dont-drop-private-types to test30*. signed-off-by: Dodji Seketeli <dodji@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-26 10:01:45 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Could not read file '"
<< elf1.path
<< "' properly\n";
Bug 22438 - Emit a clear message when debug info is not found The alternate debug info file referred to a binary can be missing, even though the rest of the debug info is not. In that case, libabigail starts loading the debug info and then it crashes when trying to get DIEs that are part of the missing alternate debug info. This patch detects when the alternate debug info is missing, so that abidiff and abipkgdiff can gracefully bail out, yielding a meaningful error message. * include/abg-dwarf-reader.h (enum abigail::dwarf_reader::status): Add a new STATUS_ALT_DEBUG_INFO_NOT_FOUND enumerator there. (refers_to_alt_debug_info): Declare new function. * src/abg-dwarf-reader.cc (read_corpus_from_elf): Detect when the referred-to alternate debug info file is not found and flip the STATUS_ALT_DEBUG_INFO_NOT_FOUND bit of the status accordingly. If the debug info was found but not the alternate debug info, then do not try to read the debug info at all. (refers_to_alt_debug_info): Define new function. * tools/abidiff.cc (handle_error): Define new static function. (main): Use it, rather than handling errors preventing libabigail from reading the corpus on a case by case basis. tools/abipkgdiff.cc (compare): Handle the case where no alternate debug info was found. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: New test output reference. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm: New test input RPM. * tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm: Likewise. * tests/data/Makefile.am: Add the new test files above to source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add a new test case from the new input files above. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-21 10:09:00 +00:00
if (detailed_error_status)
*detailed_error_status = c1_status;
Bug 22438 - Emit a clear message when debug info is not found The alternate debug info file referred to a binary can be missing, even though the rest of the debug info is not. In that case, libabigail starts loading the debug info and then it crashes when trying to get DIEs that are part of the missing alternate debug info. This patch detects when the alternate debug info is missing, so that abidiff and abipkgdiff can gracefully bail out, yielding a meaningful error message. * include/abg-dwarf-reader.h (enum abigail::dwarf_reader::status): Add a new STATUS_ALT_DEBUG_INFO_NOT_FOUND enumerator there. (refers_to_alt_debug_info): Declare new function. * src/abg-dwarf-reader.cc (read_corpus_from_elf): Detect when the referred-to alternate debug info file is not found and flip the STATUS_ALT_DEBUG_INFO_NOT_FOUND bit of the status accordingly. If the debug info was found but not the alternate debug info, then do not try to read the debug info at all. (refers_to_alt_debug_info): Define new function. * tools/abidiff.cc (handle_error): Define new static function. (main): Use it, rather than handling errors preventing libabigail from reading the corpus on a case by case basis. tools/abipkgdiff.cc (compare): Handle the case where no alternate debug info was found. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: New test output reference. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm: New test input RPM. * tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm: Likewise. * tests/data/Makefile.am: Add the new test files above to source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add a new test case from the new input files above. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-21 10:09:00 +00:00
bail_out = true;
A suppressed diff node implies suppressing all equivalent nodes too When a diff node N is suppressed (for instance, using the --headers-dir{1,2} option of abidiff}, it's only that diff node that is suppressed. We forget to suppress diff nodes that are equivalent to N. Here is why we forget to suppress diff ndoes that are equivalent. apply_suppressions walks the diff node graph to mark diff nodes as suppressed. But it does the walking by making sure each diff node's *class of equivalence* is visited once. This is not only a way to prevent infinite loops while visiting the graph, but also an optimization as it avoids walking two equivalent diff nodes. But then it can happen that we forget to categorize some diff nodes inside a given class of equivalence, even though we categorized some others. This patch makes it so that when a diff node inside a class of equivalence is categorized as SUPPRESSED, the canonical diff node of that class of equivalence is categorized as SUPPRESSED too. That way, to know if a diff node is suppressed, we just need to look at its canonical diff node. While doing this, I noticed that abidiff and abipkgdiff are not dropping private types from libabigail's internal representation, even though the Library now has that capability. The patch fixes that. But then the patch adds a --dont-drop-private-types option to abidiff to avoid dropping those private types from the IR, so that regression tests can make sure that a suppressed diff node implies suppression all equivalent nodes too. * doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst: Document the new --dont-drop-private-types option. * src/abg-comparison.cc (diff::is_filtered_out): If the canonical type was suppressed then the current diff node is filtered out. (suppression_categorization_visitor::visit_{begin,end}): Categorized the canonical node as SUPPRESSED if the current node is suppressed. * tools/abidiff.cc (options::drop_private_types): New data member. (options::options): Initialize it. (display_usage): Add new help string for the new --dont-drop-private-types option. (parse_command_line): Parse the new --dont-drop-private-types option. (set_suppressions): Generate suppression specification from header directories given in parameter and stick them to the read context. * tools/abipkgdiff.cc (compare): Likewise. * tests/data/test-diff-suppr/libtest34-v0.so: New test input. * tests/data/test-diff-suppr/libtest34-v1.so: Likewise. * tests/data/test-diff-suppr/test34-report-0.txt: New reference report. * tests/data/test-diff-suppr/test34-v0.c: Source code for the new test input. * tests/data/test-diff-suppr/test34-v1.c: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v0/test34-priv-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v1/test34-priv-include-v1.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v0/test34-pub-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v1/test34-pub-include-v1.h: Likewise. * tests/data/Makefile.am: Add new test input material above to source distribution. * tests/test-diff-suppr.cc (in_out_spec): Compare the two new test library provided. Add --dont-drop-private-types to test30*. signed-off-by: Dodji Seketeli <dodji@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-26 10:01:45 +00:00
}
Bug 22438 - Emit a clear message when debug info is not found The alternate debug info file referred to a binary can be missing, even though the rest of the debug info is not. In that case, libabigail starts loading the debug info and then it crashes when trying to get DIEs that are part of the missing alternate debug info. This patch detects when the alternate debug info is missing, so that abidiff and abipkgdiff can gracefully bail out, yielding a meaningful error message. * include/abg-dwarf-reader.h (enum abigail::dwarf_reader::status): Add a new STATUS_ALT_DEBUG_INFO_NOT_FOUND enumerator there. (refers_to_alt_debug_info): Declare new function. * src/abg-dwarf-reader.cc (read_corpus_from_elf): Detect when the referred-to alternate debug info file is not found and flip the STATUS_ALT_DEBUG_INFO_NOT_FOUND bit of the status accordingly. If the debug info was found but not the alternate debug info, then do not try to read the debug info at all. (refers_to_alt_debug_info): Define new function. * tools/abidiff.cc (handle_error): Define new static function. (main): Use it, rather than handling errors preventing libabigail from reading the corpus on a case by case basis. tools/abipkgdiff.cc (compare): Handle the case where no alternate debug info was found. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: New test output reference. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm: New test input RPM. * tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm: Likewise. * tests/data/Makefile.am: Add the new test files above to source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add a new test case from the new input files above. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-21 10:09:00 +00:00
if (opts.fail_if_no_debug_info || opts.verbose)
{
bool debug_info_error = false;
if (c1_status & abigail::dwarf_reader::STATUS_DEBUG_INFO_NOT_FOUND)
{
if (opts.verbose)
emit_prefix("abipkgdiff", cerr)
<< "while reading file" << elf1.path << "\n";
emit_prefix("abipkgdiff", cerr) << "Could not find debug info file";
if (di_dir1 && strcmp(di_dir1, ""))
cerr << " under " << di_dir1 << "\n";
else
cerr << "\n";
if (detailed_error_status)
*detailed_error_status = c1_status;
debug_info_error = true;
}
if (c1_status & abigail::dwarf_reader::STATUS_ALT_DEBUG_INFO_NOT_FOUND)
{
if (opts.verbose)
emit_prefix("abipkgdiff", cerr)
<< "while reading file" << elf1.path << "\n";
emit_prefix("abipkgdiff", cerr)
<< "Could not find alternate debug info file";
string alt_di_path;
abigail::dwarf_reader::refers_to_alt_debug_info(*c, alt_di_path);
if (!alt_di_path.empty())
cerr << ": " << alt_di_path << "\n";
else
cerr << "\n";
if (detailed_error_status)
*detailed_error_status = c1_status;
debug_info_error = true;
}
if (debug_info_error)
bail_out = true;
}
Bug 22438 - Emit a clear message when debug info is not found The alternate debug info file referred to a binary can be missing, even though the rest of the debug info is not. In that case, libabigail starts loading the debug info and then it crashes when trying to get DIEs that are part of the missing alternate debug info. This patch detects when the alternate debug info is missing, so that abidiff and abipkgdiff can gracefully bail out, yielding a meaningful error message. * include/abg-dwarf-reader.h (enum abigail::dwarf_reader::status): Add a new STATUS_ALT_DEBUG_INFO_NOT_FOUND enumerator there. (refers_to_alt_debug_info): Declare new function. * src/abg-dwarf-reader.cc (read_corpus_from_elf): Detect when the referred-to alternate debug info file is not found and flip the STATUS_ALT_DEBUG_INFO_NOT_FOUND bit of the status accordingly. If the debug info was found but not the alternate debug info, then do not try to read the debug info at all. (refers_to_alt_debug_info): Define new function. * tools/abidiff.cc (handle_error): Define new static function. (main): Use it, rather than handling errors preventing libabigail from reading the corpus on a case by case basis. tools/abipkgdiff.cc (compare): Handle the case where no alternate debug info was found. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: New test output reference. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm: New test input RPM. * tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm: Likewise. * tests/data/Makefile.am: Add the new test files above to source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add a new test case from the new input files above. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-21 10:09:00 +00:00
if (bail_out)
return abigail::tools_utils::ABIDIFF_ERROR;
Bug 22438 - Emit a clear message when debug info is not found The alternate debug info file referred to a binary can be missing, even though the rest of the debug info is not. In that case, libabigail starts loading the debug info and then it crashes when trying to get DIEs that are part of the missing alternate debug info. This patch detects when the alternate debug info is missing, so that abidiff and abipkgdiff can gracefully bail out, yielding a meaningful error message. * include/abg-dwarf-reader.h (enum abigail::dwarf_reader::status): Add a new STATUS_ALT_DEBUG_INFO_NOT_FOUND enumerator there. (refers_to_alt_debug_info): Declare new function. * src/abg-dwarf-reader.cc (read_corpus_from_elf): Detect when the referred-to alternate debug info file is not found and flip the STATUS_ALT_DEBUG_INFO_NOT_FOUND bit of the status accordingly. If the debug info was found but not the alternate debug info, then do not try to read the debug info at all. (refers_to_alt_debug_info): Define new function. * tools/abidiff.cc (handle_error): Define new static function. (main): Use it, rather than handling errors preventing libabigail from reading the corpus on a case by case basis. tools/abipkgdiff.cc (compare): Handle the case where no alternate debug info was found. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: New test output reference. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm: New test input RPM. * tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm: Likewise. * tests/data/Makefile.am: Add the new test files above to source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add a new test case from the new input files above. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-21 10:09:00 +00:00
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< " DONE reading file "
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
<< elf1.path
<< "\n";
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< " Reading file "
<< elf2.path
<< " ...\n";
A suppressed diff node implies suppressing all equivalent nodes too When a diff node N is suppressed (for instance, using the --headers-dir{1,2} option of abidiff}, it's only that diff node that is suppressed. We forget to suppress diff nodes that are equivalent to N. Here is why we forget to suppress diff ndoes that are equivalent. apply_suppressions walks the diff node graph to mark diff nodes as suppressed. But it does the walking by making sure each diff node's *class of equivalence* is visited once. This is not only a way to prevent infinite loops while visiting the graph, but also an optimization as it avoids walking two equivalent diff nodes. But then it can happen that we forget to categorize some diff nodes inside a given class of equivalence, even though we categorized some others. This patch makes it so that when a diff node inside a class of equivalence is categorized as SUPPRESSED, the canonical diff node of that class of equivalence is categorized as SUPPRESSED too. That way, to know if a diff node is suppressed, we just need to look at its canonical diff node. While doing this, I noticed that abidiff and abipkgdiff are not dropping private types from libabigail's internal representation, even though the Library now has that capability. The patch fixes that. But then the patch adds a --dont-drop-private-types option to abidiff to avoid dropping those private types from the IR, so that regression tests can make sure that a suppressed diff node implies suppression all equivalent nodes too. * doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst: Document the new --dont-drop-private-types option. * src/abg-comparison.cc (diff::is_filtered_out): If the canonical type was suppressed then the current diff node is filtered out. (suppression_categorization_visitor::visit_{begin,end}): Categorized the canonical node as SUPPRESSED if the current node is suppressed. * tools/abidiff.cc (options::drop_private_types): New data member. (options::options): Initialize it. (display_usage): Add new help string for the new --dont-drop-private-types option. (parse_command_line): Parse the new --dont-drop-private-types option. (set_suppressions): Generate suppression specification from header directories given in parameter and stick them to the read context. * tools/abipkgdiff.cc (compare): Likewise. * tests/data/test-diff-suppr/libtest34-v0.so: New test input. * tests/data/test-diff-suppr/libtest34-v1.so: Likewise. * tests/data/test-diff-suppr/test34-report-0.txt: New reference report. * tests/data/test-diff-suppr/test34-v0.c: Source code for the new test input. * tests/data/test-diff-suppr/test34-v1.c: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v0/test34-priv-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v1/test34-priv-include-v1.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v0/test34-pub-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v1/test34-pub-include-v1.h: Likewise. * tests/data/Makefile.am: Add new test input material above to source distribution. * tests/test-diff-suppr.cc (in_out_spec): Compare the two new test library provided. Add --dont-drop-private-types to test30*. signed-off-by: Dodji Seketeli <dodji@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-26 10:01:45 +00:00
corpus_sptr corpus2;
{
read_context_sptr c = create_read_context(elf2.path, &di_dir2, env.get(),
/*load_all_types=*/false);
add_read_context_suppressions(*c, priv_types_supprs2);
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>
2017-04-03 18:10:06 +00:00
if (!opts.kabi_suppressions.empty())
add_read_context_suppressions(*c, opts.kabi_suppressions);
A suppressed diff node implies suppressing all equivalent nodes too When a diff node N is suppressed (for instance, using the --headers-dir{1,2} option of abidiff}, it's only that diff node that is suppressed. We forget to suppress diff nodes that are equivalent to N. Here is why we forget to suppress diff ndoes that are equivalent. apply_suppressions walks the diff node graph to mark diff nodes as suppressed. But it does the walking by making sure each diff node's *class of equivalence* is visited once. This is not only a way to prevent infinite loops while visiting the graph, but also an optimization as it avoids walking two equivalent diff nodes. But then it can happen that we forget to categorize some diff nodes inside a given class of equivalence, even though we categorized some others. This patch makes it so that when a diff node inside a class of equivalence is categorized as SUPPRESSED, the canonical diff node of that class of equivalence is categorized as SUPPRESSED too. That way, to know if a diff node is suppressed, we just need to look at its canonical diff node. While doing this, I noticed that abidiff and abipkgdiff are not dropping private types from libabigail's internal representation, even though the Library now has that capability. The patch fixes that. But then the patch adds a --dont-drop-private-types option to abidiff to avoid dropping those private types from the IR, so that regression tests can make sure that a suppressed diff node implies suppression all equivalent nodes too. * doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst: Document the new --dont-drop-private-types option. * src/abg-comparison.cc (diff::is_filtered_out): If the canonical type was suppressed then the current diff node is filtered out. (suppression_categorization_visitor::visit_{begin,end}): Categorized the canonical node as SUPPRESSED if the current node is suppressed. * tools/abidiff.cc (options::drop_private_types): New data member. (options::options): Initialize it. (display_usage): Add new help string for the new --dont-drop-private-types option. (parse_command_line): Parse the new --dont-drop-private-types option. (set_suppressions): Generate suppression specification from header directories given in parameter and stick them to the read context. * tools/abipkgdiff.cc (compare): Likewise. * tests/data/test-diff-suppr/libtest34-v0.so: New test input. * tests/data/test-diff-suppr/libtest34-v1.so: Likewise. * tests/data/test-diff-suppr/test34-report-0.txt: New reference report. * tests/data/test-diff-suppr/test34-v0.c: Source code for the new test input. * tests/data/test-diff-suppr/test34-v1.c: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v0/test34-priv-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v1/test34-priv-include-v1.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v0/test34-pub-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v1/test34-pub-include-v1.h: Likewise. * tests/data/Makefile.am: Add new test input material above to source distribution. * tests/test-diff-suppr.cc (in_out_spec): Compare the two new test library provided. Add --dont-drop-private-types to test30*. signed-off-by: Dodji Seketeli <dodji@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-26 10:01:45 +00:00
corpus2 = read_corpus_from_elf(*c, c2_status);
Bug 22438 - Emit a clear message when debug info is not found The alternate debug info file referred to a binary can be missing, even though the rest of the debug info is not. In that case, libabigail starts loading the debug info and then it crashes when trying to get DIEs that are part of the missing alternate debug info. This patch detects when the alternate debug info is missing, so that abidiff and abipkgdiff can gracefully bail out, yielding a meaningful error message. * include/abg-dwarf-reader.h (enum abigail::dwarf_reader::status): Add a new STATUS_ALT_DEBUG_INFO_NOT_FOUND enumerator there. (refers_to_alt_debug_info): Declare new function. * src/abg-dwarf-reader.cc (read_corpus_from_elf): Detect when the referred-to alternate debug info file is not found and flip the STATUS_ALT_DEBUG_INFO_NOT_FOUND bit of the status accordingly. If the debug info was found but not the alternate debug info, then do not try to read the debug info at all. (refers_to_alt_debug_info): Define new function. * tools/abidiff.cc (handle_error): Define new static function. (main): Use it, rather than handling errors preventing libabigail from reading the corpus on a case by case basis. tools/abipkgdiff.cc (compare): Handle the case where no alternate debug info was found. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: New test output reference. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm: New test input RPM. * tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm: Likewise. * tests/data/Makefile.am: Add the new test files above to source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add a new test case from the new input files above. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-21 10:09:00 +00:00
bool bail_out = false;
A suppressed diff node implies suppressing all equivalent nodes too When a diff node N is suppressed (for instance, using the --headers-dir{1,2} option of abidiff}, it's only that diff node that is suppressed. We forget to suppress diff nodes that are equivalent to N. Here is why we forget to suppress diff ndoes that are equivalent. apply_suppressions walks the diff node graph to mark diff nodes as suppressed. But it does the walking by making sure each diff node's *class of equivalence* is visited once. This is not only a way to prevent infinite loops while visiting the graph, but also an optimization as it avoids walking two equivalent diff nodes. But then it can happen that we forget to categorize some diff nodes inside a given class of equivalence, even though we categorized some others. This patch makes it so that when a diff node inside a class of equivalence is categorized as SUPPRESSED, the canonical diff node of that class of equivalence is categorized as SUPPRESSED too. That way, to know if a diff node is suppressed, we just need to look at its canonical diff node. While doing this, I noticed that abidiff and abipkgdiff are not dropping private types from libabigail's internal representation, even though the Library now has that capability. The patch fixes that. But then the patch adds a --dont-drop-private-types option to abidiff to avoid dropping those private types from the IR, so that regression tests can make sure that a suppressed diff node implies suppression all equivalent nodes too. * doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst: Document the new --dont-drop-private-types option. * src/abg-comparison.cc (diff::is_filtered_out): If the canonical type was suppressed then the current diff node is filtered out. (suppression_categorization_visitor::visit_{begin,end}): Categorized the canonical node as SUPPRESSED if the current node is suppressed. * tools/abidiff.cc (options::drop_private_types): New data member. (options::options): Initialize it. (display_usage): Add new help string for the new --dont-drop-private-types option. (parse_command_line): Parse the new --dont-drop-private-types option. (set_suppressions): Generate suppression specification from header directories given in parameter and stick them to the read context. * tools/abipkgdiff.cc (compare): Likewise. * tests/data/test-diff-suppr/libtest34-v0.so: New test input. * tests/data/test-diff-suppr/libtest34-v1.so: Likewise. * tests/data/test-diff-suppr/test34-report-0.txt: New reference report. * tests/data/test-diff-suppr/test34-v0.c: Source code for the new test input. * tests/data/test-diff-suppr/test34-v1.c: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v0/test34-priv-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v1/test34-priv-include-v1.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v0/test34-pub-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v1/test34-pub-include-v1.h: Likewise. * tests/data/Makefile.am: Add new test input material above to source distribution. * tests/test-diff-suppr.cc (in_out_spec): Compare the two new test library provided. Add --dont-drop-private-types to test30*. signed-off-by: Dodji Seketeli <dodji@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-26 10:01:45 +00:00
if (!(c2_status & abigail::dwarf_reader::STATUS_OK))
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
A suppressed diff node implies suppressing all equivalent nodes too When a diff node N is suppressed (for instance, using the --headers-dir{1,2} option of abidiff}, it's only that diff node that is suppressed. We forget to suppress diff nodes that are equivalent to N. Here is why we forget to suppress diff ndoes that are equivalent. apply_suppressions walks the diff node graph to mark diff nodes as suppressed. But it does the walking by making sure each diff node's *class of equivalence* is visited once. This is not only a way to prevent infinite loops while visiting the graph, but also an optimization as it avoids walking two equivalent diff nodes. But then it can happen that we forget to categorize some diff nodes inside a given class of equivalence, even though we categorized some others. This patch makes it so that when a diff node inside a class of equivalence is categorized as SUPPRESSED, the canonical diff node of that class of equivalence is categorized as SUPPRESSED too. That way, to know if a diff node is suppressed, we just need to look at its canonical diff node. While doing this, I noticed that abidiff and abipkgdiff are not dropping private types from libabigail's internal representation, even though the Library now has that capability. The patch fixes that. But then the patch adds a --dont-drop-private-types option to abidiff to avoid dropping those private types from the IR, so that regression tests can make sure that a suppressed diff node implies suppression all equivalent nodes too. * doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst: Document the new --dont-drop-private-types option. * src/abg-comparison.cc (diff::is_filtered_out): If the canonical type was suppressed then the current diff node is filtered out. (suppression_categorization_visitor::visit_{begin,end}): Categorized the canonical node as SUPPRESSED if the current node is suppressed. * tools/abidiff.cc (options::drop_private_types): New data member. (options::options): Initialize it. (display_usage): Add new help string for the new --dont-drop-private-types option. (parse_command_line): Parse the new --dont-drop-private-types option. (set_suppressions): Generate suppression specification from header directories given in parameter and stick them to the read context. * tools/abipkgdiff.cc (compare): Likewise. * tests/data/test-diff-suppr/libtest34-v0.so: New test input. * tests/data/test-diff-suppr/libtest34-v1.so: Likewise. * tests/data/test-diff-suppr/test34-report-0.txt: New reference report. * tests/data/test-diff-suppr/test34-v0.c: Source code for the new test input. * tests/data/test-diff-suppr/test34-v1.c: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v0/test34-priv-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v1/test34-priv-include-v1.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v0/test34-pub-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v1/test34-pub-include-v1.h: Likewise. * tests/data/Makefile.am: Add new test input material above to source distribution. * tests/test-diff-suppr.cc (in_out_spec): Compare the two new test library provided. Add --dont-drop-private-types to test30*. signed-off-by: Dodji Seketeli <dodji@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-26 10:01:45 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Could not find the read file '"
<< elf2.path
<< "' properly\n";
if (detailed_error_status)
*detailed_error_status = c2_status;
Bug 22438 - Emit a clear message when debug info is not found The alternate debug info file referred to a binary can be missing, even though the rest of the debug info is not. In that case, libabigail starts loading the debug info and then it crashes when trying to get DIEs that are part of the missing alternate debug info. This patch detects when the alternate debug info is missing, so that abidiff and abipkgdiff can gracefully bail out, yielding a meaningful error message. * include/abg-dwarf-reader.h (enum abigail::dwarf_reader::status): Add a new STATUS_ALT_DEBUG_INFO_NOT_FOUND enumerator there. (refers_to_alt_debug_info): Declare new function. * src/abg-dwarf-reader.cc (read_corpus_from_elf): Detect when the referred-to alternate debug info file is not found and flip the STATUS_ALT_DEBUG_INFO_NOT_FOUND bit of the status accordingly. If the debug info was found but not the alternate debug info, then do not try to read the debug info at all. (refers_to_alt_debug_info): Define new function. * tools/abidiff.cc (handle_error): Define new static function. (main): Use it, rather than handling errors preventing libabigail from reading the corpus on a case by case basis. tools/abipkgdiff.cc (compare): Handle the case where no alternate debug info was found. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: New test output reference. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm: New test input RPM. * tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm: Likewise. * tests/data/Makefile.am: Add the new test files above to source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add a new test case from the new input files above. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-21 10:09:00 +00:00
bail_out = true;
A suppressed diff node implies suppressing all equivalent nodes too When a diff node N is suppressed (for instance, using the --headers-dir{1,2} option of abidiff}, it's only that diff node that is suppressed. We forget to suppress diff nodes that are equivalent to N. Here is why we forget to suppress diff ndoes that are equivalent. apply_suppressions walks the diff node graph to mark diff nodes as suppressed. But it does the walking by making sure each diff node's *class of equivalence* is visited once. This is not only a way to prevent infinite loops while visiting the graph, but also an optimization as it avoids walking two equivalent diff nodes. But then it can happen that we forget to categorize some diff nodes inside a given class of equivalence, even though we categorized some others. This patch makes it so that when a diff node inside a class of equivalence is categorized as SUPPRESSED, the canonical diff node of that class of equivalence is categorized as SUPPRESSED too. That way, to know if a diff node is suppressed, we just need to look at its canonical diff node. While doing this, I noticed that abidiff and abipkgdiff are not dropping private types from libabigail's internal representation, even though the Library now has that capability. The patch fixes that. But then the patch adds a --dont-drop-private-types option to abidiff to avoid dropping those private types from the IR, so that regression tests can make sure that a suppressed diff node implies suppression all equivalent nodes too. * doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst: Document the new --dont-drop-private-types option. * src/abg-comparison.cc (diff::is_filtered_out): If the canonical type was suppressed then the current diff node is filtered out. (suppression_categorization_visitor::visit_{begin,end}): Categorized the canonical node as SUPPRESSED if the current node is suppressed. * tools/abidiff.cc (options::drop_private_types): New data member. (options::options): Initialize it. (display_usage): Add new help string for the new --dont-drop-private-types option. (parse_command_line): Parse the new --dont-drop-private-types option. (set_suppressions): Generate suppression specification from header directories given in parameter and stick them to the read context. * tools/abipkgdiff.cc (compare): Likewise. * tests/data/test-diff-suppr/libtest34-v0.so: New test input. * tests/data/test-diff-suppr/libtest34-v1.so: Likewise. * tests/data/test-diff-suppr/test34-report-0.txt: New reference report. * tests/data/test-diff-suppr/test34-v0.c: Source code for the new test input. * tests/data/test-diff-suppr/test34-v1.c: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v0/test34-priv-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-priv-include-dir-v1/test34-priv-include-v1.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v0/test34-pub-include-v0.h: Likewise. * tests/data/test-diff-suppr/test34-pub-include-dir-v1/test34-pub-include-v1.h: Likewise. * tests/data/Makefile.am: Add new test input material above to source distribution. * tests/test-diff-suppr.cc (in_out_spec): Compare the two new test library provided. Add --dont-drop-private-types to test30*. signed-off-by: Dodji Seketeli <dodji@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-11-26 10:01:45 +00:00
}
Bug 22438 - Emit a clear message when debug info is not found The alternate debug info file referred to a binary can be missing, even though the rest of the debug info is not. In that case, libabigail starts loading the debug info and then it crashes when trying to get DIEs that are part of the missing alternate debug info. This patch detects when the alternate debug info is missing, so that abidiff and abipkgdiff can gracefully bail out, yielding a meaningful error message. * include/abg-dwarf-reader.h (enum abigail::dwarf_reader::status): Add a new STATUS_ALT_DEBUG_INFO_NOT_FOUND enumerator there. (refers_to_alt_debug_info): Declare new function. * src/abg-dwarf-reader.cc (read_corpus_from_elf): Detect when the referred-to alternate debug info file is not found and flip the STATUS_ALT_DEBUG_INFO_NOT_FOUND bit of the status accordingly. If the debug info was found but not the alternate debug info, then do not try to read the debug info at all. (refers_to_alt_debug_info): Define new function. * tools/abidiff.cc (handle_error): Define new static function. (main): Use it, rather than handling errors preventing libabigail from reading the corpus on a case by case basis. tools/abipkgdiff.cc (compare): Handle the case where no alternate debug info was found. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: New test output reference. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm: New test input RPM. * tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm: Likewise. * tests/data/Makefile.am: Add the new test files above to source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add a new test case from the new input files above. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-21 10:09:00 +00:00
if (opts.fail_if_no_debug_info || opts.verbose)
{
bool debug_info_error = false;
if (c2_status & abigail::dwarf_reader::STATUS_DEBUG_INFO_NOT_FOUND)
{
if (opts.verbose)
emit_prefix("abipkgdiff", cerr)
<< "while reading file" << elf2.path << "\n";
emit_prefix("abipkgdiff", cerr) << "Could not find debug info file";
if (di_dir2 && strcmp(di_dir2, ""))
cerr << " under " << di_dir2 << "\n";
else
cerr << "\n";
if (detailed_error_status)
*detailed_error_status = c2_status;
debug_info_error = true;
}
if (c2_status & abigail::dwarf_reader::STATUS_ALT_DEBUG_INFO_NOT_FOUND)
{
if (opts.verbose)
emit_prefix("abipkgdiff", cerr)
<< "while reading file" << elf2.path << "\n";
emit_prefix("abipkgdiff", cerr)
<< "Could not find alternate debug info file";
string alt_di_path;
abigail::dwarf_reader::refers_to_alt_debug_info(*c, alt_di_path);
if (!alt_di_path.empty())
cerr << ": " << alt_di_path << "\n";
else
cerr << "\n";
if (detailed_error_status)
*detailed_error_status = c2_status;
debug_info_error = true;
}
if (debug_info_error)
bail_out = true;
}
Bug 22438 - Emit a clear message when debug info is not found The alternate debug info file referred to a binary can be missing, even though the rest of the debug info is not. In that case, libabigail starts loading the debug info and then it crashes when trying to get DIEs that are part of the missing alternate debug info. This patch detects when the alternate debug info is missing, so that abidiff and abipkgdiff can gracefully bail out, yielding a meaningful error message. * include/abg-dwarf-reader.h (enum abigail::dwarf_reader::status): Add a new STATUS_ALT_DEBUG_INFO_NOT_FOUND enumerator there. (refers_to_alt_debug_info): Declare new function. * src/abg-dwarf-reader.cc (read_corpus_from_elf): Detect when the referred-to alternate debug info file is not found and flip the STATUS_ALT_DEBUG_INFO_NOT_FOUND bit of the status accordingly. If the debug info was found but not the alternate debug info, then do not try to read the debug info at all. (refers_to_alt_debug_info): Define new function. * tools/abidiff.cc (handle_error): Define new static function. (main): Use it, rather than handling errors preventing libabigail from reading the corpus on a case by case basis. tools/abipkgdiff.cc (compare): Handle the case where no alternate debug info was found. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: New test output reference. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm: New test input RPM. * tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm: Likewise. * tests/data/Makefile.am: Add the new test files above to source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add a new test case from the new input files above. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-21 10:09:00 +00:00
if (bail_out)
return abigail::tools_utils::ABIDIFF_ERROR;
Bug 22438 - Emit a clear message when debug info is not found The alternate debug info file referred to a binary can be missing, even though the rest of the debug info is not. In that case, libabigail starts loading the debug info and then it crashes when trying to get DIEs that are part of the missing alternate debug info. This patch detects when the alternate debug info is missing, so that abidiff and abipkgdiff can gracefully bail out, yielding a meaningful error message. * include/abg-dwarf-reader.h (enum abigail::dwarf_reader::status): Add a new STATUS_ALT_DEBUG_INFO_NOT_FOUND enumerator there. (refers_to_alt_debug_info): Declare new function. * src/abg-dwarf-reader.cc (read_corpus_from_elf): Detect when the referred-to alternate debug info file is not found and flip the STATUS_ALT_DEBUG_INFO_NOT_FOUND bit of the status accordingly. If the debug info was found but not the alternate debug info, then do not try to read the debug info at all. (refers_to_alt_debug_info): Define new function. * tools/abidiff.cc (handle_error): Define new static function. (main): Use it, rather than handling errors preventing libabigail from reading the corpus on a case by case basis. tools/abipkgdiff.cc (compare): Handle the case where no alternate debug info was found. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: New test output reference. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm: New test input RPM. * tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm: Likewise. * tests/data/Makefile.am: Add the new test files above to source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add a new test case from the new input files above. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-21 10:09:00 +00:00
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< " DONE reading file " << elf2.path << "\n";
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
emit_prefix("abipkgdiff", cerr)
<< " Comparing the ABIs of: \n"
<< " " << elf1.path << "\n"
<< " " << elf2.path << "\n";
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
diff = compute_diff(corpus1, corpus2, ctxt);
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Comparing the ABIs of file "
<< elf1.path
<< " and "
<< elf2.path
<< " is DONE\n";
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
abidiff_status s = abigail::tools_utils::ABIDIFF_OK;
if (diff->has_net_changes())
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
s |= abigail::tools_utils::ABIDIFF_ABI_CHANGE;
if (diff->has_incompatible_changes())
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
s |= abigail::tools_utils::ABIDIFF_ABI_INCOMPATIBLE_CHANGE;
return s;
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// If devel packages were associated to the main package we are
/// looking at, use the names of the header files (extracted from the
/// package) to generate suppression specification to filter out types
/// that are not defined in those header files.
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// Filtering out types not defined in publi headers amounts to filter
/// out types that are deemed private to the package we are looking
/// at.
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// If the function succeeds, the generated private type suppressions
/// are available by invoking the
/// package::private_types_suppressions() accessor of the @p pkg
/// parameter.
///
/// @param pkg the main package we are looking at.
///
/// @param opts the options of the current program.
///
/// @return true iff suppression specifications were generated for
/// types private to the package.
static bool
maybe_create_private_types_suppressions(package& pkg, const options &opts)
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (!pkg.private_types_suppressions().empty())
return false;
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
package_sptr devel_pkg = pkg.devel_package();
if (!devel_pkg
|| !file_exists(devel_pkg->extracted_dir_path())
|| !is_dir(devel_pkg->extracted_dir_path()))
return false;
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
string headers_path = devel_pkg->extracted_dir_path();
if (devel_pkg->type() == abigail::tools_utils::FILE_TYPE_RPM
||devel_pkg->type() == abigail::tools_utils::FILE_TYPE_DEB)
// For RPM and DEB packages, header files are under the
// /usr/include sub-directories.
headers_path += "/usr/include";
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (!is_dir(headers_path))
return false;
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
suppression_sptr suppr =
gen_suppr_spec_from_headers(headers_path);
if (suppr)
{
if (opts.drop_private_types)
suppr->set_drops_artifact_from_ir(true);
pkg.private_types_suppressions().push_back(suppr);
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
return suppr;
}
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>
2017-04-03 18:10:06 +00:00
/// While walking a file directory, check if a directory entry is a
/// kabi whitelist of a particular architecture.
///
/// If it is, then save its file path in a vector of whitelists.
///
/// @param entry the directory entry to consider.
///
/// @param arch the architecture to consider.
///
/// @param whitelists out parameter. If @p entry is the whitelist we
/// are looking for, add its path to this output parameter.
static void
maybe_collect_kabi_whitelists(const FTSENT *entry,
const string arch,
vector<string> &whitelists)
{
if (entry == NULL
|| (entry->fts_info != FTS_F && entry->fts_info != FTS_SL)
|| entry->fts_info == FTS_ERR
|| entry->fts_info == FTS_NS)
return;
string path = entry->fts_path;
maybe_get_symlink_target_file_path(path, path);
string kabi_whitelist_name = "kabi_whitelist_" + arch;
if (string_ends_with(path, kabi_whitelist_name))
whitelists.push_back(path);
}
/// Get the kabi whitelist for a particular architecture under a given
/// directory.
///
/// @param dir the directory to look at.
///
/// @param arch the architecture to consider.
///
/// @param whitelist_paths the vector where to add the whitelists
/// found. Note that a whitelist is added to this parameter iff the
/// function returns true.
///
/// @return true iff the function found a whitelist at least.
static bool
get_kabi_whitelists_from_arch_under_dir(const string& dir,
const string& arch,
vector<string>& whitelist_paths)
{
bool is_ok = false;
char* paths[] = {const_cast<char*>(dir.c_str()), 0};
FTS *file_hierarchy = fts_open(paths, FTS_LOGICAL|FTS_NOCHDIR, NULL);
if (!file_hierarchy)
return is_ok;
FTSENT *entry;
while ((entry = fts_read(file_hierarchy)))
maybe_collect_kabi_whitelists(entry, arch, whitelist_paths);
fts_close(file_hierarchy);
return true;
}
/// Find a kabi whitelist in a linux kernel RPM package.
///
/// Note that the linux kernel RPM package must have been extracted
/// somewhere already.
///
/// This function then looks for the whitelist under the /lib/modules
/// directory inside the extracted content of the package. If it
/// finds it and saves its file path in the
/// options::kabi_whitelist_paths data member.
///
/// @param pkg the linux kernel package to consider.
///
/// @param opts the options the program was invoked with.
static bool
maybe_handle_kabi_whitelist_pkg(const package& pkg, options &opts)
{
if (opts.kabi_whitelist_packages.empty()
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>
2017-04-03 18:10:06 +00:00
|| !opts.kabi_whitelist_paths.empty()
|| !pkg.kabi_whitelist_package())
return false;
if (pkg.type() != abigail::tools_utils::FILE_TYPE_RPM)
return false;
string pkg_name = pkg.base_name();
bool is_linux_kernel_package = file_is_kernel_package(pkg_name, pkg.type());
if (!is_linux_kernel_package)
return false;
package_sptr kabi_wl_pkg = pkg.kabi_whitelist_package();
assert(kabi_wl_pkg);
if (!file_exists(kabi_wl_pkg->extracted_dir_path())
|| !is_dir(kabi_wl_pkg->extracted_dir_path()))
return false;
string rpm_arch;
if (!get_rpm_arch(pkg_name, rpm_arch))
return false;
string kabi_wl_path = kabi_wl_pkg->extracted_dir_path();
kabi_wl_path += "/lib/modules";
vector<string> whitelist_paths;
get_kabi_whitelists_from_arch_under_dir(kabi_wl_path, rpm_arch,
whitelist_paths);
if (!whitelist_paths.empty())
{
std::sort(whitelist_paths.begin(), whitelist_paths.end());
opts.kabi_whitelist_paths.push_back(whitelist_paths.back());
}
return true;
}
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
/// The task that performs the extraction of the content of several
/// packages into a temporary directory.
///
/// If this task has several packages to extract, then it extracts
/// them in sequence.
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
///
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
/// Note that several instances of tasks can perform their jobs (i.e
/// extract packages in sequence) in parallel.
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
class pkg_extraction_task : public task
{
pkg_extraction_task();
public:
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
vector<package_sptr> pkgs;
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
const options &opts;
bool is_ok;
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
pkg_extraction_task(const package_sptr &p, const options &o)
: opts(o), is_ok(true)
{pkgs.push_back(p);}
pkg_extraction_task(const vector<package_sptr> &packages, const options &o)
: pkgs(packages), opts(o), is_ok(true)
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
{}
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
/// The job performed by the current task, which is to extract its
/// packages in sequence. This is job is to be performed in
/// parallel with other jobs of other tasks.
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
virtual void
perform()
{
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
for (vector<package_sptr>::const_iterator p = pkgs.begin();
p != pkgs.end();
++p)
is_ok &= extract_package(**p, opts);
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
}
}; //end class pkg_extraction_task
/// A convenience typedef for a shared pointer to @f pkg_extraction_task.
typedef shared_ptr<pkg_extraction_task> pkg_extraction_task_sptr;
/// The worker task which job is to prepares a package.
///
/// Preparing a package means:
///
/// 1/ Extract the package and its ancillary packages.
///
/// 2/ Analyze the extracted content, map that content so that we
/// determine what the ELF files to be analyze are.
class pkg_prepare_task : public abigail::workers::task
{
pkg_prepare_task();
public:
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
package_sptr pkg;
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
options &opts;
bool is_ok;
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
pkg_prepare_task(package_sptr &p, options &o)
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
: pkg(p), opts(o), is_ok(false)
{}
/// The job performed by this task.
virtual void
perform()
{
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
is_ok = pkg && extract_package_and_map_its_content(pkg, opts);
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
}
}; //end class pkg_prepare_task
/// A convenience typedef for a shared_ptr to @ref pkg_prepare_task
typedef shared_ptr<pkg_prepare_task> pkg_prepare_task_sptr;
/// The worker task which job is to compare two ELF binaries
class compare_task : public abigail::workers::task
{
public:
compare_args_sptr args;
abidiff_status status;
ostringstream out;
string pretty_output;
compare_task()
: status(abigail::tools_utils::ABIDIFF_OK)
{}
compare_task(const compare_args_sptr& a)
: args(a),
status(abigail::tools_utils::ABIDIFF_OK)
{}
/// The job performed by the task.
///
/// This compares two ELF files, gets the resulting test report and
/// stores it in an output stream.
virtual void
perform()
{
abigail::ir::environment_sptr env(new abigail::ir::environment);
diff_context_sptr ctxt;
corpus_diff_sptr diff;
abigail::dwarf_reader::status detailed_status =
abigail::dwarf_reader::STATUS_UNKNOWN;
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
status |= compare(args->elf1, args->debug_dir1, args->private_types_suppr1,
args->elf2, args->debug_dir2, args->private_types_suppr2,
args->opts, env, diff, ctxt, &detailed_status);
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
// If there is an ABI change, tell the user about it.
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if ((status & abigail::tools_utils::ABIDIFF_ABI_CHANGE)
||( diff && diff->has_net_changes()))
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
diff->report(out, /*prefix=*/" ");
string name = args->elf1.name;
pretty_output +=
string("================ changes of '") + name + "'===============\n"
+ out.str()
+ "================ end of changes of '"
+ name + "'===============\n\n";
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
else
{
if (args->opts.show_identical_binaries)
out << "No ABI change detected\n";
}
// If an error happened while comparing the twobinaries, tell the
// user about it.
if (status & abigail::tools_utils::ABIDIFF_ERROR)
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
{
string diagnostic =
abigail::dwarf_reader::status_to_diagnostic_string(detailed_status);
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (!diagnostic.empty())
{
string name = args->elf1.name;
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
pretty_output +=
"==== Error happened during processing of " + name + ": ====\n";
pretty_output += diagnostic;
pretty_output +=
"==== End of error for " + name + " ====\n";
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
}
}
}; // end class compare_task
/// Convenience typedef for a shared_ptr of @ref compare_task.
typedef shared_ptr<compare_task> compare_task_sptr;
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>
2017-04-03 18:10:06 +00:00
/// This function is a sub-routine of create_maps_of_package_content.
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
///
/// It's called during the walking of the directory tree containing
/// the extracted content of package. It's called with an entry of
/// that directory tree.
///
/// Depending on the kind of file this function is called on, it
/// updates the vector of paths of the directory and the set of
/// suppression paths found.
///
/// @param entry the directory entry to analyze.
///
/// @param opts the options of the current program.
///
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>
2017-04-03 18:10:06 +00:00
/// @param file_name_to_look_for if this parameter is set, the
/// function only looks for a file name which name is the same as the
/// value of this parameter.
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// @param paths out parameter. This is the set of meaningful paths
/// of the current directory tree being analyzed. These paths are
/// those that are going to be involved in ABI comparison.
static void
maybe_update_vector_of_package_content(const FTSENT *entry,
options &opts,
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>
2017-04-03 18:10:06 +00:00
const string& file_name_to_look_for,
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
vector<string>& paths)
{
if (entry == NULL
|| (entry->fts_info != FTS_F && entry->fts_info != FTS_SL)
|| entry->fts_info == FTS_ERR
|| entry->fts_info == FTS_NS)
return;
string path = entry->fts_path;
maybe_get_symlink_target_file_path(path, path);
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>
2017-04-03 18:10:06 +00:00
if (!file_name_to_look_for.empty())
{
string name;
abigail::tools_utils::base_name(path, name);
if (name == file_name_to_look_for)
paths.push_back(path);
return;
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (guess_file_type(path) == abigail::tools_utils::FILE_TYPE_ELF)
paths.push_back(path);
else if (opts.abignore && string_ends_with(path, ".abignore"))
opts.suppression_paths.push_back(path);
}
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>
2017-04-03 18:10:06 +00:00
/// Walk a given directory to collect files that are "interesting" to
Bug 22488 - Make abipkgdiff handle different binaries with same basename Some packages might have different binaries with the same soname and basename, but at different paths. In that case, abipkgdiff messes things up because it only either consider the soname or the basename of the binary. This patch makes abipkgdiff to always consider the full path of the binary inside the package. * include/abg-tools-utils.h (string_suffix) (sorted_strings_common_prefix): Declare new functions. (dir_name): Take a new keep_separator_at_end parameter at the end. * src/abg-tools-utils.cc (dir_name): Take a new keep_separator_at_end parameter at the end. Add a comment for it and update. (string_suffix, sorted_strings_common_prefix): Define new functions. (common_prefix): Define new static function. * tools/abipkgdiff.cc (get_interesting_files_under_dir): Forward declare this pre-existing static function. (package::{common_paths_prefix_, elf_file_paths_}): New data members. (package::{common_paths_prefix, elf_file_paths, convert_path_to_relative, convert_path_to_unique_suffix, load_elf_file_paths}): New member functions. (create_maps_of_package_content): Use the new package::{load_elf_file_paths, convert_path_to_unique_suffix} functions. (compare_prepared_userspace_packages): Show relative paths of package elements in reported. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Update test ouptut. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-12-01 13:52:23 +00:00
/// analyze. By default, "interesting" means interesting from either
/// a kernel package or a userspace binary analysis point of view.
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>
2017-04-03 18:10:06 +00:00
///
/// @param dir the directory to walk.
///
/// @param file_name_to_look_for if this parameter is set, only a file
/// with this name is going to be collected.
///
/// @param interesting_files out parameter. This parameter is
/// populated with the interesting files found by the function iff the
/// function returns true.
///
/// @return true iff the function completed successfully.
static bool
get_interesting_files_under_dir(const string dir,
const string& file_name_to_look_for,
options& opts,
vector<string>& interesting_files)
{
bool is_ok = false;
char* paths[] = {const_cast<char*>(dir.c_str()), 0};
FTS *file_hierarchy = fts_open(paths, FTS_LOGICAL|FTS_NOCHDIR, NULL);
if (!file_hierarchy)
return is_ok;
FTSENT *entry;
while ((entry = fts_read(file_hierarchy)))
maybe_update_vector_of_package_content(entry, opts,
file_name_to_look_for,
interesting_files);
fts_close(file_hierarchy);
is_ok = true;
return is_ok;
}
/// Create maps of the content of a given package.
///
/// The maps contain relevant metadata about the content of the
/// files. These maps are used afterwards during the comparison of
/// the content of the package. Note that the maps are stored in the
/// object that represents that package.
///
/// @param package the package to consider.
///
/// @param opts the options the current program has been called with.
///
/// @param true upon successful completion, false otherwise.
static bool
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
create_maps_of_package_content(package& package, options& opts)
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Analyzing the content of package "
<< package.path()
<< " extracted to "
<< package.extracted_dir_path()
<< " ...\n";
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>
2017-04-03 18:10:06 +00:00
bool is_ok = true;
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
vector<string> elf_file_paths;
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>
2017-04-03 18:10:06 +00:00
// if package is linux kernel package and its associated debug
// info package looks like a kernel debuginfo package, then try to
// go find the vmlinux file in that debug info file.
string pkg_name = package.base_name();
bool is_linux_kernel_package = file_is_kernel_package(pkg_name,
package.type());
if (is_linux_kernel_package)
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>
2017-07-10 09:54:13 +00:00
{
// For a linux kernel package, no analysis is done. It'll be
// done later at comparison time by
// compare_prepared_linux_kernel_packages
is_ok = true;
if (opts.verbose)
emit_prefix("abipkgdiff", cerr)
<< " Analysis of " << package.path() << " DONE\n";
return is_ok;
}
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>
2017-04-03 18:10:06 +00:00
is_ok &= get_interesting_files_under_dir(package.extracted_dir_path(),
/*file_name_to_look_for=*/"",
opts, elf_file_paths);
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
emit_prefix("abipkgdiff", cerr)
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
<< "Found " << elf_file_paths.size() << " files in "
<< package.extracted_dir_path() << "\n";
Bug 22488 - Make abipkgdiff handle different binaries with same basename Some packages might have different binaries with the same soname and basename, but at different paths. In that case, abipkgdiff messes things up because it only either consider the soname or the basename of the binary. This patch makes abipkgdiff to always consider the full path of the binary inside the package. * include/abg-tools-utils.h (string_suffix) (sorted_strings_common_prefix): Declare new functions. (dir_name): Take a new keep_separator_at_end parameter at the end. * src/abg-tools-utils.cc (dir_name): Take a new keep_separator_at_end parameter at the end. Add a comment for it and update. (string_suffix, sorted_strings_common_prefix): Define new functions. (common_prefix): Define new static function. * tools/abipkgdiff.cc (get_interesting_files_under_dir): Forward declare this pre-existing static function. (package::{common_paths_prefix_, elf_file_paths_}): New data members. (package::{common_paths_prefix, elf_file_paths, convert_path_to_relative, convert_path_to_unique_suffix, load_elf_file_paths}): New member functions. (create_maps_of_package_content): Use the new package::{load_elf_file_paths, convert_path_to_unique_suffix} functions. (compare_prepared_userspace_packages): Show relative paths of package elements in reported. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Update test ouptut. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-12-01 13:52:23 +00:00
// determine if all files have the same prefix. Compute that prefix
// and stick it into the package! That prefix is going to be used
// later by the package::convert_path_to_unique_suffix method.
package.load_elf_file_paths(opts);
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
for (vector<string>::const_iterator file = elf_file_paths.begin();
file != elf_file_paths.end();
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
++file)
{
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
elf_file_sptr e (new elf_file(*file));
if (opts.compare_dso_only)
{
if (e->type != abigail::dwarf_reader::ELF_TYPE_DSO)
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
emit_prefix("abipkgdiff", cerr)
<< "skipping non-DSO file " << e->path << "\n";
continue;
}
}
else
{
if (e->type != abigail::dwarf_reader::ELF_TYPE_DSO
Bug 19961 - Distinguish between PI executable and shared library In the ELF format, Position Independent Executables (aka PIE) and shared libraries are marked as being of type ET_DYN. So just looking at the type of the ELF file is not enough to discriminate a position independent executable from a shared library. And this is the problem. Libabigail just looks at the type of the ELF file to discriminate PIE binaries from shared libraries binaries. So it treats both kinds of binaries as being shared libraries. When we run abipkgdiff with the --dso-only option, the tool considers both PIEs and shared libraries, even though the intent of the --dso-only option is have the tool consider shared libraries only. With this patch, we introduce a new enumerator ELF_TYPE_PI_EXEC (to the elf_type enum) for PIE binaries. From now on, a file will be properly recognized as being of the ELF_TYPE_DSO kind only if it is a shared library. * include/abg-dwarf-reader.h (elf_type): Add new enumerator ELF_TYPE_PI_EXEC. * src/abg-dwarf-reader.cc (lookup_data_tag_from_dynamic_segment): New function for data tag lookup in dynamic segment of an elf (elf_file_type): Return ELF_TYPE_PI_EXEC file type for a PI executable. (get_elf_file_type): Change this to take an elf handle. (get_type_of_elf_file): New function that got factorized out of ... (load_dt_soname_and_needed): ... this one. * tools/abipkgdiff.cc (create_maps_of_package_content): Also consider ELF_TYPE_PI_EXEC file type. (compare): Likewise. * tests/test-diff-pkg.cc (in_out_specs): Test case additions * tests/data/Makefile.am: Include test files * tests/data/test-diff-pkg/tarpkg-1-dir1.tar.gz: New test data * tests/data/test-diff-pkg/tarpkg-1-dir2.tar.gz: New test data * tests/data/test-diff-pkg/tarpkg-1-report-0.txt: New test result Signed-off-by: Sinny Kumari <sinny@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-04-19 18:31:56 +00:00
&& e->type != abigail::dwarf_reader::ELF_TYPE_EXEC
&& e->type != abigail::dwarf_reader::ELF_TYPE_PI_EXEC)
{
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>
2017-04-03 18:10:06 +00:00
if (is_linux_kernel_package)
{
if (e->type == abigail::dwarf_reader::ELF_TYPE_RELOCATABLE)
{
// This is a Linux Kernel module.
;
}
}
else if (opts.verbose)
{
emit_prefix("abipkgdiff", cerr)
<< "skipping non-DSO non-executable file "
<< e->path
<< "\n";
continue;
}
}
}
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
if (e->soname.empty())
Bug 22488 - Make abipkgdiff handle different binaries with same basename Some packages might have different binaries with the same soname and basename, but at different paths. In that case, abipkgdiff messes things up because it only either consider the soname or the basename of the binary. This patch makes abipkgdiff to always consider the full path of the binary inside the package. * include/abg-tools-utils.h (string_suffix) (sorted_strings_common_prefix): Declare new functions. (dir_name): Take a new keep_separator_at_end parameter at the end. * src/abg-tools-utils.cc (dir_name): Take a new keep_separator_at_end parameter at the end. Add a comment for it and update. (string_suffix, sorted_strings_common_prefix): Define new functions. (common_prefix): Define new static function. * tools/abipkgdiff.cc (get_interesting_files_under_dir): Forward declare this pre-existing static function. (package::{common_paths_prefix_, elf_file_paths_}): New data members. (package::{common_paths_prefix, elf_file_paths, convert_path_to_relative, convert_path_to_unique_suffix, load_elf_file_paths}): New member functions. (create_maps_of_package_content): Use the new package::{load_elf_file_paths, convert_path_to_unique_suffix} functions. (compare_prepared_userspace_packages): Show relative paths of package elements in reported. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Update test ouptut. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-12-01 13:52:23 +00:00
{
// Several binaries at different paths can have the same
// base name. So let's consider the full path of the binary
// inside the extracted directory.
string key = e->name;
package.convert_path_to_unique_suffix(e->path, key);
package.path_elf_file_sptr_map()[key] = e;
if (opts.verbose)
emit_prefix("abipkgdiff", cerr)
<< "mapped binary with key '" << key << "'"
<< "\n";
}
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
else
Bug 22488 - Make abipkgdiff handle different binaries with same basename Some packages might have different binaries with the same soname and basename, but at different paths. In that case, abipkgdiff messes things up because it only either consider the soname or the basename of the binary. This patch makes abipkgdiff to always consider the full path of the binary inside the package. * include/abg-tools-utils.h (string_suffix) (sorted_strings_common_prefix): Declare new functions. (dir_name): Take a new keep_separator_at_end parameter at the end. * src/abg-tools-utils.cc (dir_name): Take a new keep_separator_at_end parameter at the end. Add a comment for it and update. (string_suffix, sorted_strings_common_prefix): Define new functions. (common_prefix): Define new static function. * tools/abipkgdiff.cc (get_interesting_files_under_dir): Forward declare this pre-existing static function. (package::{common_paths_prefix_, elf_file_paths_}): New data members. (package::{common_paths_prefix, elf_file_paths, convert_path_to_relative, convert_path_to_unique_suffix, load_elf_file_paths}): New member functions. (create_maps_of_package_content): Use the new package::{load_elf_file_paths, convert_path_to_unique_suffix} functions. (compare_prepared_userspace_packages): Show relative paths of package elements in reported. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Update test ouptut. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-12-01 13:52:23 +00:00
{
// Several binaries at different paths can have the same
// soname. So let's *also* consider the full path of the
// binary inside the extracted directory, not just the
// soname.
string key = e->soname;
if (package.convert_path_to_unique_suffix(e->path, key))
{
dir_name(key, key);
key += string("/@soname:") + e->soname;
}
package.path_elf_file_sptr_map()[key] = e;
if (opts.verbose)
emit_prefix("abipkgdiff", cerr)
<< "mapped binary with key '" << key << "'"
<< "\n";
}
}
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (opts.verbose)
emit_prefix("abipkgdiff", cerr)
<< " Analysis of " << package.path() << " DONE\n";
Bug 21058 - abipkgdiff wrongly drops non-public types When using abipkgdiff types that are defined in files not present in the devel packages provided by the --devel1 and --devel2 option are dropped from the internal representation by default. This has been designed as such, not only to avoid showing changes on types that are not part of the public headers of a shared library, but also to help lower the memory consumption of libabigail. In this particular bug report, we see a library that uses types (in its public interface) that are defined in headers of a *different* package. For instance, suppose a particular package foo that uses types defined in headers of the glib package. And some of those Glib types can be present in its public interface. So in this case, libabigail is dropping a type that is actually part of the public interface of the library that is being analyzed, even if the type was not defined in the devel package of the current package. This patch addresses the issue by doing a number of things: 1/ If a type is defined in a file which path starts with "/usr/include/", then consider it as a public type. This is so that type coming from the public interface of other packages, and that are defined in system headers are considered as part of the public types of the package being analyzed. 2/ by default, don't drop types not defined in the associated devel package. This will hinder our ability to decrease the memory usage, but there have been a number of recent optimization that help in that regard independently. So I am hoping this shouldn't have a big impact now. Incidentally, the option --dont-drop-private-types (from abidiff) is changed into --drop-private-types, so that interested users can still drop non-private types from the model, if they wish. That --drop-private-types option is added to abipkgdiff too. As the offended types are not dropped from the model anymore, the usual filtering mechanisms of libabigail can take place. * doc/manuals/abidiff.rst (--dont-drop-private-types): Remove documentation. (--drop-private-types): Document this new option. * src/abg-tools-utils.cc: Update copyright notice (handle_fts_entry): On the generated suppression specification, do not set the flag to drop matched types. Also, don't match types defined in files which patch start with "/usr/include/". * tools/abidiff.cc (options::options): Initialize the drop_private_types data member to false. (display_usage): Remove usage string for --dont-drop-private-types. Add a new one for --drop-private-types. (parse_command_line): Don't part --dont-drop-private-types, rather, parse --drop-private-types. (set_suppressions): When the suppression for private types is generated, if --drop-private-types was provided, then instruct the suppression to drop matched types. * tools/abipkgdiff.cc (options::drop_private_types): New option. (options::options): Initialize the new drop_private_types data member to false. (display_usage): Add a usage string for --drop-private-types. (parse_command_line): Parse the new --drop-private-types option. (maybe_create_private_types_suppressions): Don't take just a package, but a package_descriptor because the latter carries the options. So when the user used the --drop-private-types option, make the generated private types suppression to drop matched types. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Adjust. * tests/test-diff-suppr.cc (in_out_specs): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-18 09:10:10 +00:00
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
is_ok = true;
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>
2016-05-20 07:19:51 +00:00
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
return is_ok;
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>
2016-05-20 07:19:51 +00:00
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// Extract the content of a package (and its ancillary packages) and
/// map its content.
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// First, the content of the package and its ancillary packages are
/// extracted, in parallel.
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// Then, after that extraction is done, the content of the package if
/// walked and analyzed.
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// @param pkg the package to extract and to analyze.
///
/// @param opts the options of the current program.
///
/// @return true iff the extraction and analyzing went well.
static bool
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
extract_package_and_map_its_content(const package_sptr &pkg, options &opts)
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
{
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
assert(pkg);
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
pkg_extraction_task_sptr main_pkg_extraction;
pkg_extraction_task_sptr dbg_extraction;
pkg_extraction_task_sptr devel_extraction;
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>
2017-04-03 18:10:06 +00:00
pkg_extraction_task_sptr kabi_whitelist_extraction;
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
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>
2017-04-03 18:10:06 +00:00
size_t NUM_EXTRACTIONS = 1;
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>
2016-05-20 07:19:51 +00:00
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
main_pkg_extraction.reset(new pkg_extraction_task(pkg, opts));
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>
2016-05-20 07:19:51 +00:00
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
if (!pkg->debug_info_packages().empty())
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>
2017-04-03 18:10:06 +00:00
{
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
dbg_extraction.reset(new pkg_extraction_task(pkg->debug_info_packages(),
opts));
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>
2017-04-03 18:10:06 +00:00
++NUM_EXTRACTIONS;
}
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
if (package_sptr devel_pkg = pkg->devel_package())
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>
2017-04-03 18:10:06 +00:00
{
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
devel_extraction.reset(new pkg_extraction_task(devel_pkg, opts));
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>
2017-04-03 18:10:06 +00:00
++NUM_EXTRACTIONS;
}
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
if (package_sptr kabi_wl_pkg = pkg->kabi_whitelist_package())
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>
2017-04-03 18:10:06 +00:00
{
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
kabi_whitelist_extraction.reset(new pkg_extraction_task(kabi_wl_pkg,
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>
2017-04-03 18:10:06 +00:00
opts));
++NUM_EXTRACTIONS;
}
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
size_t num_workers = (opts.parallel
? std::min(opts.num_workers, NUM_EXTRACTIONS)
: 1);
abigail::workers::queue extraction_queue(num_workers);
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
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>
2017-04-03 18:10:06 +00:00
// Perform the extraction of the NUM_WORKERS packages in parallel.
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
extraction_queue.schedule_task(dbg_extraction);
extraction_queue.schedule_task(main_pkg_extraction);
extraction_queue.schedule_task(devel_extraction);
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>
2017-04-03 18:10:06 +00:00
extraction_queue.schedule_task(kabi_whitelist_extraction);
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>
2016-05-20 07:19:51 +00:00
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
// Wait for the extraction to be done.
extraction_queue.wait_for_workers_to_complete();
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>
2016-05-20 07:19:51 +00:00
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
// Analyze and map the content of the extracted package.
bool is_ok = false;
if (main_pkg_extraction->is_ok)
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
is_ok = create_maps_of_package_content(*pkg, opts);
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (is_ok)
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>
2017-04-03 18:10:06 +00:00
{
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
maybe_create_private_types_suppressions(*pkg, opts);
maybe_handle_kabi_whitelist_pkg(*pkg, opts);
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>
2017-04-03 18:10:06 +00:00
}
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
return is_ok;
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// Extract the two packages (and their ancillary packages) and
/// analyze their content, so that we later know what files from the
/// first package to compare against what files from the second
/// package.
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// Note that preparing the first package and its ancillary packages
/// happens in parallel with preparing the second package and its
/// ancillary packages. The function then waits for the two
/// preparations to complete before returning.
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// @param first_package the first package to consider.
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// @param second_package the second package to consider.
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// @param opts the options of the current program.
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// @return true iff the preparation went well.
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
static bool
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
prepare_packages(package_sptr &first_package,
package_sptr &second_package,
options &opts)
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
pkg_prepare_task_sptr first_pkg_prepare;
pkg_prepare_task_sptr second_pkg_prepare;
size_t NUM_PREPARATIONS = 2;
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
first_pkg_prepare.reset(new pkg_prepare_task(first_package, opts));
second_pkg_prepare.reset(new pkg_prepare_task(second_package, opts));
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
size_t num_workers = (opts.parallel
? std::min(opts.num_workers, NUM_PREPARATIONS)
: 1);
abigail::workers::queue preparation_queue(num_workers);
preparation_queue.schedule_task(first_pkg_prepare);
preparation_queue.schedule_task(second_pkg_prepare);
preparation_queue.wait_for_workers_to_complete();
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
return first_pkg_prepare->is_ok && second_pkg_prepare->is_ok;
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// Compare the added sizes of an ELF pair (specified by a comparison
/// task that compares two ELF files) against the added sizes of a
/// second ELF pair.
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
///
/// Larger filesize strongly raises the possibility of larger debug-info,
/// hence longer diff time. For a package containing several relatively
/// large and small ELFs, it is often more efficient to start working on
/// the larger ones first. This function is used to order the pairs by
/// size, starting from the largest.
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// @param t1 the first comparison task that compares a pair of ELF
/// files.
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// @param t2 the second comparison task that compares a pair of ELF
/// files.
///
/// @return true if @p task1 is greater than @p task2.
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
bool
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
elf_size_is_greater(const task_sptr &task1,
const task_sptr &task2)
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
compare_task_sptr t1 = dynamic_pointer_cast<compare_task>(task1);
compare_task_sptr t2 = dynamic_pointer_cast<compare_task>(task2);
off_t s1 = t1->args->elf1.size + t1->args->elf2.size;
off_t s2 = t2->args->elf1.size + t2->args->elf2.size;
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
return s1 > s2;
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// This type is used to notify the calling thread that the comparison
/// of two ELF files is done.
class comparison_done_notify : public abigail::workers::queue::task_done_notify
{
comparison_done_notify();
public:
abi_diff& diff;
abidiff_status status;
comparison_done_notify(abi_diff &d)
: diff(d),
status(abigail::tools_utils::ABIDIFF_OK)
{}
/// This operator is invoked by the worker queue whenever a
/// comparison task is done.
///
/// The operator collects the status of the job of the task and also
/// updates the the count of binaries that have ABI changes.
///
/// @param task_done the task that is done.
virtual void
operator()(const task_sptr& task_done)
{
compare_task_sptr comp_task = dynamic_pointer_cast<compare_task>(task_done);
assert(comp_task);
status |= comp_task->status;
if (status != abigail::tools_utils::ABIDIFF_OK)
{
string name = comp_task->args->elf1.name;
if (status & abigail::tools_utils::ABIDIFF_ABI_CHANGE)
diff.changed_binaries.push_back(name);
}
}
}; // end struct comparison_done_notify
/// Erase the temporary directories that might have been created while
/// handling two packages, unless the user asked to keep the temporary
/// directories around.
///
/// @param first_package the first package to consider.
///
/// @param second_package the second package to consider.
///
/// @param opts the options passed to the program.
static void
maybe_erase_temp_dirs(package& first_package, package& second_package,
options& opts)
{
if (opts.keep_tmp_files)
return;
erase_created_temporary_directories(first_package, second_package, opts);
erase_created_temporary_directories_parent(opts);
}
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>
2017-07-10 09:54:13 +00:00
/// Compare the ABI of two prepared packages that contain userspace
/// binaries.
///
/// A prepared package is a package which content has been extracted
/// and mapped.
///
/// @param first_package the first package to consider.
///
/// @param second_package the second package to consider.
///
/// @param options the options the current program has been called
/// with.
///
/// @param diff out parameter. If this function returns true, then
/// this parameter is set to the result of the comparison.
///
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
/// @param opts the options of the current program.
///
/// @return the status of the comparison.
static abidiff_status
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>
2017-07-10 09:54:13 +00:00
compare_prepared_userspace_packages(package& first_package,
package& second_package,
abi_diff& diff, options& opts)
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
{
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>
2017-07-10 09:54:13 +00:00
abidiff_status status = abigail::tools_utils::ABIDIFF_OK;
abigail::workers::queue::tasks_type compare_tasks;
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>
2017-04-03 18:10:06 +00:00
string pkg_name = first_package.base_name();
// Setting debug-info path of libraries
string debug_dir1, debug_dir2, relative_debug_path = "/usr/lib/debug/";
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
if (!first_package.debug_info_packages().empty()
&& !second_package.debug_info_packages().empty())
{
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
debug_dir1 =
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
first_package.debug_info_packages().front()->extracted_dir_path() +
relative_debug_path;
debug_dir2 =
second_package.debug_info_packages().front()->extracted_dir_path() +
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
relative_debug_path;
}
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
for (map<string, elf_file_sptr>::iterator it =
first_package.path_elf_file_sptr_map().begin();
it != first_package.path_elf_file_sptr_map().end();
++it)
{
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
map<string, elf_file_sptr>::iterator iter =
second_package.path_elf_file_sptr_map().find(it->first);
if (iter != second_package.path_elf_file_sptr_map().end()
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
&& (iter->second->type == abigail::dwarf_reader::ELF_TYPE_DSO
Bug 19961 - Distinguish between PI executable and shared library In the ELF format, Position Independent Executables (aka PIE) and shared libraries are marked as being of type ET_DYN. So just looking at the type of the ELF file is not enough to discriminate a position independent executable from a shared library. And this is the problem. Libabigail just looks at the type of the ELF file to discriminate PIE binaries from shared libraries binaries. So it treats both kinds of binaries as being shared libraries. When we run abipkgdiff with the --dso-only option, the tool considers both PIEs and shared libraries, even though the intent of the --dso-only option is have the tool consider shared libraries only. With this patch, we introduce a new enumerator ELF_TYPE_PI_EXEC (to the elf_type enum) for PIE binaries. From now on, a file will be properly recognized as being of the ELF_TYPE_DSO kind only if it is a shared library. * include/abg-dwarf-reader.h (elf_type): Add new enumerator ELF_TYPE_PI_EXEC. * src/abg-dwarf-reader.cc (lookup_data_tag_from_dynamic_segment): New function for data tag lookup in dynamic segment of an elf (elf_file_type): Return ELF_TYPE_PI_EXEC file type for a PI executable. (get_elf_file_type): Change this to take an elf handle. (get_type_of_elf_file): New function that got factorized out of ... (load_dt_soname_and_needed): ... this one. * tools/abipkgdiff.cc (create_maps_of_package_content): Also consider ELF_TYPE_PI_EXEC file type. (compare): Likewise. * tests/test-diff-pkg.cc (in_out_specs): Test case additions * tests/data/Makefile.am: Include test files * tests/data/test-diff-pkg/tarpkg-1-dir1.tar.gz: New test data * tests/data/test-diff-pkg/tarpkg-1-dir2.tar.gz: New test data * tests/data/test-diff-pkg/tarpkg-1-report-0.txt: New test result Signed-off-by: Sinny Kumari <sinny@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-04-19 18:31:56 +00:00
|| iter->second->type == abigail::dwarf_reader::ELF_TYPE_EXEC
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>
2017-04-03 18:10:06 +00:00
|| iter->second->type == abigail::dwarf_reader::ELF_TYPE_PI_EXEC
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>
2017-07-10 09:54:13 +00:00
|| iter->second->type == abigail::dwarf_reader::ELF_TYPE_RELOCATABLE))
{
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>
2017-07-10 09:54:13 +00:00
if (iter->second->type != abigail::dwarf_reader::ELF_TYPE_RELOCATABLE)
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>
2017-04-03 18:10:06 +00:00
{
compare_args_sptr args
(new compare_args(*it->second,
debug_dir1,
first_package.private_types_suppressions(),
*iter->second,
debug_dir2,
second_package.private_types_suppressions(),
opts));
compare_task_sptr t(new compare_task(args));
compare_tasks.push_back(t);
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
second_package.path_elf_file_sptr_map().erase(iter);
}
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>
2017-04-03 18:10:06 +00:00
else if (iter == second_package.path_elf_file_sptr_map().end())
{
diff.removed_binaries.push_back(it->second);
status |= abigail::tools_utils::ABIDIFF_ABI_INCOMPATIBLE_CHANGE;
status |= abigail::tools_utils::ABIDIFF_ABI_CHANGE;
}
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (compare_tasks.empty())
{
maybe_erase_temp_dirs(first_package, second_package, opts);
return abigail::tools_utils::ABIDIFF_OK;
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
// Larger elfs are processed first, since it's usually safe to assume
// their debug-info is larger as well, but the results are still
// in a map ordered by looked up in elf.name order.
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
std::sort(compare_tasks.begin(), compare_tasks.end(), elf_size_is_greater);
// There's no reason to spawn more workers than there are ELF pairs
// to be compared.
size_t num_workers = (opts.parallel
? std::min(opts.num_workers, compare_tasks.size())
: 1);
assert(num_workers >= 1);
comparison_done_notify notifier(diff);
abigail::workers::queue comparison_queue(num_workers, notifier);
// Compare all the binaries, in parallel and then wait for the
// comparisons to complete.
comparison_queue.schedule_tasks(compare_tasks);
comparison_queue.wait_for_workers_to_complete();
// Get the set of comparison tasks that were perform and sort them.
queue::tasks_type& done_tasks = comparison_queue.get_completed_tasks();
std::sort(done_tasks.begin(), done_tasks.end(), elf_size_is_greater);
// Print the reports of the comparison to standard output.
for (queue::tasks_type::const_iterator i = done_tasks.begin();
i != done_tasks.end();
++i)
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
{
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
compare_task_sptr t = dynamic_pointer_cast<compare_task>(*i);
cout << t->pretty_output;
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
// Update the count of added binaries.
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
for (map<string, elf_file_sptr>::iterator it =
second_package.path_elf_file_sptr_map().begin();
it != second_package.path_elf_file_sptr_map().end();
++it)
diff.added_binaries.push_back(it->second);
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
// Print information about removed binaries on standard output.
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
if (diff.removed_binaries.size())
{
cout << "Removed binaries:\n";
for (vector<elf_file_sptr>::iterator it = diff.removed_binaries.begin();
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
it != diff.removed_binaries.end(); ++it)
{
Bug 22488 - Make abipkgdiff handle different binaries with same basename Some packages might have different binaries with the same soname and basename, but at different paths. In that case, abipkgdiff messes things up because it only either consider the soname or the basename of the binary. This patch makes abipkgdiff to always consider the full path of the binary inside the package. * include/abg-tools-utils.h (string_suffix) (sorted_strings_common_prefix): Declare new functions. (dir_name): Take a new keep_separator_at_end parameter at the end. * src/abg-tools-utils.cc (dir_name): Take a new keep_separator_at_end parameter at the end. Add a comment for it and update. (string_suffix, sorted_strings_common_prefix): Define new functions. (common_prefix): Define new static function. * tools/abipkgdiff.cc (get_interesting_files_under_dir): Forward declare this pre-existing static function. (package::{common_paths_prefix_, elf_file_paths_}): New data members. (package::{common_paths_prefix, elf_file_paths, convert_path_to_relative, convert_path_to_unique_suffix, load_elf_file_paths}): New member functions. (create_maps_of_package_content): Use the new package::{load_elf_file_paths, convert_path_to_unique_suffix} functions. (compare_prepared_userspace_packages): Show relative paths of package elements in reported. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Update test ouptut. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-12-01 13:52:23 +00:00
string relative_path;
first_package.convert_path_to_relative((*it)->path, relative_path);
cout << " " << relative_path << ", ";
string soname;
get_soname_of_elf_file((*it)->path, soname);
if (!soname.empty())
cout << "SONAME: " << soname;
else
cout << "no SONAME";
cout << "\n";
}
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
// Print information about added binaries on standard output.
if (opts.show_added_binaries && diff.added_binaries.size())
{
cout << "Added binaries:\n";
for (vector<elf_file_sptr>::iterator it = diff.added_binaries.begin();
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
it != diff.added_binaries.end(); ++it)
{
Bug 22488 - Make abipkgdiff handle different binaries with same basename Some packages might have different binaries with the same soname and basename, but at different paths. In that case, abipkgdiff messes things up because it only either consider the soname or the basename of the binary. This patch makes abipkgdiff to always consider the full path of the binary inside the package. * include/abg-tools-utils.h (string_suffix) (sorted_strings_common_prefix): Declare new functions. (dir_name): Take a new keep_separator_at_end parameter at the end. * src/abg-tools-utils.cc (dir_name): Take a new keep_separator_at_end parameter at the end. Add a comment for it and update. (string_suffix, sorted_strings_common_prefix): Define new functions. (common_prefix): Define new static function. * tools/abipkgdiff.cc (get_interesting_files_under_dir): Forward declare this pre-existing static function. (package::{common_paths_prefix_, elf_file_paths_}): New data members. (package::{common_paths_prefix, elf_file_paths, convert_path_to_relative, convert_path_to_unique_suffix, load_elf_file_paths}): New member functions. (create_maps_of_package_content): Use the new package::{load_elf_file_paths, convert_path_to_unique_suffix} functions. (compare_prepared_userspace_packages): Show relative paths of package elements in reported. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Update test ouptut. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-12-01 13:52:23 +00:00
string relative_path;
second_package.convert_path_to_relative((*it)->path, relative_path);
cout << " " << relative_path << ", ";
string soname;
get_soname_of_elf_file((*it)->path, soname);
if (!soname.empty())
cout << "SONAME: " << soname;
else
cout << "no SONAME";
cout << "\n";
}
}
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
// Erase temporary directory tree we might have left behind.
maybe_erase_temp_dirs(first_package, second_package, opts);
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
status = notifier.status;
return status;
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
}
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>
2017-07-10 09:54:13 +00:00
/// Compare the ABI of two prepared packages that contain linux kernel
/// binaries.
///
/// A prepared package is a package which content has been extracted
/// and mapped.
///
/// @param first_package the first package to consider.
///
/// @param second_package the second package to consider.
///
/// @param options the options the current program has been called
/// with.
///
/// @param diff out parameter. If this function returns true, then
/// this parameter is set to the result of the comparison.
///
/// @param opts the options of the current program.
///
/// @return the status of the comparison.
static abidiff_status
compare_prepared_linux_kernel_packages(package& first_package,
package& second_package,
options& opts)
{
abidiff_status status = abigail::tools_utils::ABIDIFF_OK;
string pkg_name = first_package.base_name();
// Setting debug-info path of binaries
string debug_dir1, debug_dir2, relative_debug_path = "/usr/lib/debug/";
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
if (!first_package.debug_info_packages().empty()
&& !second_package.debug_info_packages().empty())
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>
2017-07-10 09:54:13 +00:00
{
debug_dir1 =
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
first_package.debug_info_packages().front()->extracted_dir_path() +
relative_debug_path;
debug_dir2 =
second_package.debug_info_packages().front()->extracted_dir_path() +
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>
2017-07-10 09:54:13 +00:00
relative_debug_path;
}
string vmlinux_path1, vmlinux_path2;
if (!get_vmlinux_path_from_kernel_dist(debug_dir1, vmlinux_path1))
return abigail::tools_utils::ABIDIFF_ERROR;
if (!get_vmlinux_path_from_kernel_dist(debug_dir2, vmlinux_path2))
return abigail::tools_utils::ABIDIFF_ERROR;
string dist_root1 = first_package.extracted_dir_path();
string dist_root2 = second_package.extracted_dir_path();
abigail::ir::environment_sptr env(new abigail::ir::environment);
suppressions_type supprs;
corpus_group_sptr corpus1, corpus2;
corpus1 = build_corpus_group_from_kernel_dist_under(dist_root1,
debug_dir1,
vmlinux_path1,
opts.suppression_paths,
opts.kabi_whitelist_paths,
supprs,
opts.verbose,
env);
if (!corpus1)
return abigail::tools_utils::ABIDIFF_ERROR;
corpus2 = build_corpus_group_from_kernel_dist_under(dist_root2,
debug_dir2,
vmlinux_path2,
opts.suppression_paths,
opts.kabi_whitelist_paths,
supprs,
opts.verbose,
env);
if (!corpus2)
return abigail::tools_utils::ABIDIFF_ERROR;
diff_context_sptr diff_ctxt(new diff_context);
set_diff_context_from_opts(diff_ctxt, opts);
corpus_diff_sptr diff = compute_diff(corpus1, corpus2, diff_ctxt);
if (diff->has_net_changes())
status |= abigail::tools_utils::ABIDIFF_ABI_CHANGE;
if (diff->has_incompatible_changes())
status |= abigail::tools_utils::ABIDIFF_ABI_INCOMPATIBLE_CHANGE;
if (status & abigail::tools_utils::ABIDIFF_ABI_CHANGE)
{
cout << "== Kernel ABI changes between packages '"
<< first_package.path() << "' and '"
<< second_package.path() << "' are: ===\n";
diff->report(cout);
cout << "== End of kernel ABI changes between packages '"
<< first_package.path()
<< "' and '"
<< second_package.path() << "' ===\n\n";
}
return status;
}
/// Compare the ABI of two prepared packages.
///
/// A prepared package is a package which content has been extracted
/// and mapped.
///
/// @param first_package the first package to consider.
///
/// @param second_package the second package to consider.
///
/// @param options the options the current program has been called
/// with.
///
/// @param diff out parameter. If this function returns true, then
/// this parameter is set to the result of the comparison.
///
/// @param opts the options of the current program.
///
/// @return the status of the comparison.
static abidiff_status
compare_prepared_package(package& first_package, package& second_package,
abi_diff& diff, options& opts)
{
abidiff_status status = abigail::tools_utils::ABIDIFF_OK;
if (abigail::tools_utils::file_is_kernel_package(first_package.base_name(),
first_package.type()))
{
opts.show_symbols_not_referenced_by_debug_info = false;
status = compare_prepared_linux_kernel_packages(first_package,
second_package,
opts);
}
else
status = compare_prepared_userspace_packages(first_package,
second_package,
diff, opts);
return status;
}
/// Compare the ABI of two packages
///
/// @param first_package the first package to consider.
///
/// @param second_package the second package to consider.
///
/// @param options the options the current program has been called
/// with.
///
/// @param diff out parameter. If this function returns true, then
/// this parameter is set to the result of the comparison.
///
/// @param opts the options of the current program.
///
/// @return the status of the comparison.
static abidiff_status
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
compare(package_sptr& first_package, package_sptr& second_package,
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>
2017-07-10 09:54:13 +00:00
abi_diff& diff, options& opts)
{
// Prepare (extract and analyze the contents) the packages and their
// ancillary packages.
//
// Note that the package preparations happens in parallel.
if (!prepare_packages(first_package, second_package, opts))
{
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
maybe_erase_temp_dirs(*first_package, *second_package, opts);
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>
2017-07-10 09:54:13 +00:00
return abigail::tools_utils::ABIDIFF_ERROR;
}
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
return compare_prepared_package(*first_package, *second_package, diff, opts);
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>
2017-07-10 09:54:13 +00:00
}
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
/// Compare the ABI of two packages.
///
/// @param first_package the first package to consider.
///
/// @param second_package the second package to consider.
///
/// @param opts the options the current program has been called with.
///
/// @return the status of the comparison.
static abidiff_status
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
compare(package_sptr& first_package,
package_sptr& second_package,
options& opts)
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
{
abi_diff diff;
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
return compare(first_package, second_package, diff, opts);
}
/// Parse the command line of the current program.
///
/// @param argc the number of arguments in the @p argv parameter.
///
/// @param argv the array of arguemnts passed to the function. The
/// first argument is the name of this program.
///
/// @param opts the resulting options.
///
/// @return true upon successful parsing.
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
static bool
parse_command_line(int argc, char* argv[], options& opts)
{
if (argc < 2)
return false;
for (int i = 1; i < argc; ++i)
{
if (argv[i][0] != '-')
{
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
if (opts.package1.empty())
{
opts.package1 = make_path_absolute(argv[i]).get();
opts.nonexistent_file = !file_exists(opts.package1);
}
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
else if (opts.package2.empty())
{
opts.package2 = make_path_absolute(argv[i]).get();
opts.nonexistent_file = !file_exists(opts.package2);
}
else
{
opts.wrong_arg = argv[i];
return false;
}
if (opts.nonexistent_file)
{
opts.wrong_option = argv[i];
return true;
}
}
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
else if (!strcmp(argv[i], "--debug-info-pkg1")
|| !strcmp(argv[i], "--d1"))
{
int j = i + 1;
if (j >= argc)
{
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
opts.missing_operand = true;
opts.wrong_option = argv[i];
return true;
}
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
opts.debug_packages1.push_back
(abigail::tools_utils::make_path_absolute(argv[j]).get());
++i;
}
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
else if (!strcmp(argv[i], "--debug-info-pkg2")
|| !strcmp(argv[i], "--d2"))
{
int j = i + 1;
if (j >= argc)
{
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
opts.missing_operand = true;
opts.wrong_option = argv[i];
return true;
}
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
opts.debug_packages2.push_back
(abigail::tools_utils::make_path_absolute(argv[j]).get());
++i;
}
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>
2016-05-20 07:19:51 +00:00
else if (!strcmp(argv[i], "--devel-pkg1")
|| !strcmp(argv[i], "--devel1"))
{
int j = i + 1;
if (j >= argc)
{
opts.missing_operand = true;
opts.wrong_option = argv[i];
return true;
}
opts.devel_package1 =
abigail::tools_utils::make_path_absolute(argv[j]).get();
++i;
}
else if (!strcmp(argv[i], "--devel-pkg2")
|| !strcmp(argv[i], "--devel2"))
{
int j = i + 1;
if (j >= argc)
{
opts.missing_operand = true;
opts.wrong_option = argv[i];
return true;
}
opts.devel_package2 =
abigail::tools_utils::make_path_absolute(argv[j]).get();
++i;
}
Bug 21058 - abipkgdiff wrongly drops non-public types When using abipkgdiff types that are defined in files not present in the devel packages provided by the --devel1 and --devel2 option are dropped from the internal representation by default. This has been designed as such, not only to avoid showing changes on types that are not part of the public headers of a shared library, but also to help lower the memory consumption of libabigail. In this particular bug report, we see a library that uses types (in its public interface) that are defined in headers of a *different* package. For instance, suppose a particular package foo that uses types defined in headers of the glib package. And some of those Glib types can be present in its public interface. So in this case, libabigail is dropping a type that is actually part of the public interface of the library that is being analyzed, even if the type was not defined in the devel package of the current package. This patch addresses the issue by doing a number of things: 1/ If a type is defined in a file which path starts with "/usr/include/", then consider it as a public type. This is so that type coming from the public interface of other packages, and that are defined in system headers are considered as part of the public types of the package being analyzed. 2/ by default, don't drop types not defined in the associated devel package. This will hinder our ability to decrease the memory usage, but there have been a number of recent optimization that help in that regard independently. So I am hoping this shouldn't have a big impact now. Incidentally, the option --dont-drop-private-types (from abidiff) is changed into --drop-private-types, so that interested users can still drop non-private types from the model, if they wish. That --drop-private-types option is added to abipkgdiff too. As the offended types are not dropped from the model anymore, the usual filtering mechanisms of libabigail can take place. * doc/manuals/abidiff.rst (--dont-drop-private-types): Remove documentation. (--drop-private-types): Document this new option. * src/abg-tools-utils.cc: Update copyright notice (handle_fts_entry): On the generated suppression specification, do not set the flag to drop matched types. Also, don't match types defined in files which patch start with "/usr/include/". * tools/abidiff.cc (options::options): Initialize the drop_private_types data member to false. (display_usage): Remove usage string for --dont-drop-private-types. Add a new one for --drop-private-types. (parse_command_line): Don't part --dont-drop-private-types, rather, parse --drop-private-types. (set_suppressions): When the suppression for private types is generated, if --drop-private-types was provided, then instruct the suppression to drop matched types. * tools/abipkgdiff.cc (options::drop_private_types): New option. (options::options): Initialize the new drop_private_types data member to false. (display_usage): Add a usage string for --drop-private-types. (parse_command_line): Parse the new --drop-private-types option. (maybe_create_private_types_suppressions): Don't take just a package, but a package_descriptor because the latter carries the options. So when the user used the --drop-private-types option, make the generated private types suppression to drop matched types. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Adjust. * tests/test-diff-suppr.cc (in_out_specs): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-01-18 09:10:10 +00:00
else if (!strcmp(argv[i], "--drop-private-types"))
opts.drop_private_types = true;
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>
2016-05-30 08:37:48 +00:00
else if (!strcmp(argv[i], "--no-default-suppression"))
opts.no_default_suppression = true;
else if (!strcmp(argv[i], "--keep-tmp-files"))
opts.keep_tmp_files = true;
else if (!strcmp(argv[i], "--dso-only"))
opts.compare_dso_only = true;
Add a --leaf-changes-only option to abipkgdiff This patch adds the --leaf-changes-only option to abipkgdiff, just like what we have for abidiff. The patch also emit leaf changes report by default when comparing two Linux Kernel packages. The patch also adds the --impacted-interfaces and --full-impact options. * doc/manuals/abipkgdiff.rst: Add documentation for the new --leaf-change-only, --impacted-interfaces and --full-impact options. * tools/abipkgdiff.cc (options::{leaf_changes_only, show_impacted_interfaces, show_full_impact_report): Add new data members. (options::options): Initialize them. (display_usage): Add help strings for the new --leaf-change-only, --impacted-interfaces and --full-impact|-f options. (set_diff_context_from_opts): Set the diff context for the 'leaf-changes-only' and 'show-impacted-interfaces' flags. (parse_command_line): Parse the --leaf-change-only, --impacted-interfaces and --full-impact options. Handle the case where the --linux-kernel-abi-whitelist|-w option is given a whitelist *package*. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt: New test output reference. * tests/test-diff-pkg.cc (in_out_spec): Compare data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64.rpm and data/test-diff-pkg/spice-server-0.12.8-1.el7.x86_64.rpm with the new --leaf-changes-only and --impacted-interfaces options, using the new output reference above. * tests/data/Makefile.am: Add the new test material to source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-09-18 14:00:23 +00:00
else if (!strcmp(argv[i], "--leaf-changes-only")
||!strcmp(argv[i], "-l"))
opts.leaf_changes_only = true;
else if (!strcmp(argv[i], "--impacted-interfaces")
||!strcmp(argv[i], "-i"))
opts.show_impacted_interfaces = true;
else if (!strcmp(argv[i], "--full-impact")
||!strcmp(argv[i], "-f"))
opts.show_full_impact_report = true;
else if (!strcmp(argv[i], "--no-linkage-name"))
opts.show_linkage_names = false;
else if (!strcmp(argv[i], "--redundant"))
opts.show_redundant_changes = true;
else if (!strcmp(argv[i], "--harmless"))
opts.show_harmless_changes = true;
Add the option of printing the file, line and column information about a type being reported. * bash-completion/abicompat: Complete the new "--no-show-locs" option. * bash-completion/abidiff: Likewise. * bash-completion/abidw: Likewise. * bash-completion/abipkgdiff: Likewise. * doc/manuals/abicompat.rst: Mention the new "--no-show-locs" option. * doc/manuals/abidiff.rst: Likewise. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-comparison.h (show_locs): Add declarations. * src/abg-comparison.cc: (diff_context::priv): Add a new switch called "show_locs_" and set its default value to false. (report_loc_info): New function. Outputting the extra information is conditionalized based on the associated diff contexts settings. (show_locs): define a getter/setter for diff_context::priv::show_locs_. ({distinct,pointer,reference,qualified_type,enum,class,scope,fn_parm, typedef,corpus}_diff::report): Call report_loc_info when appropriate. (maybe_report_diff_for_member): Likewise. (represent): Accept a const reference to a diff_context_sptr as a first argument and call report_loc_info on its second argument. * src/abg-dwarf-reader.cc: * tests/data/Makefile.am: Add the new test reference files. * tests/data/test-abicompat/test0-fn-changed-report-2.txt: New test reference output. * tests/data/test-abicompat/test5-fn-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test6-var-changed-report-1.txt: Likewise. * tests/data/test-abicompat/test7-fn-changed-report-2.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-pkg/dirpkg-3-report-2.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. * tests/test-abidiff.cc: Explicitly create a diff context and turn off location emitting. * tests/test-diff-dwarf.cc: Likewise. * tests/test-abicompat.cc: Add --no-show-locs to all existing test arguments. Run a few of the existing tests again, but without this option. * tests/test-diff-filter.cc: Likewise. * tests/test-diff-pkg.cc: Likewise. * tests/test-diff-suppr.cc: Likewise. * tools/abicompat.cc: Handle the new "--no-show-locs" option. * tools/abidiff.cc: Likewise. * tools/abidw.cc: Likewise. * tools/abipkgdiff.cc: Likewise. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-16 09:55:28 +00:00
else if (!strcmp(argv[i], "--no-show-locs"))
opts.show_locs = false;
Bug 20887 - Show relative change of offsets Until now, an offset change is reported by showing the old and new offsets of the data member that changed. This patch adds the string "(by +N bits)" with 'N' being the number of bits by which the offset of the data member was increased, or "(by -N bits) if the offset of the data member was decreased of N bits. The patch also emits a string that says "size hasn't changed" if the size of the structure did not change. This can be disabled by a new --no-show-relative-offset-changes option. * doc/manuals/abidiff.rst: Document the new --no-show-relative-offset-changes. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-comparison.h (diff_context::show_relative_offset_changes): New accessors. * include/abg-ir.h ({set,get}_data_member_offset): Return uint64_t instead of the less portable size_t. * src/abg-comparison.cc (diff_context::priv::show_relative_offset_changes_): New data member. (dif_context::show_relative_offset_changes): Define accessor. (maybe_show_relative_offset_change): Define new function. (represent): In the overload for var_diff, call the new maybe_show_relative_offset_change. (report_size_and_alignment_changes): If the size of the type didn't change then say it now. * src/abg-ir.cc (set_data_member_offset, get_data_member_offset): Take or return a uint64_t instead of a size_t. * tools/abidiff.cc (options::show_relative_offset_changes): New data member. (options::options): Initialize it. (display_usage): Display help string for the new --no-show-relative-offset-changes. (parse_command_line): Parse the new --no-show-relative-offset-changes options. (set_diff_context_from_opts): Set the "show-relative-offset-changes" flag according to the new option.n * tools/abipkgdiff.cc (options::show_relative_offset_changes): New data member. (options::options): Initialize it. (display_usage): Add help string for the new --no-show-relative-offset-changes option. (set_diff_context_from_opts): Set the "show-relative-offset-changes" flag according to the new option. (parse_command_line): Parse the new command line option. * tests/data/test-diff-dwarf/test40-report-0.txt: Add new reference output. * tests/data/test-diff-dwarf/test40-v0.c: Source code of the first test binary. * tests/data/test-diff-dwarf/test40-v1.c: Source code of the second test binay. * tests/data/test-diff-dwarf/libtest40-v0.so: New first test binary. * tests/data/test-diff-dwarf/libtest40-v1.so: New second test binary. * tests/test-diff-dwarf.cc (in_out_spec): Add the new test binaries above to the set of binaries that are compared. * tests/data/Makefile.am: Add the new test material to source distribution. * tests/data/test-abicompat/test7-fn-changed-report-0.txt: Adjust. * tests/data/test-abidiff/test-PR18791-report0.txt: Likewise. * tests/data/test-abidiff/test-enum0-report.txt: Likewise. * tests/data/test-abidiff/test-enum1-report.txt: Likewise. * tests/data/test-abidiff/test-struct1-report.txt: Likewise. * tests/data/test-diff-dwarf/test0-report.txt: Likewise. * tests/data/test-diff-dwarf/test1-report.txt: Likewise. * tests/data/test-diff-dwarf/test10-report.txt: Likewise. * tests/data/test-diff-dwarf/test11-report.txt: Likewise. * tests/data/test-diff-dwarf/test13-report.txt: Likewise. * tests/data/test-diff-dwarf/test15-enum-report.txt: Likewise. * tests/data/test-diff-dwarf/test27-local-base-diff-report.txt: Likewise. * tests/data/test-diff-dwarf/test32-fnptr-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test33-fnref-changes-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test38-union-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test4-report.txt: Likewise. * tests/data/test-diff-dwarf/test5-report.txt: Likewise. * tests/data/test-diff-dwarf/test6-report.txt: Likewise. * tests/data/test-diff-dwarf/test8-report.txt: Likewise. * tests/data/test-diff-filter/test0-report.txt: Likewise. * tests/data/test-diff-filter/test01-report.txt: Likewise. * tests/data/test-diff-filter/test1-report.txt: Likewise. * tests/data/test-diff-filter/test13-report.txt: Likewise. * tests/data/test-diff-filter/test16-report-2.txt: Likewise. * tests/data/test-diff-filter/test16-report.txt: Likewise. * tests/data/test-diff-filter/test17-0-report.txt: Likewise. * tests/data/test-diff-filter/test17-1-report.txt: Likewise. * tests/data/test-diff-filter/test18-report.txt: Likewise. * tests/data/test-diff-filter/test19-enum-report-1.txt: Likewise. * tests/data/test-diff-filter/test2-report.txt: Likewise. * tests/data/test-diff-filter/test23-redundant-fn-parm-change-report-0.txt: Likewise. * tests/data/test-diff-filter/test24-compatible-vars-report-1.txt: Likewise. * tests/data/test-diff-filter/test25-cyclic-type-report-0.txt: Likewise. * tests/data/test-diff-filter/test25-cyclic-type-report-1.txt: Likewise. * tests/data/test-diff-filter/test26-qualified-redundant-node-report-0.t: Likewise.xt * tests/data/test-diff-filter/test26-qualified-redundant-node-report-1.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt: Likewise. * tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt: Likewise. * tests/data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt: Likewise. * tests/data/test-diff-filter/test3-report.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise. * tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt: Likewise. * 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: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test10-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-suppr/test2-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test3-struct-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test30-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test4-local-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-1.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-2.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-3.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-4.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-7.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-8.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-12-02 13:41:07 +00:00
else if (!strcmp(argv[i], "--no-show-relative-offset-changes"))
opts.show_relative_offset_changes = false;
else if (!strcmp(argv[i], "--no-added-syms"))
opts.show_added_syms = false;
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>
2017-04-03 18:10:06 +00:00
else if (!strcmp(argv[i], "--no-unreferenced-symbols"))
opts.show_symbols_not_referenced_by_debug_info = false;
else if (!strcmp(argv[i], "--no-added-binaries"))
opts.show_added_binaries = false;
else if (!strcmp(argv[i], "--fail-no-dbg"))
opts.fail_if_no_debug_info = true;
else if (!strcmp(argv[i], "--verbose"))
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
opts.verbose = true;
else if (!strcmp(argv[i], "--no-abignore"))
opts.abignore = false;
Bug 19081 - abipkgdiff parallelization Abipkgdiff now attempts to extract packages and compare the resulting ELF pairs in parallel. First off, a thread is spawned to extract each package and each debuginfo package. After the ELF files are extracted, mapped and the threads are successfully collected, the resulting ELF vectors are traversed to identify existing pairs and a list of arguments for future comparison is made. This list is then sorted by size from largest to smallest. Unless --no-parallel is specified on the command line, MIN(pairs,active_processors) threads are spawned, sharing a single list of arguments. This list is processed and a map of (ELF_PATH,DIFF_CORPUS) is created. Meanwhile, the main thread checks this same map for results in the original order of the ELF pairs, ensuring sequential output. After all the diffing and reporting is done, the threads are collected again. * doc/manuals/abipkgdiff.rst: Mention the new --no-parallel option. * tools/Makefile.am: Add -pthread to abipkgdiffs link options. * tools/abipkgdiff.cc (elf_file_paths_tls_key): New key for the thread-local vector of ELF filepaths. (reports_map): A map of the path of the first ELF of a compared pair and a corpus representing the difference. (env_map): A map of the corpus difference and a corresponding environment needed to be kept alive until the diff is reported. ({arg,map}_lock): mutexes to control access to the comparison argument list and the {reports,env}_map respectively. (options): Add a new member "parallel" and set it to true in the ctor. (elf_file): Add a new "size" member and set it in the ctor. (package descriptor): Arguments passed to extract_package_set. (compare_args): Arguments passed to the ELF comparison function. (display_usage): Mention the new "--no-parallel" option. (pthread_routine_extract_package): A wrapper function around extract_package to be used in a multi-threaded environment. ({first_second}_package_tree_walker_callback_fn): Add the new ELF file paths to a thread-specific vector. (compare): In an overload of compare, verbose output is updated to always mention the ELF files being compared for each reported stage. Reporting is no longer done in this function, the resulting difference is instead passed back to the calling function for reporting in the main thread, along with a corresponding environment. (pthread_routine_compare): Accept a pointer to a vector of comparison arguments. This function is to be called NTHREAD times and share the vector passed to it with its other invocations. Create the environment for compare() and store its output in a map if there is a difference. (create_maps_of_package_content): Allocate memory for a thread local vector of ELF paths and dispose of it before returning. (pthread_routine_extract_pkg_and_map_its_content): Renamed from extract_package_and_map_its_content. Extract the debuginfo as well as the regular package in this function. Spawn a separate thread for the extraction of the debug package. (pthread_join): A function handling thread joining throughout package extractions. (prepare_packages): Spawn a thread to extract each set of packages. (elf_size_is_greater): New comparison function used to order ELF pairs by size. (compare): In the overload of compare, pass through the ELF path vectors and identify pairs to be diffed. Put them in a vector and sort it by the summed ELF pair size. Spawn comparison threads and safely check for results in the proper order of the ELF pairs. Report any differences ASAP and collect the threads after all the reporting is done, checking their return status. (parse_command_line): Check for the "--no-parallel" option. Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-11-09 10:02:45 +00:00
else if (!strcmp(argv[i], "--no-parallel"))
opts.parallel = false;
Make fedabipkgdiff consistent with Libabigail's other tests In the libabigail project, almost all the tests for the tools follow a similar pattern. The test contains a set of input files to compare. The result of the comparison is thus compared to a set of reference comparison result. This approach is already documented in the CONTRIBUTING file. There are several interesting properties with this scheme. First, it capture the behaviour of the tools, including what is shown to the user. Second, it eases the job of a hacker who wants to add a new test for a new behaviour of a given tool. The user just has to provide: 1/ A new reference output of the new use case of the tool (that is easily constructed by using the tool itself and saving its output) and add an entry to array of entries that describe what to compare 2/ A new set of inputs to the tool And voila. Unfortunately, fedabipkgdiff tests don't follow this scheme. That make them surprising to hackers who read the source code of the existing tests, at very least. Also, the fedabipkgdiff tests were only unit tests. They were not testing the tool as used by users in general. This patch makes the fedabipkgdiff tests follow the general approach of the tests of the other Libabigail tools. The patch first craetes a program names tests/mockfedabipkgdiff. It's a wrapper around tools/fedabipkgdiff. It overloads the Koji client of fedabipkgdiff with a fake Koji client that gets the Fedora packages locally, from tests/data/test-fedabipkgdiff/packages. In other words, mockfedabipkgdiff is fedabipkgdiff without going to the network. I believe that in the future, tests/mockfedabipkgdiff should be killed when fedabipkgdiff is able to cache a local description of a local partial view of a Koji repository, along with the build packages that were already downloaded. That way, calling fedabipkgdiff twice with the same set of option should make the tool perform correctly without going to the netword on the second invocation. We should be able to save the local partial view of the Koji repository under e.g, tests/data/test-fedabipkgdiff/local-koji and tell fedabipkgdiff to use that, instead of using the network. But we are not there yet. So for now, I am using mockfedabipkgdiff. Then, tests/runtestfedabipkdiff.py.in has been re-written to use tests/mockfedabipkgdiff and to look like what is described in CONTRIBUTING as far as how Libabigail tools' tests are organized: mockfedabipkgdiff is called to perform a comparison. The result of the comparison is then compared (using GNU diff) to a reference comparison result file. Please note that tests/runtestfedabipkdiff.py is relatively fast for the moment. But when it contains much more tests and start becoming slow, then we'll need to change the code to run several comparisons in parallel, just like we do today in tests/test-diff-filter.cc. At that point, I believe I'll just re-write this in C++, just like tests/test-diff-filter.cc because that will allow us to have true concurrent code based on the abigail:workers API. For now, I am keeping this in Python also because I think that keeps Chenxiong happy ;-) To be sure that fedabipkgdiff (and its underlying abipkgdiff) are really comparing all the packages they are supposed to compare and also all the binaries in those packages, I have added a new --show-identical-binaries to abipkgdiff and fedabipkgdiff. That option shows the name of the binaries (and packages) that are compared, *even if* the ABI of those binaries are identical. Because otherwise, today, if two binaries (or packages) have the same ABI, nothing is displayed. For instance, here is the result of comparing a package against itself, using this new --show-identical-binaries options: dodji@adjoa:patches$ ./tools/fedabipkgdiff --abipkgdiff ./build/tools/abipkgdiff --show-identical-binaries dbus-glib-0.80-3.fc12.x86_64.rpm dbus-glib-0.80-3.fc12.x86_64.rpm Comparing the ABI of binaries between dbus-glib-0.80-3.fc12.x86_64.rpm and dbus-glib-0.80-3.fc12.x86_64.rpm: ================ changes of 'dbus-binding-tool'=============== No ABI change detected ================ end of changes of 'dbus-binding-tool'=============== ================ changes of 'libdbus-glib-1.so.2.1.0'=============== No ABI change detected ================ end of changes of 'libdbus-glib-1.so.2.1.0'=============== dodji@adjoa:patches$ And here is what this command before that patch would do: dodji@adjoa:patches$ ./tools/fedabipkgdiff --abipkgdiff ../master/build/tools/abipkgdiff dbus-glib-0.80-3.fc12.x86_64.rpm dbus-glib-0.80-3.fc12.x86_64.rpm Comparing the ABI of binaries between dbus-glib-0.80-3.fc12.x86_64.rpm and dbus-glib-0.80-3.fc12.x86_64.rpm: dodji@adjoa:patches$ The rest of the patch is mostly new test inputs material and the necessary adjustments following all the changes above. * configure.ac: Do not require Python dependencies itertools, unittest and StringIO anymore as they are not used anymore. Require new module tempfile now. Generate new executable script tests/mockfedabipkgdiff from tests/mockfedabipkgdiff.in. * doc/manuals/abipkgdiff.rst: Add doc for new option --show-identical-binaries to abipkgdiff * doc/manuals/fedabipkgdiff.rst: Add doc for new options --show-identical-binaries to fedabipkgdiff. * tools/abipkgdiff.cc (options::show_identical_binaries): New data member. (options::options): Initialize new data member. (display_usage): Add a new help string for the new --show-identical-binaries option. (parse_command_line): Parse the newq --show-identical-binaries command line switch. (pthread_routine_compare): When the comparison of two binaries is empty, if --show-identical-binaries was provided, then emit some output saying the comparison did yield the empty set. * tools/fedabipkgdiff (DEFAULT_ABIPKGDIFF): Store the default path to abipkgdiff in this new global variable. Naming this default path is useful because it can then be cleanly overloaded when using mock.patch. (build_path_to_abipkgdiff): Return the new DEFAULT_ABIPKGDIFF global variable. (cmd): Parse the new --show-identical-binaries command line switch. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: New reference output. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/mockfedabipkgdiff.in: New uninstalled script template. * tests/runtestfedabipkgdiff.py.in (counter) (temp_file_or_dir_prefix, UtilsTest, RPMTest, LocalRPMTest) (RunAbipkgdiffTest, GetPackageLatestBuildTest, DownloadRPMTest) (BrewListRPMsTest, AssertionHelper, MockGlobalConfig) (BUILT_ABIPKGDIFF, CompareABIFromCommandLineTest): Remove these classes, global variables and functions. (FEDABIPKGDIFF, TEST_SRC_DIR, TEST_BUILD_DIR, INPUT_DIR) (OUTPUT_DIR, FEDABIPKGDIFF_TEST_SPECS): New global variables. (ensure_output_dir_created, run_fedabipkgdiff_tests, main): New functions. * tests/test-diff-pkg.cc (in_out_specs): Add tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt to the set of reference outputs to consider. * tests/Makefile.am: Add non-installed script mockfedabipkgdiff to source distribution. Also added tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt, tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt, tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt, tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt and tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt to source distribution. Signed-off-by: Chenxiong Qi <cqi@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-07-06 09:51:13 +00:00
else if (!strcmp(argv[i], "--show-identical-binaries"))
opts.show_identical_binaries = true;
else if (!strcmp(argv[i], "--suppressions")
|| !strcmp(argv[i], "--suppr"))
{
int j = i + 1;
if (j >= argc)
return false;
opts.suppression_paths.push_back(argv[j]);
++i;
}
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>
2017-04-03 18:10:06 +00:00
else if (!strcmp(argv[i], "--linux-kernel-abi-whitelist")
|| !strcmp(argv[i], "-w"))
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>
2017-04-03 18:10:06 +00:00
{
int j = i + 1;
if (j >= argc)
{
opts.missing_operand = true;
opts.wrong_option = argv[i];
return true;
}
Add a --leaf-changes-only option to abipkgdiff This patch adds the --leaf-changes-only option to abipkgdiff, just like what we have for abidiff. The patch also emit leaf changes report by default when comparing two Linux Kernel packages. The patch also adds the --impacted-interfaces and --full-impact options. * doc/manuals/abipkgdiff.rst: Add documentation for the new --leaf-change-only, --impacted-interfaces and --full-impact options. * tools/abipkgdiff.cc (options::{leaf_changes_only, show_impacted_interfaces, show_full_impact_report): Add new data members. (options::options): Initialize them. (display_usage): Add help strings for the new --leaf-change-only, --impacted-interfaces and --full-impact|-f options. (set_diff_context_from_opts): Set the diff context for the 'leaf-changes-only' and 'show-impacted-interfaces' flags. (parse_command_line): Parse the --leaf-change-only, --impacted-interfaces and --full-impact options. Handle the case where the --linux-kernel-abi-whitelist|-w option is given a whitelist *package*. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt: New test output reference. * tests/test-diff-pkg.cc (in_out_spec): Compare data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64.rpm and data/test-diff-pkg/spice-server-0.12.8-1.el7.x86_64.rpm with the new --leaf-changes-only and --impacted-interfaces options, using the new output reference above. * tests/data/Makefile.am: Add the new test material to source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-09-18 14:00:23 +00:00
if (guess_file_type(argv[j]) == abigail::tools_utils::FILE_TYPE_RPM)
// The kernel abi whitelist is actually a whitelist
// *package*. Take that into account.
opts.kabi_whitelist_packages.push_back
(make_path_absolute(argv[j]).get());
else
// We assume the kernel abi whitelist is a white list
// file.
opts.kabi_whitelist_paths.push_back(argv[j]);
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>
2017-04-03 18:10:06 +00:00
++i;
}
else if (!strcmp(argv[i], "--wp"))
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>
2017-04-03 18:10:06 +00:00
{
int j = i + 1;
if (j >= argc)
{
opts.missing_operand = true;
opts.wrong_option = argv[i];
return true;
}
opts.kabi_whitelist_packages.push_back
(make_path_absolute(argv[j]).get());
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>
2017-04-03 18:10:06 +00:00
++i;
}
else if (!strcmp(argv[i], "--help")
|| !strcmp(argv[i], "-h"))
{
opts.display_usage = true;
return true;
}
Add --version option to several libabigail tools This patch changed the revision number of the libabigail library to make it reflect the fact that we are not in "release candidate" mode, before the first 1.0 release. So the revision number is now "rc0". The configuration manager has been updated to support version numbers that are strings, so that it can supports things like "rc0". Then, several libabigail tools have been modified to support the --version option to display their version number. * configure.ac: Set the version revision to "rc0". * doc/manuals/abicompat.rst: Adjust manual for new --version option. * doc/manuals/abidiff.rst: Likewise. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abilint.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-config.h (config::{m_format_minor, m_format_major}): Make these be strings. (config::{get,set}_format_minor_version_number): Make these return strings. (config::{get,set}_format_major_version_number): Make these return or take strings. (abigail_get_library_version): Make this take strings. * src/abg-config.cc (config::config): Adjust. (config::{get,set}_format_major_version_number): Make these return or take strings. (config::{get,set}_format_minor_version_number): Make these return strings. (abigail_get_library_version): Make this take strings. * include/abg-version.h.in: Make the version variables be strings. * src/abg-writer.cc (write_translation_unit): The version numbers are now strings so adjust. * tools/{abicompat,abidiff,abidw,abilint,abipkgdiff,abisym}.cc (options::display_version): New data member. (options::options): Initialize it. (display_usage): Add documentation for new --version option. (parse_command_line): Parse new --version option. (main): Support --version. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-11-16 10:39:15 +00:00
else if (!strcmp(argv[i], "--version")
|| !strcmp(argv[i], "-v"))
{
opts.display_version = true;
return true;
}
else
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
{
if (strlen(argv[i]) >= 2 && argv[i][0] == '-' && argv[i][1] == '-')
opts.wrong_option = argv[i];
return false;
}
}
return true;
}
int
main(int argc, char* argv[])
{
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
options opts(argv[0]);
Make abipkgdiff.cc use the abigail::workers interface With this patch, the code of abipkgdiff.cc doesn't use the pthreads API directly anymore. Rather, it uses the higher level "Workers Queue" API provided by the abigail::workers namespace. The main benefits are: - better code readability and maintainability. The code base doesn't have any global variable anymore. This is going to be helpful when adding new features to the abipkgdiff.cc code base. - faster code. The tests/runtestdiffpkg test program executes on ~ 17s without the patch, and on ~ 11s with the patch on my old X220 laptop. * tools/abipkgdiff.cc: Remove ftw.h, pthread.h, unistd.h, add fts.h and abg-workers.h. (verbose, elf_file_paths_tls_key, reports_map, env_map, map_lock) (arg_lock, prog_options): Remove all these global variables. (struct package_descriptor): Remove this type. (pthread_routine_extract_package) (first_package_tree_walker_callback_fn) (second_package_tree_walker_callback_fn, pthread_routine_compare) (pthread_join, pthread_routine_extract_pkg_and_map_its_content): Remove these functions. (options::{num_workers, verbose}): Define new data members. (options::options): Initialize the new verbose and num_workers data members. (package::erase_extraction_directory) (erase_created_temporary_directories_parent): Take the program options in parameter. Don't use the global verbose variable anymore. (package::erase_extraction_directories) (erase_created_temporary_directories, extract_package): Take the program options in parameter. (extract_rpm, extract_deb, extract_tar): Likewise. And don't use the global verbose variable anymore. (compare): Don't use the global verbose variable anymore. Use the new compare_task type along with the abigail::workers::queue type. (pkg_extraction_task, pkg_prepare_task, compare_task) (comparison_done_notify): Define new classes. (maybe_update_vector_of_package_content): Define new static function. (create_maps_of_package_content): Don't take the ftw_cp_type anymore. Don't use the global verbose variable anymore. Use the fts_{open,read,close} functions, rather than the ftw one. (extract_package_and_map_its_content): Don't use pthreads anymore. Use the new pkg_extraction_task type created along with the abigail::workers::queue type. (prepare_packages): Don't use pthreads anymore. Use the new pkg_prepare_task type along with the abigail::workers::queue type. (elf_size_is_greater): Adjust to use abigail::workers::queue::tasks, rather than the previous compaer_args_sptr type. (parse_command_line): Adjust to stop using the global verbose variable. (main): Remove use of global variables prog_options and also the packages variable. * tests/data/test-diff-pkg/dbus-glib-0.104-3.fc23.x86_64--dbus-glib-0.104-3.fc23.armv7hl-report-0.txt: Adjust. * tests/data/test-diff-pkg/dirpkg-0-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-dbus-glib-0.80-3.fc12.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-0.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-1.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-2.txt: Likewise. * tests/data/test-diff-pkg/test-rpm-report-3.txt: Likewise. * tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise. * tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-02-24 13:16:35 +00:00
if (!parse_command_line(argc, argv, opts))
{
if (!opts.wrong_option.empty())
emit_prefix("abipkgdiff", cerr)
<< "unrecognized option: " << opts.wrong_option
<< "\ntry the --help option for more information\n";
else
emit_prefix("abipkgdiff", cerr)
<< "unrecognized argument: " << opts.wrong_arg
<< "\ntry the --help option for more information\n";
return (abigail::tools_utils::ABIDIFF_USAGE_ERROR
| abigail::tools_utils::ABIDIFF_ERROR);
}
if (opts.missing_operand)
{
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< "missing operand\n"
"try the --help option for more information\n";
return (abigail::tools_utils::ABIDIFF_USAGE_ERROR
| abigail::tools_utils::ABIDIFF_ERROR);
}
if (opts.nonexistent_file)
{
string input_file;
base_name(opts.wrong_option, input_file);
emit_prefix("abipkgdiff", cerr)
<< "The input file " << input_file << " doesn't exist\n"
"try the --help option for more information\n";
return (abigail::tools_utils::ABIDIFF_USAGE_ERROR
| abigail::tools_utils::ABIDIFF_ERROR);
}
if (opts.kabi_whitelist_packages.size() > 2)
{
emit_prefix("abipkgdiff", cerr)
<< "no more than 2 Linux kernel white list packages can be provided\n";
return (abigail::tools_utils::ABIDIFF_USAGE_ERROR
| abigail::tools_utils::ABIDIFF_ERROR);
}
if (opts.display_usage)
{
display_usage(argv[0], cout);
return (abigail::tools_utils::ABIDIFF_USAGE_ERROR
| abigail::tools_utils::ABIDIFF_ERROR);
}
Add --version option to several libabigail tools This patch changed the revision number of the libabigail library to make it reflect the fact that we are not in "release candidate" mode, before the first 1.0 release. So the revision number is now "rc0". The configuration manager has been updated to support version numbers that are strings, so that it can supports things like "rc0". Then, several libabigail tools have been modified to support the --version option to display their version number. * configure.ac: Set the version revision to "rc0". * doc/manuals/abicompat.rst: Adjust manual for new --version option. * doc/manuals/abidiff.rst: Likewise. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abilint.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-config.h (config::{m_format_minor, m_format_major}): Make these be strings. (config::{get,set}_format_minor_version_number): Make these return strings. (config::{get,set}_format_major_version_number): Make these return or take strings. (abigail_get_library_version): Make this take strings. * src/abg-config.cc (config::config): Adjust. (config::{get,set}_format_major_version_number): Make these return or take strings. (config::{get,set}_format_minor_version_number): Make these return strings. (abigail_get_library_version): Make this take strings. * include/abg-version.h.in: Make the version variables be strings. * src/abg-writer.cc (write_translation_unit): The version numbers are now strings so adjust. * tools/{abicompat,abidiff,abidw,abilint,abipkgdiff,abisym}.cc (options::display_version): New data member. (options::options): Initialize it. (display_usage): Add documentation for new --version option. (parse_command_line): Parse new --version option. (main): Support --version. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-11-16 10:39:15 +00:00
if (opts.display_version)
{
emit_prefix(argv[0], cout)
<< abigail::tools_utils::get_library_version_string();
Add --version option to several libabigail tools This patch changed the revision number of the libabigail library to make it reflect the fact that we are not in "release candidate" mode, before the first 1.0 release. So the revision number is now "rc0". The configuration manager has been updated to support version numbers that are strings, so that it can supports things like "rc0". Then, several libabigail tools have been modified to support the --version option to display their version number. * configure.ac: Set the version revision to "rc0". * doc/manuals/abicompat.rst: Adjust manual for new --version option. * doc/manuals/abidiff.rst: Likewise. * doc/manuals/abidw.rst: Likewise. * doc/manuals/abilint.rst: Likewise. * doc/manuals/abipkgdiff.rst: Likewise. * include/abg-config.h (config::{m_format_minor, m_format_major}): Make these be strings. (config::{get,set}_format_minor_version_number): Make these return strings. (config::{get,set}_format_major_version_number): Make these return or take strings. (abigail_get_library_version): Make this take strings. * src/abg-config.cc (config::config): Adjust. (config::{get,set}_format_major_version_number): Make these return or take strings. (config::{get,set}_format_minor_version_number): Make these return strings. (abigail_get_library_version): Make this take strings. * include/abg-version.h.in: Make the version variables be strings. * src/abg-writer.cc (write_translation_unit): The version numbers are now strings so adjust. * tools/{abicompat,abidiff,abidw,abilint,abipkgdiff,abisym}.cc (options::display_version): New data member. (options::options): Initialize it. (display_usage): Add documentation for new --version option. (parse_command_line): Parse new --version option. (main): Support --version. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-11-16 10:39:15 +00:00
return 0;
}
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>
2016-05-30 08:37:48 +00:00
if (!opts.no_default_suppression && opts.suppression_paths.empty())
{
// Load the default system and user suppressions.
string default_system_suppr_file =
get_default_system_suppression_file_path();
if (file_exists(default_system_suppr_file))
opts.suppression_paths.push_back(default_system_suppr_file);
string default_user_suppr_file =
get_default_user_suppression_file_path();
if (file_exists(default_user_suppr_file))
opts.suppression_paths.push_back(default_user_suppr_file);
}
if (!maybe_check_suppression_files(opts))
return (abigail::tools_utils::ABIDIFF_USAGE_ERROR
| abigail::tools_utils::ABIDIFF_ERROR);
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
if (opts.package1.empty() || opts.package2.empty())
{
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< "Please enter two packages to compare" << "\n";
return (abigail::tools_utils::ABIDIFF_USAGE_ERROR
| abigail::tools_utils::ABIDIFF_ERROR);
}
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
package_sptr first_package(new package(opts.package1, "package1"));
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
Remove the last direct fiddling with ELF from abipkgdiff.cc Directly using elfutils from abipkgdiff.cc feels like a taping into the wrong abstraction layer from this level. So this patch moves the determination of the type of elf file into abg-dwarf-reader.cc and uses it from there. The patch also simplifies the instantiation of types elf_file and package, from abipkgdiff.cc. * abg-dwarf-reader.h (enum elf_type): Move this declaration here from abipkgdiff.cc to here. (get_type_of_elf_file): Declare this new function. (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. So now to use this, the user doesn't have to get her hand dirty with elfutils. * src/abg-dwarf-reader.cc (get_soname_from_elf): Change this to take a path to the elf file rather than a Elf* handler. (elf_file_type): Move this static function here, from abipkgdiff.cc. (get_type_of_elf_file): New function. This has been factorized out of create_maps_of_package_content() in abipkgdiff.cc. * tools/abipkgdiff.cc (class elf_file): Changed struct elf_file into this. Make the default constructor private. (elf_file::elf_file): Change the constructor to just take the path to the elf_file. The base name, soname and elf file type are now computed from the path file, in the constructor. This makes instantiation much much easier from the point of view of the user of the type. (struct abi_diff): Renamed struct abi_changes into this. (abi_diff::has_changes): Define new member function. (abi_diffs): Remove this global variable. (package::package): Remove the elf file type from the set of parameters of this constructor. Rather, compute that elf file type from the path to the elf file, in the constructor. Again, this eases the use of the type. (elf_file_type): Remove this from here, as it got moved to abg-dwarf-reader.cc. (compare): In the elf_file overload, return true if the comparison yields ABI changes. (create_maps_of_package_content): Do not fiddle with elfutils stuff here. Rather, just instantiate elf_file and the analyzing of the file magically happens. (compare): Make the package overload take an abi_diff as output parameter, rather than populating a global variable in return. (compare): Add an other overload for package that doesn't take the abi_diff as output parameter and write it in terms of the previous one. (main): Adjust as the instantiation of package is now simpler. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-15 13:25:26 +00:00
package_sptr second_package(new package(opts.package2, "package2"));
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
for (vector<string>::const_iterator p = opts.debug_packages1.begin();
p != opts.debug_packages1.end();
++p)
first_package->debug_info_packages().push_back
(package_sptr(new package(*p,
"debug_package1",
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>
2016-05-20 07:19:51 +00:00
/*pkg_kind=*/package::KIND_DEBUG_INFO)));
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
for (vector<string>::const_iterator p = opts.debug_packages2.begin();
p != opts.debug_packages2.end();
++p)
second_package->debug_info_packages().push_back
(package_sptr(new package(*p,
"debug_package2",
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>
2016-05-20 07:19:51 +00:00
/*pkg_kind=*/package::KIND_DEBUG_INFO)));
if (!opts.devel_package1.empty())
first_package->devel_package
(package_sptr(new package(opts.devel_package1,
"devel_package1",
/*pkg_kind=*/package::KIND_DEVEL)));
;
if (!opts.devel_package2.empty())
second_package->devel_package
(package_sptr(new package(opts.devel_package2,
"devel_package2",
/*pkg_kind=*/package::KIND_DEVEL)));
Important organizational changes in abipkgdiff.cc This patch introduces many changes that should hopefully improve legibility and ease of maintenance. Here is a list of the topic of the changes: * Avoid using shortened names when the line is not too long. * Use shared_ptr when possible. * When a function parameter is not meant to be nil, do not pass it as a pointer; rather, pass it as a reference. * Avoid doing things that can "fail" in a destructor; e.g, spawning a process. Also, it's not common practise to cleanup a resource in a type destructor, when that resource has not been created in one of the member functions of the type. It eases maintenance when resource creation and cleanup is performed at the same logical level. * tools/abipkgdiff.cc (option::package{1,2}): Rename option::pkg{1,2} into this, to increase legibility. (option::debug_package{1,2}): Likewise, rename option::debug_pkg{1,2} into this. (elf_file::~elf_file): Do not "delete this" in a destructor. This leads to double free. It's when someone invokes the "delete" operator on a pointer to the object that the destructor of the object is executed automatically; so if in the destructor the delete operator is called again, bad things are going to happen. As the destructor is now empty, remove it altogether. (elf_file_sptr): New typedef for shared_ptr<elf_file>. (package::path): Rename package::pkg_path into this, for better legibility. (package::extracted_package_dir_path): Rename package::extracted_pkg_dir_path into this. (package::type): Rename package::pkg_type into this. (package::is_debug_info): Rename package::is_debuginfo_pkg into this. (package::path_elf_file_sptr_map): Rename package::dir_elf_files_map into this because this is a map of path -> elf_file_sptr. Also, now the value of the map element is a elf_file_sptr, no more an elf_file*. (package::debug_info_package): Rename package::debuginfo_pkg into this. (package::package): Adjust for the changes above. (package::{erase_extraction_directory, erase_extraction_directories}): New member functions. (elf_file_paths): Renamed dir_elf_files_path into this. (erase_created_temporary_directories) (create_maps_of_package_content) (extract_package_and_map_its_content, prepare_packages): New static functions. (get_soname, elf_file_type, extract_rpm): Make this static. (extract_package): Take a const package& rather than a package_sptr to express that the function really expects a non-nil object by reference (not by copy) and that the object won't be modified. Using a reference removes the possibility that the pointer could be nil, causing crashes in the code where parameter->something was used. Now only parameter.something can be used, so no crash possible there. This is more solid code. (file_tree_walker_callback_fn): Rename callback() into this. It makes the code more legible and kind of 'self-documented'. At least you get the hint that this is a callback function for some file tree walking (ftw) function. Adjust for the relevant names renaming above. (compare): Rename compute_abidiff into this; again, this increases legibility; at least at the point of use of this function. Rename compare_package() into a an overload of compare() as well. compare_package() used to take a vector of packages. It was hard to guess by reading the signature of the function, which element of the vector is expected to be the first vector of the comparison, which one is to be the second, etc. Now, this function takes two packages, named first_package and second_package. That is more "typed"; that is, the signature is more meaningful. Greater legibility, hopefully. And in the body of the function, the debug information packages are now accessed using the package::debug_info_package data member. Again, this is less surprising, I believe. Also, explicitly erase the temporary files that were created during this comparison. All this simplifies the logic of this function, hopefully. (parse_command_line): Make this static. Add new --d1 and --d2 command line switches that are shortcuts of --debug-info-pkg1 and --debug-info-pkg2. Adjust this function for the relevant name changes above. Make lines be shorter than 80 characters. (main): Do not create any vector of parameters anymore as the compare_packages() function don't take any vector of parameter anymore. Just instantiate first_package and second_package now. Adjust for the relevant name changes above. This hopefully simplifies the logic of this function. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-07 07:44:58 +00:00
if (!opts.kabi_whitelist_packages.empty())
{
first_package->kabi_whitelist_package
(package_sptr(new package
(opts.kabi_whitelist_packages[0],
"kabi_whitelist_package1",
/*pkg_kind=*/package::KIND_KABI_WHITELISTS)));
if (opts.kabi_whitelist_packages.size() >= 2)
second_package->kabi_whitelist_package
(package_sptr(new package
(opts.kabi_whitelist_packages[1],
"kabi_whitelist_package2",
/*pkg_kind=*/package::KIND_KABI_WHITELISTS)));
}
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>
2017-04-03 18:10:06 +00:00
string package_name;
switch (first_package->type())
{
case abigail::tools_utils::FILE_TYPE_RPM:
if (second_package->type() != abigail::tools_utils::FILE_TYPE_RPM)
{
base_name(opts.package2, package_name);
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< package_name << " should be an RPM file\n";
return (abigail::tools_utils::ABIDIFF_USAGE_ERROR
| abigail::tools_utils::ABIDIFF_ERROR);
}
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>
2017-07-10 09:54:13 +00:00
if (file_is_kernel_package(first_package->base_name(),
abigail::tools_utils::FILE_TYPE_RPM)
|| file_is_kernel_package(second_package->base_name(),
abigail::tools_utils::FILE_TYPE_RPM))
{
if (file_is_kernel_package(first_package->base_name(),
abigail::tools_utils::FILE_TYPE_RPM)
!= file_is_kernel_package(second_package->base_name(),
abigail::tools_utils::FILE_TYPE_RPM))
{
emit_prefix("abipkgdiff", cerr)
<< "a Linux kernel package can only be compared to another "
"Linux kernel package\n";
return (abigail::tools_utils::ABIDIFF_USAGE_ERROR
| abigail::tools_utils::ABIDIFF_ERROR);
}
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
if (first_package->debug_info_packages().empty()
|| second_package->debug_info_packages().empty())
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>
2017-07-10 09:54:13 +00:00
{
emit_prefix("abipkgdiff", cerr)
<< "a Linux Kernel package must be accompanied with its "
"debug info package\n";
return (abigail::tools_utils::ABIDIFF_USAGE_ERROR
| abigail::tools_utils::ABIDIFF_ERROR);
}
Add a --leaf-changes-only option to abipkgdiff This patch adds the --leaf-changes-only option to abipkgdiff, just like what we have for abidiff. The patch also emit leaf changes report by default when comparing two Linux Kernel packages. The patch also adds the --impacted-interfaces and --full-impact options. * doc/manuals/abipkgdiff.rst: Add documentation for the new --leaf-change-only, --impacted-interfaces and --full-impact options. * tools/abipkgdiff.cc (options::{leaf_changes_only, show_impacted_interfaces, show_full_impact_report): Add new data members. (options::options): Initialize them. (display_usage): Add help strings for the new --leaf-change-only, --impacted-interfaces and --full-impact|-f options. (set_diff_context_from_opts): Set the diff context for the 'leaf-changes-only' and 'show-impacted-interfaces' flags. (parse_command_line): Parse the --leaf-change-only, --impacted-interfaces and --full-impact options. Handle the case where the --linux-kernel-abi-whitelist|-w option is given a whitelist *package*. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt: New test output reference. * tests/test-diff-pkg.cc (in_out_spec): Compare data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64.rpm and data/test-diff-pkg/spice-server-0.12.8-1.el7.x86_64.rpm with the new --leaf-changes-only and --impacted-interfaces options, using the new output reference above. * tests/data/Makefile.am: Add the new test material to source distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-09-18 14:00:23 +00:00
// We are looking at kernel packages. If the user provided
// the --full-impact option then it means we want to display
// the default libabigail report format where a full impact
// analysis is done for each ABI change.
//
// Otherwise, let's just emit the leaf change report.
if (opts.show_full_impact_report)
opts.leaf_changes_only = false;
else
opts.leaf_changes_only = true;
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>
2017-07-10 09:54:13 +00:00
}
break;
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>
2015-08-07 08:48:17 +00:00
case abigail::tools_utils::FILE_TYPE_DEB:
if (second_package->type() != abigail::tools_utils::FILE_TYPE_DEB)
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>
2015-08-07 08:48:17 +00:00
{
base_name(opts.package2, package_name);
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< package_name << " should be a DEB file\n";
return (abigail::tools_utils::ABIDIFF_USAGE_ERROR
| abigail::tools_utils::ABIDIFF_ERROR);
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>
2015-08-07 08:48:17 +00:00
}
break;
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>
2015-08-22 09:44:08 +00:00
case abigail::tools_utils::FILE_TYPE_DIR:
if (second_package->type() != abigail::tools_utils::FILE_TYPE_DIR)
{
base_name(opts.package2, package_name);
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< package_name << " should be a directory\n";
return (abigail::tools_utils::ABIDIFF_USAGE_ERROR
| abigail::tools_utils::ABIDIFF_ERROR);
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>
2015-08-22 09:44:08 +00:00
}
break;
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>
2015-08-22 11:59:18 +00:00
case abigail::tools_utils::FILE_TYPE_TAR:
if (second_package->type() != abigail::tools_utils::FILE_TYPE_TAR)
{
base_name(opts.package2, package_name);
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< package_name << " should be a GNU tar archive\n";
return (abigail::tools_utils::ABIDIFF_USAGE_ERROR
| abigail::tools_utils::ABIDIFF_ERROR);
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>
2015-08-22 11:59:18 +00:00
}
break;
default:
base_name(opts.package1, package_name);
Emit more informational messages on unrecognized options This is like what was done for abififf, but for abicompat, abidw, abipkgdiff and abilint. * tools/abicompat.cc (options::prog_name): New data member. (display_help, perform_compat_check_in_normal_mode) (perform_compat_check_in_weak_mode, main): Prefix error messages with the name of the program. * tools/abidw.cc (options::wrong_option): New data member. (display_help): Prefix error messages with the name of the program.n (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abilint.cc (optionqs::wrong_option): New data member (display_usage): Prefix error messages with the name of the program. (parse_command_line): Record the name of the unrecognized option. (main): Tell the name of the unrecognized option. Prefix error messages with the name of the program. * tools/abipkgdiff.cc (options::{wrong_option, prog_name}): New data members. (package::erase_extraction_directory, display_usage, extract_rpm) (extract_deb, extract_tar) (erase_created_temporary_directories_parent, extract_package) (compare, create_maps_of_package_content): Prefix error messages with the name of the program. (maybe_check_suppression_files): Adjust. (parse_command_line): Record the name of the unrecognized option, and the name of option which lacks an operand. (main): Give the name of the unrecognized option. Prefix error messages with the name of the program. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-12 11:37:04 +00:00
emit_prefix("abipkgdiff", cerr)
<< package_name << " should be a valid package file \n";
return (abigail::tools_utils::ABIDIFF_USAGE_ERROR
| abigail::tools_utils::ABIDIFF_ERROR);
}
Bug 22436 - make abipkgdiff accept several debuginfo packages Sometimes, the debug information for one given package P can have been split into several packages. In that case, we need abipkgdiff to consider several debug info packages for a given input binary package. This patch makes abipkgdiff to accept several --d{1,2} <debug-info-package> option, for a given input package. * doc/manuals/abipkgdiff.rst: Document the fact that --d{1,2} can be provided several times on the command line. * tools/abipkgdiff.cc (options::debug_packages{1,2}): Rename the debug_package{1,2} data members into this, and make them be vector of strings, rather than just strings. (package::debug_info_packages_): Renamed package::debug_info_package_ into this and make it be a vector of package_sptr, rather than just a package_sptr. (package::debug_info_packages): Renamed the method package::debug_info_package into this and -- for the getter overload -- make it return a vector of package_sptr, rather than just a package_sptr. Likewise for the setter overload. Add a non-const getter overload. (package::erase_extraction_directories) (extract_package_and_map_its_content): Adjust. (extract_rpm, extract_deb): Do not erase the content of the extraction directory (if it was pre-existing) prior to extracting the RPM/deb into it. (pkg_extraction::pkgs): Renamed pkg_extraction::pkg into this and make it be a vector of packages, rather than just a package. (pkg_extraction::pkg_extraction): Adjust to take a package_sptr rather than just a package. Add an overload to take a vector of packages_sptr. (pkg_extraction::perform): Extract the vector of package that the task is not responsible for, not just one random package. (extract_package_and_map_its_content): Adjust. (prepare_packages): Take smart pointers to package rather than just packages. Adjust accordingly. (compare_prepared_package): Make the overload that takes two packages to take two smart pointers of packages. (compare): Make the overload that takes two package take two package_sptr. (parse_command_line): Parse having --d{1,2} several times for a given input package. (main): Take several debug info packages for one input file. * include/abg-tools-utils.h (split_string): Declare ... * src/abg-tools-utils.cc (split_string): ... new function. * tests/data/test-diff-pkg/libxfce4ui-debuginfo-4.12.1-8.fc27.ppc64.rpm: Add a new RPM test input file. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-ok-0.txt: new reference output file. * tests/data/Makefile.am: Add the new test input files above to source distribution. * tests/test-diff-pkg.cc (in_out_spec): Add new test entry to specify two debug info packages for one input package. (test_task::perform): Support having several debug info package paths in the IntOutSpec::{first,second}_in_debug_package_path data member. The debug info packages paths are separated by either a white space or commas. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2017-11-27 14:45:47 +00:00
return compare(first_package, second_package, opts);
}