From 25dc383b406565f5ba4068bc336e1455ff070215 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Wed, 1 Jul 2015 11:03:16 +0200 Subject: [PATCH] Show aliases of functions with changed sub-types The report emitted by abidiff now tells the user about the aliases of the current function, when that function has some sub-type changes. * include/abg-ir.h (elf_symbol::get_aliases_id_string): Declare new overload. * src/abg-ir.cc (elf_symbol::get_aliases_id_string): Define new overload. * src/abg-comparison.cc (corpus_diff::report): For functions with sub-type changes report their aliases. Do not do this if the function is a constructor or destructor because these almost always have aliases, at least with GCC and the developer most certainly has not done anything special for that; she would thus be uselessly surprised by that remote implementation detail. * tests/data/test-diff-dwarf/test5-report.txt: Adjust test. Signed-off-by: Dodji Seketeli --- include/abg-ir.h | 3 ++ src/abg-comparison.cc | 16 ++++++++++- src/abg-ir.cc | 32 +++++++++++++++++++++ tests/data/test-diff-dwarf/test5-report.txt | 2 ++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/include/abg-ir.h b/include/abg-ir.h index 6f3d558b..3bf304f9 100644 --- a/include/abg-ir.h +++ b/include/abg-ir.h @@ -455,6 +455,9 @@ public: get_aliases_id_string(const string_elf_symbols_map_type& symtab, bool include_symbol_itself = true) const; + string + get_aliases_id_string(bool include_symbol_itself = true) const; + static bool get_name_and_version_from_id(const string& id, string& name, diff --git a/src/abg-comparison.cc b/src/abg-comparison.cc index 490e1dd0..6606e380 100644 --- a/src/abg-comparison.cc +++ b/src/abg-comparison.cc @@ -13748,9 +13748,23 @@ corpus_diff::report(ostream& out, const string& indent) const if (diff->to_be_reported()) { + function_decl_sptr fn = (*i)->first_function_decl(); out << indent << " [C]'" - << (*i)->first_function_decl()->get_pretty_representation() + << fn->get_pretty_representation() << "' has some indirect sub-type changes:\n"; + if (fn->get_symbol()->has_aliases() + && !(is_member_function(fn) + && get_member_function_is_ctor(fn)) + && !(is_member_function(fn) + && get_member_function_is_dtor(fn))) + { + out << indent << " " + << "Please note that the symbol of this function is " + << fn->get_symbol()->get_id_string() + << "\n and it aliases: " + << fn->get_symbol()->get_aliases_id_string(false) + << "\n"; + } diff->report(out, indent + " "); out << "\n"; emitted |= true; diff --git a/src/abg-ir.cc b/src/abg-ir.cc index b974e9c8..49048c2c 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -812,6 +812,38 @@ elf_symbol::get_aliases_id_string(const string_elf_symbols_map_type& syms, return result; } +/// Return a comma separated list of the id of the current symbol as +/// well as the id string of its aliases. +/// +/// @param include_symbol_itself if set to true, then the name of the +/// current symbol is included in the list of alias names that is emitted. +/// +/// @return the string. +string +elf_symbol::get_aliases_id_string(bool include_symbol_itself) const +{ + vector aliases; + if (include_symbol_itself) + aliases.push_back(get_main_symbol()); + + for (elf_symbol_sptr a = get_next_alias(); + a && a.get() != get_main_symbol().get(); + a = a->get_next_alias()) + aliases.push_back(a); + + string result; + for (vector::const_iterator i = aliases.begin(); + i != aliases.end(); + ++i) + { + if (i != aliases.begin()) + result += ", "; + result += (*i)->get_id_string(); + } + + return result; +} + /// Given the ID of a symbol, get the name and the version of said /// symbol. /// diff --git a/tests/data/test-diff-dwarf/test5-report.txt b/tests/data/test-diff-dwarf/test5-report.txt index 04ec3405..508a5594 100644 --- a/tests/data/test-diff-dwarf/test5-report.txt +++ b/tests/data/test-diff-dwarf/test5-report.txt @@ -4,6 +4,8 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable 1 function with some indirect sub-type change: [C]'function C0 foo()' has some indirect sub-type changes: + Please note that the symbol of this function is _ZN2C0C2Ev + and it aliases: _ZN2C0C1Ev, _Z3foov return type changed: entity changed from 'class C0' to compatible type 'typedef c0_type' 1 data member change: