]>
Commit | Line | Data |
---|---|---|
4b260c20 BK |
1 | // -*- C++ -*- |
2 | ||
a945c346 | 3 | // Copyright (C) 2004-2024 Free Software Foundation, Inc. |
4b260c20 BK |
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 | |
748086b7 | 7 | // published by the Free Software Foundation; either version 3, or (at |
4b260c20 BK |
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 | |
748086b7 JJ |
16 | // along with this library; see the file COPYING3. If not see |
17 | // <http://www.gnu.org/licenses/>. | |
18 | ||
4b260c20 BK |
19 | // Benjamin Kosnik <bkoz@redhat.com> |
20 | ||
21 | #include <string> | |
22 | #include <stdexcept> | |
0c312c2d | 23 | #include <vector> |
84b31797 | 24 | #include <locale> |
4190b7f1 JW |
25 | #if __cplusplus >= 201103L |
26 | # include <unordered_map> | |
f4b4ce15 FD |
27 | # ifdef _GLIBCXX_DEBUG |
28 | namespace unord = std::_GLIBCXX_STD_C; | |
29 | # else | |
4190b7f1 | 30 | namespace unord = std; |
f4b4ce15 | 31 | # endif |
4190b7f1 JW |
32 | #else |
33 | # include <tr1/unordered_map> | |
34 | namespace unord = std::tr1; | |
35 | #endif | |
4b260c20 BK |
36 | #include <cxxabi.h> |
37 | ||
38 | // Encapsulates symbol characteristics. | |
39 | struct symbol | |
40 | { | |
bf718682 | 41 | enum category { function, object, tls, uncategorized }; |
bb2b2a24 BK |
42 | enum designation { existing, added, subtracted, undesignated }; |
43 | enum version { none, compatible, incompatible, unversioned }; | |
f92ab29f CG |
44 | enum compatibility |
45 | { | |
46 | compat_type = 1, | |
47 | compat_name = 2, | |
48 | compat_size = 4, | |
49 | compat_version = 8 | |
4b260c20 BK |
50 | }; |
51 | ||
52 | category type; | |
53 | std::string name; | |
bb2b2a24 | 54 | std::string raw_name; // Name with versioning info still attached. |
4b260c20 BK |
55 | std::string demangled_name; |
56 | int size; | |
57 | std::string version_name; | |
bb2b2a24 | 58 | version version_status; |
4b260c20 BK |
59 | designation status; |
60 | ||
f92ab29f CG |
61 | symbol() |
62 | : type(uncategorized), size(0), version_status(unversioned), | |
bb2b2a24 | 63 | status(undesignated) { } |
4b260c20 | 64 | |
f92ab29f CG |
65 | symbol(const symbol& other) |
66 | : type(other.type), name(other.name), demangled_name(other.demangled_name), | |
67 | size(other.size), version_name(other.version_name), | |
bb2b2a24 | 68 | version_status(other.version_status), status(other.status) { } |
4b260c20 BK |
69 | |
70 | void | |
71 | print() const; | |
72 | ||
73 | void | |
74 | init(std::string& data); | |
75 | }; | |
76 | ||
0c312c2d | 77 | // Map type between symbol names and full symbol info. |
4190b7f1 | 78 | typedef unord::unordered_map<std::string, symbol> symbols; |
4b260c20 BK |
79 | |
80 | ||
81 | // Check. | |
82 | bool | |
bb2b2a24 | 83 | check_version(symbol& test, bool added = false); |
4b260c20 | 84 | |
f92ab29f | 85 | bool |
bb2b2a24 | 86 | check_compatible(symbol& lhs, symbol& rhs, bool verbose = false); |
4b260c20 BK |
87 | |
88 | ||
89 | // Examine. | |
90 | bool | |
91 | has_symbol(const std::string& mangled, const symbols& list) throw(); | |
92 | ||
0c312c2d | 93 | const symbol& |
4b260c20 BK |
94 | get_symbol(const std::string& mangled, const symbols& list); |
95 | ||
96 | extern "C" void | |
97 | examine_symbol(const char* name, const char* file); | |
98 | ||
fdbba6bc | 99 | extern "C" int |
4b260c20 BK |
100 | compare_symbols(const char* baseline_file, const char* test_file, bool verb); |
101 | ||
102 | ||
103 | // Util. | |
104 | symbols | |
105 | create_symbols(const char* file); | |
106 | ||
4f7c2c7f | 107 | std::string |
4b260c20 | 108 | demangle(const std::string& mangled); |