Changeset View
Changeset View
Standalone View
Standalone View
src/analyze/gui/locationdata.h
Show All 22 Lines | |||||
23 | #include <QString> | 23 | #include <QString> | ||
24 | 24 | | |||
25 | #include <memory> | 25 | #include <memory> | ||
26 | 26 | | |||
27 | #include <boost/functional/hash.hpp> | 27 | #include <boost/functional/hash.hpp> | ||
28 | 28 | | |||
29 | #include <KLocalizedString> | 29 | #include <KLocalizedString> | ||
30 | 30 | | |||
31 | using SymbolId = long; | ||||
mwolff: quint64 or uint64_t please | |||||
32 | | ||||
31 | struct Symbol | 33 | struct Symbol | ||
32 | { | 34 | { | ||
33 | Symbol(const QString& symbol = {}, const QString& binary = {}, const QString& path = {}) | 35 | Symbol(const QString& symbol = {}, const QString& binary = {}, const QString& path = {}, SymbolId symbolId = 0) | ||
34 | : symbol(symbol) | 36 | : symbol(symbol) | ||
35 | , binary(binary) | 37 | , binary(binary) | ||
36 | , path(path) | 38 | , path(path) | ||
39 | , symbolId(symbolId) | ||||
37 | { | 40 | { | ||
38 | } | 41 | } | ||
39 | 42 | | |||
40 | // function name | 43 | // function name | ||
41 | QString symbol; | 44 | QString symbol; | ||
42 | // dso / executable name | 45 | // dso / executable name | ||
43 | QString binary; | 46 | QString binary; | ||
44 | // path to dso / executable | 47 | // path to dso / executable | ||
45 | QString path; | 48 | QString path; | ||
49 | // ID | ||||
50 | SymbolId symbolId; | ||||
46 | 51 | | |||
47 | bool operator==(const Symbol& rhs) const | 52 | bool operator==(const Symbol& rhs) const | ||
48 | { | 53 | { | ||
49 | return std::tie(symbol, binary, path) == std::tie(rhs.symbol, rhs.binary, rhs.path); | 54 | return symbolId == rhs.symbolId; | ||
50 | } | 55 | } | ||
51 | 56 | | |||
52 | bool operator!=(const Symbol& rhs) const | 57 | bool operator!=(const Symbol& rhs) const | ||
53 | { | 58 | { | ||
54 | return !operator==(rhs); | 59 | return !operator==(rhs); | ||
55 | } | 60 | } | ||
56 | 61 | | |||
57 | bool operator<(const Symbol& rhs) const | 62 | bool operator<(const Symbol& rhs) const | ||
58 | { | 63 | { | ||
59 | return std::tie(symbol, binary, path) < std::tie(rhs.symbol, rhs.binary, rhs.path); | 64 | return symbolId < rhs.symbolId; | ||
60 | } | 65 | } | ||
61 | 66 | | |||
62 | bool isValid() const | 67 | bool isValid() const | ||
63 | { | 68 | { | ||
64 | return !symbol.isEmpty() || !binary.isEmpty() || !path.isEmpty(); | 69 | return symbolId > 0; | ||
65 | } | 70 | } | ||
66 | 71 | | |||
72 | struct FullEqual { | ||||
73 | bool operator()(const Symbol &lhs, const Symbol &rhs) const { | ||||
74 | return lhs.symbol == rhs.symbol && | ||||
75 | lhs.binary == rhs.binary && | ||||
76 | lhs.path == rhs.path; | ||||
77 | } | ||||
78 | }; | ||||
67 | struct FullLessThan { | 79 | struct FullLessThan { | ||
68 | bool operator()(const Symbol &lhs, const Symbol &rhs) const { | 80 | bool operator()(const Symbol &lhs, const Symbol &rhs) const { | ||
69 | return std::tie(lhs.symbol, lhs.binary, lhs.path) < std::tie(rhs.symbol, rhs.binary, rhs.path); | 81 | return std::tie(lhs.symbol, lhs.binary, lhs.path) < std::tie(rhs.symbol, rhs.binary, rhs.path); | ||
70 | } | 82 | } | ||
71 | }; | 83 | }; | ||
72 | }; | 84 | }; | ||
73 | 85 | | |||
74 | Q_DECLARE_TYPEINFO(Symbol, Q_MOVABLE_TYPE); | 86 | Q_DECLARE_TYPEINFO(Symbol, Q_MOVABLE_TYPE); | ||
Show All 25 Lines | |||||
100 | inline QString unresolvedFunctionName() | 112 | inline QString unresolvedFunctionName() | ||
101 | { | 113 | { | ||
102 | static QString msg = i18n("<unresolved function>"); | 114 | static QString msg = i18n("<unresolved function>"); | ||
103 | return msg; | 115 | return msg; | ||
104 | } | 116 | } | ||
105 | 117 | | |||
106 | inline uint qHash(const Symbol& symbol, uint seed_ = 0) | 118 | inline uint qHash(const Symbol& symbol, uint seed_ = 0) | ||
107 | { | 119 | { | ||
108 | size_t seed = seed_; | 120 | return qHash(symbol.symbolId, seed_); | ||
109 | boost::hash_combine(seed, qHash(symbol.symbol)); | | |||
110 | boost::hash_combine(seed, qHash(symbol.binary)); | | |||
111 | boost::hash_combine(seed, qHash(symbol.path)); | | |||
112 | return seed; | | |||
113 | } | 121 | } | ||
114 | 122 | | |||
115 | inline uint qHash(const FileLine& location, uint seed_ = 0) | 123 | inline uint qHash(const FileLine& location, uint seed_ = 0) | ||
116 | { | 124 | { | ||
117 | size_t seed = seed_; | 125 | size_t seed = seed_; | ||
118 | boost::hash_combine(seed, qHash(location.file)); | 126 | boost::hash_combine(seed, qHash(location.file)); | ||
119 | boost::hash_combine(seed, location.line); | 127 | boost::hash_combine(seed, location.line); | ||
120 | return seed; | 128 | return seed; | ||
121 | } | 129 | } | ||
122 | 130 | | |||
123 | #endif // LOCATIONDATA_H | 131 | #endif // LOCATIONDATA_H |
quint64 or uint64_t please