Commit 0c312c2d by Benjamin Kosnik Committed by Benjamin Kosnik

testsuite_abi.h: Remove symbol_objects, symbol_names typedefs.


2008-03-26  Benjamin Kosnik  <bkoz@redhat.com>

	* testsuite/util/testsuite_abi.h: Remove symbol_objects,
	symbol_names typedefs.	
	* testsuite/util/testsuite_abi.cc (compare_symbols): Correct check
	for long double compatiblity symbols, simplify data structures used.

From-SVN: r133621
parent b8ab1f4a
2008-03-26 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/util/testsuite_abi.h: Remove symbol_objects,
symbol_names typedefs.
* testsuite/util/testsuite_abi.cc (compare_symbols): Correct check
for long double compatiblity symbols, simplify data structures used.
2008-03-25 Benjamin Kosnik <bkoz@redhat.com> 2008-03-25 Benjamin Kosnik <bkoz@redhat.com>
* scripts/run_doxygen: Remove html_output_dir. Downgrade to * scripts/run_doxygen: Remove html_output_dir. Downgrade to
......
...@@ -218,6 +218,15 @@ check_version(symbol& test, bool added) ...@@ -218,6 +218,15 @@ check_version(symbol& test, bool added)
if (added && test.version_name == known_versions[0]) if (added && test.version_name == known_versions[0])
test.version_status = symbol::incompatible; test.version_status = symbol::incompatible;
// Check that long double compatibility symbols demangled as
// __float128 are put into some _LDBL_ version name.
if (added && test.demangled_name.find("__float128") != std::string::npos)
{
// Has to be in _LDBL_ version name.
if (test.version_name.find("_LDBL_") == std::string::npos)
test.version_status = symbol::incompatible;
}
// Check for weak label. // Check for weak label.
if (it1 == end && it2 == end) if (it1 == end && it2 == end)
test.version_status = symbol::incompatible; test.version_status = symbol::incompatible;
...@@ -294,28 +303,22 @@ check_compatible(symbol& lhs, symbol& rhs, bool verbose) ...@@ -294,28 +303,22 @@ check_compatible(symbol& lhs, symbol& rhs, bool verbose)
} }
bool inline bool
has_symbol(const string& mangled, const symbols& s) throw() has_symbol(const string& name, const symbols& s) throw()
{ { return s.find(name) != s.end(); }
const symbol_names& names = s.first;
symbol_names::const_iterator i = find(names.begin(), names.end(), mangled);
return i != names.end();
}
symbol& const symbol&
get_symbol(const string& mangled, const symbols& s) get_symbol(const string& name, const symbols& s)
{ {
const symbol_names& names = s.first; symbols::const_iterator i = s.find(name);
symbol_names::const_iterator i = find(names.begin(), names.end(), mangled); if (i != s.end())
if (i != names.end())
{ {
symbol_objects objects = s.second; return i->second;
return objects[mangled];
} }
else else
{ {
ostringstream os; ostringstream os;
os << "get_symbol failed for symbol " << mangled; os << "get_symbol failed for symbol " << name;
__throw_logic_error(os.str().c_str()); __throw_logic_error(os.str().c_str());
} }
} }
...@@ -326,7 +329,7 @@ examine_symbol(const char* name, const char* file) ...@@ -326,7 +329,7 @@ examine_symbol(const char* name, const char* file)
try try
{ {
symbols s = create_symbols(file); symbols s = create_symbols(file);
symbol& sym = get_symbol(name, s); const symbol& sym = get_symbol(name, s);
sym.print(); sym.print();
} }
catch(...) catch(...)
...@@ -340,15 +343,9 @@ compare_symbols(const char* baseline_file, const char* test_file, ...@@ -340,15 +343,9 @@ compare_symbols(const char* baseline_file, const char* test_file,
// Input both lists of symbols into container. // Input both lists of symbols into container.
symbols baseline = create_symbols(baseline_file); symbols baseline = create_symbols(baseline_file);
symbols test = create_symbols(test_file); symbols test = create_symbols(test_file);
symbol_names& baseline_names = baseline.first;
symbol_objects& baseline_objects = baseline.second;
symbol_names& test_names = test.first;
symbol_objects& test_objects = test.second;
// Sanity check results. // Sanity check results.
const symbol_names::size_type baseline_size = baseline_names.size(); if (!baseline.size() || !test.size())
const symbol_names::size_type test_size = test_names.size();
if (!baseline_size || !test_size)
{ {
cerr << "Problems parsing the list of exported symbols." << endl; cerr << "Problems parsing the list of exported symbols." << endl;
exit(2); exit(2);
...@@ -356,81 +353,85 @@ compare_symbols(const char* baseline_file, const char* test_file, ...@@ -356,81 +353,85 @@ compare_symbols(const char* baseline_file, const char* test_file,
// Check to see if any long double compatibility symbols are produced. // Check to see if any long double compatibility symbols are produced.
bool ld_version_found(false); bool ld_version_found(false);
symbol_objects::iterator li(test_objects.begin()); symbols::iterator li(test.begin());
while (!ld_version_found && li != test_objects.end()) while (!ld_version_found && li != test.end())
{ {
if (li->second.version_name.find("GLIBCXX_LDBL_") != std::string::npos) if (li->second.version_name.find("_LDBL_") != std::string::npos)
ld_version_found = true; ld_version_found = true;
++li; ++li;
} }
// Sort out names. // Sort out names.
// Assuming baseline_names, test_names are both unique w/ no duplicates. // Assuming all baseline names and test names are both unique w/ no
// duplicates.
// //
// The names added to missing_names are baseline_names not found in // The names added to missing_names are baseline names not found in
// test_names // test names
// -> symbols that have been deleted. // -> symbols that have been deleted.
// //
// The names added to added_names are test_names not in // The names added to added_names are test names not in
// baseline_names // baseline names
// -> symbols that have been added. // -> symbols that have been added.
typedef std::vector<std::string> symbol_names;
symbol_names shared_names; symbol_names shared_names;
symbol_names missing_names; symbol_names missing_names;
symbol_names added_names = test_names; symbol_names added_names;
for (size_t i = 0; i < baseline_size; ++i) for (li = test.begin(); li != test.end(); ++li)
added_names.push_back(li->first);
for (symbols::iterator i = baseline.begin(); i != baseline.end(); ++i)
{ {
string what(baseline_names[i]); string name(i->first);
symbol_names::iterator end = added_names.end(); symbol_names::iterator end = added_names.end();
symbol_names::iterator it = find(added_names.begin(), end, what); symbol_names::iterator it = find(added_names.begin(), end, name);
if (it != end) if (it != end)
{ {
// Found. // Found.
shared_names.push_back(what); shared_names.push_back(name);
added_names.erase(it); added_names.erase(it);
} }
else else
missing_names.push_back(what); {
// Iff no test long double compatibility symbols at all and the symbol
// missing is a baseline long double compatibility symbol, skip.
string version_name(i->second.version_name);
bool base_ld(version_name.find("_LDBL_") != std::string::npos);
if (!base_ld || base_ld && ld_version_found)
missing_names.push_back(name);
}
} }
// Check missing names for compatibility. // Fill out list of incompatible symbols.
typedef pair<symbol, symbol> symbol_pair; typedef pair<symbol, symbol> symbol_pair;
vector<symbol_pair> incompatible; vector<symbol_pair> incompatible;
const symbol_names::size_type missing_size = missing_names.size();
for (size_t j = 0; j < missing_size; ++j) // Check missing names for compatibility.
for (size_t j = 0; j < missing_names.size(); ++j)
{ {
symbol& base = baseline_objects[missing_names[j]]; symbol& sbase = baseline[missing_names[j]];
sbase.status = symbol::subtracted;
// Iff no test long double symbols at all and the symbol missing incompatible.push_back(symbol_pair(sbase, sbase));
// is a baseline long double symbol, skip.
if (!ld_version_found
&& base.version_name.find("GLIBCXX_LDBL_") != std::string::npos)
continue;
else
{
base.status = symbol::subtracted;
incompatible.push_back(symbol_pair(base, base));
}
} }
// Check shared names for compatibility. // Check shared names for compatibility.
const symbol_names::size_type shared_size = shared_names.size(); const symbol_names::size_type shared_size = shared_names.size();
for (size_t k = 0; k < shared_size; ++k) for (size_t k = 0; k < shared_size; ++k)
{ {
symbol& base = baseline_objects[shared_names[k]]; symbol& sbase = baseline[shared_names[k]];
symbol& test = test_objects[shared_names[k]]; symbol& stest = test[shared_names[k]];
test.status = symbol::existing; stest.status = symbol::existing;
if (!check_compatible(base, test)) if (!check_compatible(sbase, stest))
incompatible.push_back(symbol_pair(base, test)); incompatible.push_back(symbol_pair(sbase, stest));
} }
// Check added names for compatibility. // Check added names for compatibility.
const symbol_names::size_type added_size = added_names.size(); const symbol_names::size_type added_size = added_names.size();
for (size_t l = 0; l < added_size; ++l) for (size_t l = 0; l < added_size; ++l)
{ {
symbol& test = test_objects[added_names[l]]; symbol& stest = test[added_names[l]];
test.status = symbol::added; stest.status = symbol::added;
if (!check_version(test, true)) if (!check_version(stest, true))
incompatible.push_back(symbol_pair(test, test)); incompatible.push_back(symbol_pair(stest, stest));
} }
// Report results. // Report results.
...@@ -440,7 +441,7 @@ compare_symbols(const char* baseline_file, const char* test_file, ...@@ -440,7 +441,7 @@ compare_symbols(const char* baseline_file, const char* test_file,
for (size_t j = 0; j < added_names.size() ; ++j) for (size_t j = 0; j < added_names.size() ; ++j)
{ {
cout << j << endl; cout << j << endl;
test_objects[added_names[j]].print(); test[added_names[j]].print();
} }
} }
...@@ -450,7 +451,7 @@ compare_symbols(const char* baseline_file, const char* test_file, ...@@ -450,7 +451,7 @@ compare_symbols(const char* baseline_file, const char* test_file,
for (size_t j = 0; j < missing_names.size() ; ++j) for (size_t j = 0; j < missing_names.size() ; ++j)
{ {
cout << j << endl; cout << j << endl;
baseline_objects[missing_names[j]].print(); baseline[missing_names[j]].print();
} }
} }
...@@ -463,12 +464,12 @@ compare_symbols(const char* baseline_file, const char* test_file, ...@@ -463,12 +464,12 @@ compare_symbols(const char* baseline_file, const char* test_file,
cout << j << endl; cout << j << endl;
// Second, report name. // Second, report name.
symbol& base = incompatible[j].first; symbol& sbase = incompatible[j].first;
symbol& test = incompatible[j].second; symbol& stest = incompatible[j].second;
test.print(); stest.print();
// Second, report reason or reasons incompatible. // Second, report reason or reasons incompatible.
check_compatible(base, test, true); check_compatible(sbase, stest, true);
} }
} }
...@@ -491,18 +492,16 @@ create_symbols(const char* file) ...@@ -491,18 +492,16 @@ create_symbols(const char* file)
ifstream ifs(file); ifstream ifs(file);
if (ifs.is_open()) if (ifs.is_open())
{ {
// Organize file data into container of symbol objects, and a // Organize file data into an associated container (symbols) of symbol
// container of mangled names without versioning information. // objects mapped to mangled names without versioning
symbol_names& names = s.first; // information.
symbol_objects& objects = s.second;
const string empty; const string empty;
string line = empty; string line = empty;
while (getline(ifs, line).good()) while (getline(ifs, line).good())
{ {
symbol tmp; symbol tmp;
tmp.init(line); tmp.init(line);
objects[tmp.name] = tmp; s[tmp.name] = tmp;
names.push_back(tmp.name);
line = empty; line = empty;
} }
} }
......
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. // Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // modify it under the terms of the GNU General Public License as
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#include <deque> #include <vector>
#include <locale> #include <locale>
#include <tr1/unordered_map> #include <tr1/unordered_map>
#include <cxxabi.h> #include <cxxabi.h>
...@@ -75,11 +75,8 @@ struct symbol ...@@ -75,11 +75,8 @@ struct symbol
init(std::string& data); init(std::string& data);
}; };
typedef std::tr1::unordered_map<std::string, symbol> symbol_objects; // Map type between symbol names and full symbol info.
typedef std::tr1::unordered_map<std::string, symbol> symbols;
typedef std::deque<std::string> symbol_names;
typedef std::pair<symbol_names, symbol_objects> symbols;
// Check. // Check.
...@@ -94,7 +91,7 @@ check_compatible(symbol& lhs, symbol& rhs, bool verbose = false); ...@@ -94,7 +91,7 @@ check_compatible(symbol& lhs, symbol& rhs, bool verbose = false);
bool bool
has_symbol(const std::string& mangled, const symbols& list) throw(); has_symbol(const std::string& mangled, const symbols& list) throw();
symbol& const symbol&
get_symbol(const std::string& mangled, const symbols& list); get_symbol(const std::string& mangled, const symbols& list);
extern "C" void extern "C" void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment