OSDN Git Service

2004-10-23 Andrew Pinski <pinskia@physics.uc.edu>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / testsuite / testsuite_abi.h
1 // -*- C++ -*-
2
3 // Copyright (C) 2004 Free Software Foundation, Inc.
4
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2, or (at
8 // your option) any later version.
9
10 // This library is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // General Public License for more details.
14
15 // You should have received a copy of the GNU General Public License
16 // along with this library; see the file COPYING.  If not, write to
17 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
18 // MA 02111-1307, USA.
19
20 // As a special exception, you may use this file as part of a free
21 // software library without restriction.  Specifically, if other files
22 // instantiate templates or use macros or inline functions from this
23 // file, or you compile this file and link it with other files to
24 // produce an executable, this file does not by itself cause the
25 // resulting executable to be covered by the GNU General Public
26 // License.  This exception does not however invalidate any other
27 // reasons why the executable file might be covered by the GNU General
28 // Public License.
29
30 // Benjamin Kosnik  <bkoz@redhat.com>
31
32 #include <string>
33 #include <stdexcept>
34 #include <deque>
35 #include <ext/hash_map>
36 #include <cxxabi.h>
37
38 // Encapsulates symbol characteristics.
39 struct symbol
40 {
41   enum category { none, function, object, error };
42   enum designation { unknown, added, subtracted, compatible, incompatible };
43   enum compatibility 
44     { 
45       compat_type = 1, 
46       compat_name = 2, 
47       compat_size = 4, 
48       compat_version = 8 
49     };
50
51   category      type;
52   std::string   name;
53   std::string   demangled_name;
54   int           size;
55   std::string   version_name;
56   designation   status;
57
58   symbol() : type(none), size(0), status(unknown) { }
59
60   symbol(const symbol& other) 
61   : type(other.type), name(other.name), demangled_name(other.demangled_name), 
62    size(other.size), version_name(other.version_name),
63    status(other.status) { }
64
65   void
66   print() const;
67
68   void
69   init(std::string& data);
70 };
71
72 struct symbol_error : public std::logic_error
73 {
74   explicit symbol_error(const std::string& s) : std::logic_error(s) { }
75 };
76
77
78 typedef __gnu_cxx::hash_map<std::string, symbol>        symbol_objects;
79
80 typedef std::deque<std::string>                         symbol_names;
81
82 typedef std::pair<symbol_names, symbol_objects>         symbols;
83
84
85 // Check.
86 bool
87 check_version(const symbol& test, bool added = false);
88
89 bool 
90 check_compatible(const symbol& lhs, const symbol& rhs, bool verbose = false);
91
92
93 // Examine.
94 bool
95 has_symbol(const std::string& mangled, const symbols& list) throw();
96
97 symbol&
98 get_symbol(const std::string& mangled, const symbols& list);
99
100 extern "C" void
101 examine_symbol(const char* name, const char* file);
102
103 extern "C" void
104 compare_symbols(const char* baseline_file, const char* test_file, bool verb);
105
106
107 // Util.
108 symbols
109 create_symbols(const char* file);
110
111 const char*
112 demangle(const std::string& mangled);
113
114
115 // Specialization.
116 namespace __gnu_cxx
117 {
118   using namespace std;
119
120   template<> 
121     struct hash<string>
122     {
123       size_t operator()(const string& s) const 
124       { 
125         const collate<char>& c = use_facet<collate<char> >(locale::classic());
126         return c.hash(s.c_str(), s.c_str() + s.size());
127       }
128     }; 
129 }