Hi

I'd like to show you where I stand on the abi check of the versioned namespace mode.

My approach is to indexed symbols based on their 'cleaned-up' de-mangled name instead of the raw symbol name. 'cleaned-up' means for current symbols that the '__8::' is removed and for baseline symbols '__cxx11::' is removed.

Thanks to that a some other changes in patch the 'make RUNTESTFLAGS="abi.exp" check' is improving from:

# of added symbols:              4185
# of missing symbols:            5630
# of undesignated symbols:       0
# of incompatible symbols:       9815

to:

# of added symbols:              406
# of missing symbols:            729
# of undesignated symbols:       2
# of incompatible symbols:       839

No change on the results of the check on non-versioned namespace build as expected, just a small performance improvement.

Any thoughts ?

François

diff --git a/libstdc++-v3/testsuite/util/testsuite_abi.cc 
b/libstdc++-v3/testsuite/util/testsuite_abi.cc
index 90cda2fbca8..3bcfc590788 100644
--- a/libstdc++-v3/testsuite/util/testsuite_abi.cc
+++ b/libstdc++-v3/testsuite/util/testsuite_abi.cc
@@ -26,11 +26,12 @@
 #include <iostream>
 #include <vector>
 #include <algorithm>
+#include <cxxabi.h>
 
 using namespace std;
 
 void
-symbol::init(string& data)
+symbol::init(string& data, bool versioned_ns)
 {
   const char delim = ':';
   const char version_delim = '@';
@@ -38,14 +39,24 @@ symbol::init(string& data)
   string::size_type n = 0;
 
   // Set the type.
-  if (data.find("FUNC") == 0)
-    type = symbol::function;
-  else if (data.find("OBJECT") == 0)
-    type = symbol::object;
-  else if (data.find("TLS") == 0)
-    type = symbol::tls;
-
-  n = data.find_first_of(delim);
+  if (data.compare(n, 4, "FUNC") == 0)
+    {
+      type = symbol::function;
+      n = 4;
+    }
+  else if (data.compare(n, 6, "OBJECT") == 0)
+    {
+      type = symbol::object;
+      n = 6;
+    }
+  else if (data.compare(n, 3, "TLS") == 0)
+    {
+      type = symbol::tls;
+      n = 3;
+    }
+  else
+    n = data.find_first_of(delim);
+
   if (n != npos)
     data.erase(data.begin(), data.begin() + n + 1);
 
@@ -66,7 +77,7 @@ symbol::init(string& data)
     }
 
   // Set the name and raw_name.
-  raw_name = string(data.begin(), data.end());
+  raw_name = data;
   n = data.find_first_of(version_delim);
   if (n != npos)
     {
@@ -81,12 +92,39 @@ symbol::init(string& data)
   else
     {
       // No versioning info.
-      name = string(data.begin(), data.end());
+      name = data;
       version_status = symbol::none;
     }
 
   // Set the demangled name.
-  demangled_name = demangle(name);
+  raw_demangled_name = demangle(name);
+  demangled_name = raw_demangled_name;
+  if (versioned_ns)
+  {
+    size_t pos = 0;
+    for (;;)
+      {
+       pos = demangled_name.find("__8::", pos);
+       if (pos == std::string::npos)
+         break;
+
+       demangled_name.replace(pos, 5, "");
+      }
+  }
+#if !_GLIBCXX_USE_DUAL_ABI
+  else
+  {
+    size_t pos = 0;
+    for (;;)
+      {
+       pos = demangled_name.find("__cxx11::", pos);
+       if (pos == std::string::npos)
+         break;
+
+       demangled_name.replace(pos, 9, "");
+      }
+  }
+#endif
 }
 
 void
@@ -95,8 +133,8 @@ symbol::print() const
   const char tab = '\t';
   cout << name << endl;
 
-  if (demangled_name != name)
-    cout << demangled_name << endl;
+  if (raw_demangled_name != name)
+    cout << raw_demangled_name << endl;
 
   string vers;
   switch (version_status)
@@ -167,7 +205,7 @@ symbol::print() const
 
 
 bool
-check_version(symbol& test, bool added)
+check_version(symbol& test, bool added, bool versioned_ns)
 {
   // Construct list of compatible versions.
   typedef std::vector<std::string> compat_list;
@@ -244,8 +282,29 @@ check_version(symbol& test, bool added)
       known_versions.push_back("CXXABI_TM_1");
       known_versions.push_back("CXXABI_FLOAT128");
     }
-  compat_list::iterator begin = known_versions.begin();
-  compat_list::iterator end = known_versions.end();
+
+  compat_list::iterator begin, end;
+#if _GLIBCXX_INLINE_VERSION
+  static compat_list known_versioned_ns_versions;
+  if (known_versioned_ns_versions.empty())
+    {
+      known_versioned_ns_versions.push_back("GLIBCXX_8.0");
+      known_versioned_ns_versions.push_back("CXXABI_2.0");
+      known_versioned_ns_versions.push_back("CXXABI_TM_1");
+    }
+
+  if (versioned_ns)
+    {
+      begin = known_versioned_ns_versions.begin();
+      end = known_versioned_ns_versions.end();
+    }
+  else
+#endif
+    {
+      begin = known_versions.begin();
+      end = known_versions.end();
+    }
+
 
   // Check for compatible version.
   if (test.version_name.size())
@@ -258,10 +317,23 @@ check_version(symbol& test, bool added)
        test.version_status = symbol::incompatible;
 
       // Check that added symbols are added in the latest pre-release version.
-      bool latestp = (test.version_name == "GLIBCXX_3.4.35"
-                    || test.version_name == "CXXABI_1.3.17"
-                    || test.version_name == "CXXABI_FLOAT128"
-                    || test.version_name == "CXXABI_TM_1");
+      bool latestp;
+      if (!versioned_ns)
+       {
+         latestp =
+           test.version_name == "GLIBCXX_3.4.35"
+           || test.version_name == "CXXABI_1.3.17"
+           || test.version_name == "CXXABI_FLOAT128";
+       }
+      else
+       {
+         latestp =
+           test.version_name == "GLIBCXX_8.0"
+           || test.version_name == "CXXABI_2.0";
+       }
+
+      latestp |= test.version_name == "CXXABI_TM_1";
+
       if (added && !latestp)
        test.version_status = symbol::incompatible;
 
@@ -312,46 +384,49 @@ check_version(symbol& test, bool added)
 }
 
 bool
-check_compatible(symbol& lhs, symbol& rhs, bool verbose)
+check_compatible(symbol& sbase, symbol& stest, bool verbose)
 {
+  const bool versioned_ns = bool(_GLIBCXX_INLINE_VERSION);
   bool ret = true;
   const char tab = '\t';
 
   // Check to see if symbol_objects are compatible.
-  if (lhs.type != rhs.type)
+  if (sbase.type != stest.type)
     {
       ret = false;
       if (verbose)
        cout << tab << "incompatible types" << endl;
     }
 
-  if (lhs.name != rhs.name)
+  const string& sbase_name = versioned_ns ? sbase.demangled_name : sbase.name;
+  const string& stest_name = versioned_ns ? stest.demangled_name : stest.name;
+  if (sbase_name != stest_name)
     {
       ret = false;
       if (verbose)
        cout << tab << "incompatible names" << endl;
     }
 
-  if (lhs.size != rhs.size)
+  if (sbase.size != stest.size)
     {
       ret = false;
       if (verbose)
        {
          cout << tab << "incompatible sizes" << endl;
-         cout << tab << lhs.size << endl;
-         cout << tab << rhs.size << endl;
+         cout << tab << sbase.size << endl;
+         cout << tab << stest.size << endl;
        }
     }
 
-  if (lhs.version_name != rhs.version_name
-      && !check_version(lhs) && !check_version(rhs))
+  if (sbase.version_name != stest.version_name
+      && !check_version(sbase, false) && !check_version(stest, false, 
versioned_ns))
     {
       ret = false;
       if (verbose)
        {
          cout << tab << "incompatible versions" << endl;
-         cout << tab << lhs.version_name << endl;
-         cout << tab << rhs.version_name << endl;
+         cout << tab << sbase.version_name << endl;
+         cout << tab << stest.version_name << endl;
        }
     }
 
@@ -382,6 +457,9 @@ get_symbol(const string& name, const symbols& s)
     }
 }
 
