diff --git a/doc/manuals/abidiff.rst b/doc/manuals/abidiff.rst index 2a2aabfa..708c6cd7 100644 --- a/doc/manuals/abidiff.rst +++ b/doc/manuals/abidiff.rst @@ -107,22 +107,23 @@ Options ELF binary. It thus considers functions and variables which are defined and exported in the ELF sense. - * ``--dont-drop-private-types`` + * ``--drop-private-types`` This option is to be used with the ``--headers-dir1`` and - ``--headers-dir2`` options. Without this option, types that are + ``--headers-dir2`` options. With this option, types that are *NOT* defined in the headers are entirely dropped from the internal representation build by Libabigail to represent the ABI. They thus don't have to be filtered out from the final ABI change report because they are not even present in Libabigail's representation. - With this option however, those private types are kept in the + Without this option however, those private types are kept in the internal representation and later filtered out from the report. - This options thus potentially makes Libabigail to potentially - consume more memory. It's meant to be mainly used for debugging - purposes. + This options thus potentially makes Libabigail consume less + memory. It's meant to be mainly used to optimize the memory + consumption of the tool on binaries with a lot of publicly defined + and exported types. * ``--stat`` diff --git a/doc/manuals/abipkgdiff.rst b/doc/manuals/abipkgdiff.rst index 351865a2..5623967e 100644 --- a/doc/manuals/abipkgdiff.rst +++ b/doc/manuals/abipkgdiff.rst @@ -100,6 +100,24 @@ Options filters out reports about ABI changes to types that are *NOT* defined in these header files. + * ``--drop-private-types`` + + This option is to be used with the ``--devel-pkg1`` and + ``--devel-pkg2`` options. With this option, types that are *NOT* + defined in the headers are entirely dropped from the internal + representation build by Libabigail to represent the ABI. They + thus don't have to be filtered out from the final ABI change + report because they are not even present in Libabigail's + representation. + + Without this option however, those private types are kept in the + internal representation and later filtered out from the report. + + This options thus potentially makes Libabigail consume less + memory. It's meant to be mainly used to optimize the memory + consumption of the tool on binaries with a lot of publicly defined + and exported types. + * ``--dso-only`` Compare ELF files that are shared libraries, only. Do not compare diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc index 0b2457a6..a3e9a459 100644 --- a/src/abg-tools-utils.cc +++ b/src/abg-tools-utils.cc @@ -1,6 +1,6 @@ // -*- Mode: C++ -*- // -// Copyright (C) 2013-2016 Red Hat, Inc. +// Copyright (C) 2013-2017 Red Hat, Inc. // // This file is part of the GNU Application Binary Interface Generic // Analysis and Instrumentation Library (libabigail). This library is @@ -853,11 +853,19 @@ handle_fts_entry(const FTSENT *entry, || string_ends_with(fname, ".hxx")) { if (!suppr) - suppr.reset(new type_suppression(PRIVATE_TYPES_SUPPR_SPEC_NAME, - /*type_name_regexp=*/"", - /*type_name=*/"")); - suppr->set_is_artificial(true); - suppr->set_drops_artifact_from_ir(true); + { + suppr.reset(new type_suppression(PRIVATE_TYPES_SUPPR_SPEC_NAME, + /*type_name_regexp=*/"", + /*type_name=*/"")); + + // Types that are defined in system headers are usually + // OK to be considered as public types. + suppr->set_source_location_to_keep_regex_str("^/usr/include/"); + suppr->set_is_artificial(true); + } + // And types that are defined in header files that are under + // the header directory file we are looking are to be + // considered public types too. suppr->get_source_locations_to_keep().insert(fname); } } diff --git a/tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt b/tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt index abdb69d6..d92d21ee 100644 --- a/tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt +++ b/tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt @@ -1,5 +1,5 @@ ================ changes of 'libtbb.so.2'=============== - Functions changes summary: 0 Removed, 7 Changed (9 filtered out), 17 Added functions + Functions changes summary: 0 Removed, 7 Changed (17 filtered out), 17 Added functions Variables changes summary: 0 Removed, 0 Changed, 0 Added variable Function symbols changes summary: 0 Removed, 0 Added function symbol not referenced by debug info Variable symbols changes summary: 3 Removed, 0 Added variable symbols not referenced by debug info @@ -49,7 +49,7 @@ type size hasn't changed 1 data member insertion: 'tbb::internal::cpu_ctl_env_space tbb::task_group_context::my_cpu_ctl_env', at offset 896 (in bits) at task.h:380:1 - 1 data member changes (1 filtered): + 1 data member changes (2 filtered): type of 'char tbb::task_group_context::_leading_padding[80]' changed: type name changed from 'char[80]' to 'char[72]' array type size changed from 640 to 576 bits: diff --git a/tests/test-diff-suppr.cc b/tests/test-diff-suppr.cc index 09876635..80eabf5c 100644 --- a/tests/test-diff-suppr.cc +++ b/tests/test-diff-suppr.cc @@ -1604,7 +1604,7 @@ InOutSpec in_out_specs[] = "", "", "", - "--no-default-suppression --dont-drop-private-types", + "--no-default-suppression", "data/test-diff-suppr/test30-report-0.txt", "output/test-diff-suppr/test30-report-0.txt" }, @@ -1614,7 +1614,7 @@ InOutSpec in_out_specs[] = "data/test-diff-suppr/test30-include-dir-v0", "data/test-diff-suppr/test30-include-dir-v1", "", - "--no-default-suppression --dont-drop-private-types", + "--no-default-suppression", "data/test-diff-suppr/test30-report-1.txt", "output/test-diff-suppr/test30-report-1.txt" }, @@ -1674,7 +1674,7 @@ InOutSpec in_out_specs[] = "data/test-diff-suppr/test34-pub-include-dir-v0", "data/test-diff-suppr/test34-pub-include-dir-v1", "", - "--no-default-suppression --dont-drop-private-types", + "--no-default-suppression", "data/test-diff-suppr/test34-report-0.txt", "output/test-diff-suppr/test34-report-0.txt" }, diff --git a/tools/abidiff.cc b/tools/abidiff.cc index 2ebe1130..7210226b 100644 --- a/tools/abidiff.cc +++ b/tools/abidiff.cc @@ -109,7 +109,7 @@ struct options : display_usage(), display_version(), missing_operand(), - drop_private_types(true), + drop_private_types(false), linux_kernel_mode(true), no_default_supprs(), no_arch(), @@ -149,7 +149,7 @@ display_usage(const string& prog_name, ostream& out) << " --debug-info-dir2|--d2 the root for the debug info of file2\n" << " --headers-dir1|--hd1 the path to headers of file1\n" << " --headers-dir2|--hd2 the path to headers of file2\n" - << " --dont-drop-private-types\n keep private types in " + << " --drop-private-types\n drop private types from " "internal representation\n" << " --no-linux-kernel-mode don't consider the input binaries as " "linux kernel binaries\n" @@ -307,8 +307,8 @@ parse_command_line(int argc, char* argv[], options& opts) opts.display_usage = true; return true; } - else if (!strcmp(argv[i], "--dont-drop-private-types")) - opts.drop_private_types = false; + else if (!strcmp(argv[i], "--drop-private-types")) + opts.drop_private_types = true; else if (!strcmp(argv[i], "--no-default-suppression")) opts.no_default_supprs = true; else if (!strcmp(argv[i], "--no-architecture")) @@ -664,34 +664,39 @@ set_suppressions(ReadContextType& read_ctxt, const options& opts) ++i) read_suppressions(*i, supprs); - if (opts.drop_private_types) + if (!opts.headers_dir1.empty()) { - if (!opts.headers_dir1.empty()) + // Generate suppression specification to avoid showing ABI + // changes on types that are not defined in public headers. + // + // As these suppression specifications are applied during the + // corpus loading, they are going to be dropped from the + // internal representation altogether. + suppression_sptr suppr = + gen_suppr_spec_from_headers(opts.headers_dir1); + if (suppr) { - // Generate suppression specification to avoid showing ABI - // changes on types that are not defined in public headers. - // - // As these suppression specifications are applied during the - // corpus loading, they are going to be dropped from the - // internal representation altogether. - suppression_sptr suppr = - gen_suppr_spec_from_headers(opts.headers_dir1); - if (suppr) - supprs.push_back(suppr); + if (opts.drop_private_types) + suppr->set_drops_artifact_from_ir(true); + supprs.push_back(suppr); } + } - if (!opts.headers_dir2.empty()) + if (!opts.headers_dir2.empty()) + { + // Generate suppression specification to avoid showing ABI + // changes on types that are not defined in public headers. + // + // As these suppression specifications are applied during the + // corpus loading, they are going to be dropped from the + // internal representation altogether. + suppression_sptr suppr = + gen_suppr_spec_from_headers(opts.headers_dir2); + if (suppr) { - // Generate suppression specification to avoid showing ABI - // changes on types that are not defined in public headers. - // - // As these suppression specifications are applied during the - // corpus loading, they are going to be dropped from the - // internal representation altogether. - suppression_sptr suppr = - gen_suppr_spec_from_headers(opts.headers_dir2); - if (suppr) - supprs.push_back(suppr); + if (opts.drop_private_types) + suppr->set_drops_artifact_from_ir(true); + supprs.push_back(suppr); } } diff --git a/tools/abipkgdiff.cc b/tools/abipkgdiff.cc index 438ef8f1..8d905ee0 100644 --- a/tools/abipkgdiff.cc +++ b/tools/abipkgdiff.cc @@ -171,6 +171,7 @@ public: string debug_package2; string devel_package1; string devel_package2; + bool drop_private_types; bool show_relative_offset_changes; bool no_default_suppression; bool keep_tmp_files; @@ -192,6 +193,7 @@ public: nonexistent_file(), abignore(true), parallel(true), + drop_private_types(false), show_relative_offset_changes(true), no_default_suppression(), keep_tmp_files(), @@ -612,6 +614,8 @@ display_usage(const string& prog_name, ostream& out) << " --debug-info-pkg2|--d2 path of debug-info package of package2\n" << " --devel-pkg1|--devel1 path of devel package of pakage1\n" << " --devel-pkg2|--devel2 path of devel package of pakage1\n" + << " --drop-private-types\n drop private types from " + "internal representation\n" << " --no-default-suppression don't load any default " "suppression specifications\n" << " --suppressions|--suppr specify supression specification path\n" @@ -1375,8 +1379,10 @@ create_maps_of_package_content(package& package, /// @return true iff suppression specifications were generated for /// types private to the package. static bool -maybe_create_private_types_suppressions(package& pkg) +maybe_create_private_types_suppressions(package_descriptor& desc) { + package& pkg = desc.pkg; + if (!pkg.private_types_suppressions().empty()) return false; @@ -1400,7 +1406,11 @@ maybe_create_private_types_suppressions(package& pkg) gen_suppr_spec_from_headers(headers_path); if (suppr) - pkg.private_types_suppressions().push_back(suppr); + { + if (desc.opts.drop_private_types) + suppr->set_drops_artifact_from_ir(true); + pkg.private_types_suppressions().push_back(suppr); + } return suppr; } @@ -1504,7 +1514,7 @@ pthread_routine_extract_pkg_and_map_its_content(package_descriptor *a) if (has_devel_pkg && opts.parallel) result &= pthread_join(thr_devel); - maybe_create_private_types_suppressions(package); + maybe_create_private_types_suppressions(*a); // Let's wait for debug package extractions to finish before // we exit. @@ -1925,6 +1935,8 @@ parse_command_line(int argc, char* argv[], options& opts) abigail::tools_utils::make_path_absolute(argv[j]).get(); ++i; } + else if (!strcmp(argv[i], "--drop-private-types")) + opts.drop_private_types = true; else if (!strcmp(argv[i], "--no-default-suppression")) opts.no_default_suppression = true; else if (!strcmp(argv[i], "--keep-tmp-files"))