Introduce recursive dumping/diffing of types.

1) Types are now quantifed into one of the following:
	a) RecordType - structures/ unions/ classes.
	b) EnumType - enumerated types.
	c) QualifiedType - types with qualifiers intact.
	d) PointerType - pointer to a type.
	e) LvalueReferenceType
	f) RvalueReferenceType
	g) ArrayType

2) ABI diffing now diffs based on types directly / indirectly reachable
by function signatures / global variable types by default. Also added an option
to header-abi-diff:

-check-all-apis : Include changes to all APIs exported via exported
headers whether directly / indirectly used by function signatures /
global variable types or not.

3) Introduced an internal representation of abi information. This
enables us to switch formats of abi-dumps / abi-diffs more easily
without changing the AST parsing code. For example: In the future, if we
wanted to add options to view the abi-dumps in html / xml we could just
add classes which extended IRDumper and implement dumping methods.

4) The linked ABI dump of a shared library also includes a list of the
exported functions and objects collected from the .dynsym table. This makes it
possible to avoid false reports of ABI breakages when functions/ global
variables are moved to assembly files.

Test: abi-dumping and linking: make -j64 from ToT
      abi_diffing: change parameter types directly, indirectly.
      Ran tests/test.py with soong running the built tool, all tests passed.

Bug: 62060883

Bug: 63865902

Change-Id: Id9ef757165a1669049fde20bda4147d5074cc191
This commit is contained in:
Jayant Chowdhary
2017-07-05 17:56:33 -07:00
parent c57aaaf57c
commit 83fc92bb30
21 changed files with 5077 additions and 1167 deletions

View File

@@ -14,6 +14,8 @@
#include "abi_diff.h"
#include <fstream>
#include <llvm/Support/CommandLine.h>
#include <llvm/Support/FileSystem.h>
#include <llvm/Support/raw_ostream.h>
@@ -49,6 +51,12 @@ static llvm::cl::opt<bool> advice_only(
"advice-only", llvm::cl::desc("Advisory mode only"), llvm::cl::Optional,
llvm::cl::cat(header_checker_category));
static llvm::cl::opt<bool> check_all_apis(
"check-all-apis",
llvm::cl::desc("All apis, whether referenced or not, by exported symbols in"
" the dynsym table of a shared library are checked"),
llvm::cl::Optional, llvm::cl::cat(header_checker_category));
static llvm::cl::opt<bool> suppress_local_warnings(
"suppress_local_warnings", llvm::cl::desc("suppress local warnings"),
llvm::cl::Optional, llvm::cl::cat(header_checker_category));
@@ -58,6 +66,13 @@ static llvm::cl::opt<bool> allow_extensions(
llvm::cl::desc("Do not return a non zero status on extensions"),
llvm::cl::Optional, llvm::cl::cat(header_checker_category));
static llvm::cl::opt<bool> allow_unreferenced_changes(
"allow-unreferenced-changes",
llvm::cl::desc("Do not return a non zero status on changes to data"
" structures which are not directly referenced by exported"
" APIs."),
llvm::cl::Optional, llvm::cl::cat(header_checker_category));
static std::set<std::string> LoadIgnoredSymbols(std::string &symbol_list_path) {
std::ifstream symbol_ifstream(symbol_list_path);
std::set<std::string> ignored_symbols;
@@ -80,38 +95,50 @@ int main(int argc, const char **argv) {
ignored_symbols = LoadIgnoredSymbols(ignore_symbol_list);
}
HeaderAbiDiff judge(lib_name, arch, old_dump, new_dump, compatibility_report,
ignored_symbols);
ignored_symbols, check_all_apis);
CompatibilityStatus status = judge.GenerateCompatibilityReport();
abi_util::CompatibilityStatusIR status = judge.GenerateCompatibilityReport();
std::string status_str = "";
switch (status) {
case CompatibilityStatus::INCOMPATIBLE:
status_str = "broken";
break;
case CompatibilityStatus::EXTENSION:
status_str = "extended";
break;
default:
break;
}
std::string unreferenced_change_str = "";
std::string error_or_warning_str = "\033[36;1mwarning: \033[0m";
if (status == abi_util::CompatibilityStatusIR::Incompatible) {
error_or_warning_str = "\033[31;1merror: \033[0m";
status_str = " INCOMPATIBLE CHANGES";
} else if (status & abi_util::CompatibilityStatusIR::Extension) {
status_str = "EXTENDING CHANGES";
}
if (status & abi_util::CompatibilityStatusIR::UnreferencedChanges) {
unreferenced_change_str = ", changes in exported headers, which are";
unreferenced_change_str += " not directly referenced by exported symbols.";
unreferenced_change_str += " This MIGHT be an ABI breaking change due to";
unreferenced_change_str += " internal typecasts.";
}
if (!suppress_local_warnings && status) {
llvm::errs() << "******************************************************\n"
<< "VNDK Abi "
<< error_or_warning_str
<< "VNDK library: "
<< lib_name
<< "'s ABI has "
<< status_str
<< ":"
<< unreferenced_change_str
<< " Please check compatiblity report at : "
<< compatibility_report << "\n"
<< "*****************************************************\n";
<< "******************************************************\n";
}
if ((allow_extensions &&
(status & abi_util::CompatibilityStatusIR::Extension)) ||
(allow_unreferenced_changes &&
(status & abi_util::CompatibilityStatusIR::UnreferencedChanges))) {
return abi_util::CompatibilityStatusIR::Compatible;
}
if (advice_only) {
return CompatibilityStatus::COMPATIBLE;
return abi_util::CompatibilityStatusIR::Compatible;
}
if (allow_extensions && status == CompatibilityStatus::EXTENSION) {
return CompatibilityStatus::COMPATIBLE;
}
return status;
}