+symbols
+create_symbols(const char* file, bool demangled_name_indexed, bool 
versioned_ns);
+
 void
 examine_symbol(const char* name, const char* file)
 {
@@ -394,9 +472,11 @@ int
 compare_symbols(const char* baseline_file, const char* test_file,
                bool verbose)
 {
+  const bool versioned_ns = bool(_GLIBCXX_INLINE_VERSION);
+
   // Input both lists of symbols into container.
-  symbols baseline = create_symbols(baseline_file);
-  symbols test = create_symbols(test_file);
+  symbols baseline = create_symbols(baseline_file, versioned_ns, false);
+  symbols test = create_symbols(test_file, versioned_ns, versioned_ns);
 
   //  Sanity check results.
   if (!baseline.size() || !test.size())
@@ -503,7 +583,7 @@ compare_symbols(const char* baseline_file, const char* 
test_file,
       if (stest.type == symbol::tls)
        {
          stest.status = symbol::undesignated;
-         if (!check_version(stest, false))
+         if (!check_version(stest, false, versioned_ns))
            incompatible.push_back(symbol_pair(stest, stest));
          else
            undesignated.push_back(stest);
@@ -516,7 +596,7 @@ compare_symbols(const char* baseline_file, const char* 
test_file,
                       || stest.version_name == "GLIBCXX_3.4.30"))
        {
          stest.status = symbol::undesignated;
-         if (!check_version(stest, false))
+         if (!check_version(stest, false, versioned_ns))
            incompatible.push_back(symbol_pair(stest, stest));
          else
            undesignated.push_back(stest);
@@ -524,7 +604,7 @@ compare_symbols(const char* baseline_file, const char* 
test_file,
       else
        {
          stest.status = symbol::added;
-         if (!check_version(stest, true))
+         if (!check_version(stest, true, versioned_ns))
            incompatible.push_back(symbol_pair(stest, stest));
        }
     }
@@ -535,7 +615,10 @@ compare_symbols(const char* baseline_file, const char* 
test_file,
     {
       symbol& sundes = undesignated[l];
       symbol_names::iterator end = added_names.end();
-      symbol_names::iterator it = find(added_names.begin(), end, sundes.name);
+      symbol_names::iterator it =
+       find(added_names.begin(), end, versioned_ns
+            ? sundes.demangled_name
+            : sundes.name);
        if (it != end)
        {
          // Found.
@@ -611,9 +694,8 @@ compare_symbols(const char* baseline_file, const char* 
test_file,
   return !(missing_names.size() || incompatible.size());
 }
 
-
 symbols
-create_symbols(const char* file)
+create_symbols(const char* file, bool demangled_name_indexed, bool 
versioned_ns)
 {
   symbols s;
   ifstream ifs(file);
@@ -627,8 +709,8 @@ create_symbols(const char* file)
       while (getline(ifs, line).good())
        {
          symbol tmp;
-         tmp.init(line);
-         s[tmp.name] = tmp;
+         tmp.init(line, versioned_ns);
+         s[demangled_name_indexed ? tmp.demangled_name : tmp.name] = tmp;
          line = empty;
        }
     }
@@ -641,6 +723,9 @@ create_symbols(const char* file)
   return s;
 }
 
+symbols
+create_symbols(const char* file)
+{ return create_symbols(file, false, false); }
 
 std::string
 demangle(const std::string& mangled)
diff --git a/libstdc++-v3/testsuite/util/testsuite_abi.h 
b/libstdc++-v3/testsuite/util/testsuite_abi.h
index 30e8f5d7f36..8f7faad39cd 100644
--- a/libstdc++-v3/testsuite/util/testsuite_abi.h
+++ b/libstdc++-v3/testsuite/util/testsuite_abi.h
@@ -19,9 +19,6 @@
 // Benjamin Kosnik  <[email protected]>
 
 #include <string>
-#include <stdexcept>
-#include <vector>
-#include <locale>
 #if __cplusplus >= 201103L
 # include <unordered_map>
 # ifdef _GLIBCXX_DEBUG
@@ -33,7 +30,6 @@ namespace unord = std;
 # include <tr1/unordered_map>
 namespace unord = std::tr1;
 #endif
-#include <cxxabi.h>
 
 // Encapsulates symbol characteristics.
 struct symbol
@@ -53,6 +49,7 @@ struct symbol
   std::string  name;
   std::string  raw_name; // Name with versioning info still attached.
   std::string  demangled_name;
+  std::string  raw_demangled_name;
   int          size;
   std::string  version_name;
   version      version_status;
@@ -64,6 +61,7 @@ struct symbol
 
   symbol(const symbol& other)
   : type(other.type), name(other.name), demangled_name(other.demangled_name),
+    raw_demangled_name(other.raw_demangled_name),
     size(other.size), version_name(other.version_name),
     version_status(other.version_status), status(other.status) { }
 
@@ -71,7 +69,7 @@ struct symbol
   print() const;
 
   void
-  init(std::string& data);
+  init(std::string& data, bool versioned_ns);
 };
 
 // Map type between symbol names and full symbol info.
@@ -80,7 +78,7 @@ typedef unord::unordered_map<std::string, symbol>     symbols;
 
 // Check.
 bool
-check_version(symbol& test, bool added = false);
+check_version(symbol& test, bool added = false, bool versioned_ns = false);
 
 bool
 check_compatible(symbol& lhs, symbol& rhs, bool verbose = false);

Reply via email to