Exclude processing symlink, display removed/added binaries between two packages

Removed binaries can also lead to ABI breakage if an applicating was using
it previously. So, display it in ABI change report. Also, looking for
ABI change in symbolic link files doesn't make sense. Now, we are not
looking into ABI changes in symlink binaries.

	* tools/abipkgdiff.cc (abi_changes): Declare new struct
	(callback): Exclude symbloic link file for durther processing
	(compute_abidiff): Consider SONAME if exists as key in map instead
	of binary name, else binary as key. Also, print if removed/added
	binaries exist between packages
This commit is contained in:
Sinny Kumari 2015-06-19 16:57:05 +05:30 committed by Dodji Seketeli
parent 4d9bd0a155
commit 29b3c26a8d

View File

@ -38,6 +38,7 @@
#include <assert.h>
#include <limits.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <elf.h>
#include <elfutils/libdw.h>
#include "abg-tools-utils.h"
@ -95,6 +96,13 @@ struct elf_file
}
};
struct abi_changes
{
vector <string> added_binaries;
vector <string> removed_binaries;
vector <string> abi_changes;
}abi_diffs;
struct package
{
string pkg_path;
@ -233,8 +241,14 @@ extract_pkg(package_sptr pkg)
static int
callback(const char *fpath, const struct stat *st, int flag)
{
if (guess_file_type(fpath) == abigail::tools_utils::FILE_TYPE_ELF)
dir_elf_files_path.push_back(fpath);
struct stat s;
lstat(fpath, &s);
if (!S_ISLNK(s.st_mode))
{
if (guess_file_type(fpath) == abigail::tools_utils::FILE_TYPE_ELF)
dir_elf_files_path.push_back(fpath);
}
return 0;
}
@ -242,7 +256,7 @@ void
compute_abidiff (const elf_file* elf1, const string debug_dir1,
const elf_file* elf2, const string &debug_dir2)
{
cout << "~ ABI changes between libraries " << elf1->name << " and " << elf2->name;
cout << "ABI change between binaries " << elf1->name << " and " << elf2->name;
cout << " =======>\n";
string cmd = "abidiff " +
elf1->path + " " + elf2->path;
@ -280,11 +294,15 @@ pkg_diff(vector<package_sptr> &packages)
string soname;
elf_type e = elf_file_type(ehdr);
if (e == ELF_TYPE_DSO)
string soname = get_soname(elf, ehdr);
soname = get_soname(elf, ehdr);
string file_base_name(basename(const_cast<char*>((*iter).c_str())));
(*it)->dir_elf_files_map[file_base_name] =
new elf_file((*iter), file_base_name, e, soname);
if (soname.empty())
(*it)->dir_elf_files_map[file_base_name] =
new elf_file((*iter), file_base_name, e, soname);
else
(*it)->dir_elf_files_map[soname] =
new elf_file((*iter), file_base_name, e, soname);
}
}
else
@ -307,12 +325,45 @@ pkg_diff(vector<package_sptr> &packages)
it != packages[0]->dir_elf_files_map.end();
++it)
{
map<string, elf_file*>::iterator iter =
packages[1]->dir_elf_files_map.find(it->first);
if (iter != packages[1]->dir_elf_files_map.end())
compute_abidiff(it->second, debug_dir1, iter->second, debug_dir2);
{
compute_abidiff(it->second, debug_dir1, iter->second, debug_dir2);
packages[1]->dir_elf_files_map.erase(iter);
}
else
abi_diffs.removed_binaries.push_back(it->second->name);
}
for (map<string, elf_file*>::iterator it = packages[1]->dir_elf_files_map.begin();
it != packages[1]->dir_elf_files_map.end();
++it)
{
abi_diffs.added_binaries.push_back(it->second->name);
}
if (abi_diffs.removed_binaries.size())
{
cout << "Removed binaries\n";
for (vector<string>::iterator it = abi_diffs.removed_binaries.begin();
it != abi_diffs.removed_binaries.end(); ++it)
{
cout << *it << std::endl;
}
}
if (abi_diffs.added_binaries.size())
{
cout << "Added binaries\n";
for (vector<string>::iterator it = abi_diffs.added_binaries.begin();
it != abi_diffs.added_binaries.end(); ++it)
{
cout << *it << std::endl;
}
}
return true;
}