]>
Commit | Line | Data |
---|---|---|
4b260c20 BK |
1 | // -*- C++ -*- |
2 | ||
aa118a03 | 3 | // Copyright (C) 2004-2014 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> |
0c3de900 | 25 | #include <tr1/unordered_map> |
4b260c20 BK |
26 | #include <cxxabi.h> |
27 | ||
28 | // Encapsulates symbol characteristics. | |
29 | struct symbol | |
30 | { | |
bf718682 | 31 | enum category { function, object, tls, uncategorized }; |
bb2b2a24 BK |
32 | enum designation { existing, added, subtracted, undesignated }; |
33 | enum version { none, compatible, incompatible, unversioned }; | |
4b260c20 BK |
34 | enum compatibility |
35 | { | |
36 | compat_type = 1, | |
37 | compat_name = 2, | |
38 | compat_size = 4, | |
39 | compat_version = 8 | |
40 | }; | |
41 | ||
42 | category type; | |
43 | std::string name; | |
bb2b2a24 | 44 | std::string raw_name; // Name with versioning info still attached. |
4b260c20 BK |
45 | std::string demangled_name; |
46 | int size; | |
47 | std::string version_name; | |
bb2b2a24 | 48 | version version_status; |
4b260c20 BK |
49 | designation status; |
50 | ||
bb2b2a24 BK |
51 | symbol() |
52 | : type(uncategorized), size(0), version_status(unversioned), | |
53 | status(undesignated) { } | |
4b260c20 BK |
54 | |
55 | symbol(const symbol& other) | |
56 | : type(other.type), name(other.name), demangled_name(other.demangled_name), | |
bb2b2a24 BK |
57 | size(other.size), version_name(other.version_name), |
58 | version_status(other.version_status), status(other.status) { } | |
4b260c20 BK |
59 | |
60 | void | |
61 | print() const; | |
62 | ||
63 | void | |
64 | init(std::string& data); | |
65 | }; | |
66 | ||
0c312c2d BK |
67 | // Map type between symbol names and full symbol info. |
68 | typedef std::tr1::unordered_map<std::string, symbol> symbols; | |
4b260c20 BK |
69 | |
70 | ||
71 | // Check. | |
72 | bool | |
bb2b2a24 | 73 | check_version(symbol& test, bool added = false); |
4b260c20 BK |
74 | |
75 | bool | |
bb2b2a24 | 76 | check_compatible(symbol& lhs, symbol& rhs, bool verbose = false); |
4b260c20 BK |
77 | |
78 | ||
79 | // Examine. | |
80 | bool | |
81 | has_symbol(const std::string& mangled, const symbols& list) throw(); | |
82 | ||
0c312c2d | 83 | const symbol& |
4b260c20 BK |
84 | get_symbol(const std::string& mangled, const symbols& list); |
85 | ||
86 | extern "C" void | |
87 | examine_symbol(const char* name, const char* file); | |
88 | ||
fdbba6bc | 89 | extern "C" int |
4b260c20 BK |
90 | compare_symbols(const char* baseline_file, const char* test_file, bool verb); |
91 | ||
92 | ||
93 | // Util. | |
94 | symbols | |
95 | create_symbols(const char* file); | |
96 | ||
97 | const char* | |
98 | demangle(const std::string& mangled); |