diff options
Diffstat (limited to 'app/perfaddresscache.h')
-rw-r--r-- | app/perfaddresscache.h | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/app/perfaddresscache.h b/app/perfaddresscache.h index 92751f9..055ac3e 100644 --- a/app/perfaddresscache.h +++ b/app/perfaddresscache.h @@ -21,6 +21,8 @@ #define PERFADDRESSCACHE_H #include <QHash> +#include <QVector> + #include "perfelfmap.h" class PerfAddressCache @@ -36,13 +38,47 @@ public: int locationId; bool isInterworking; }; + using OffsetAddressCache = QHash<quint64, AddressCacheEntry>; + + struct SymbolCacheEntry + { + SymbolCacheEntry(quint64 offset = 0, quint64 value = 0, quint64 size = 0, const QByteArray &symname = {}) + : offset(offset) + , value(value) + , size(size) + , symname(symname) + {} + + bool isValid() const { return !symname.isEmpty(); } + + // adjusted/absolute st_value, see documentation of the `addr` arg in `dwfl_module_getsym_info` + quint64 offset; + // unadjusted/relative st_value + quint64 value; + quint64 size; + QByteArray symname; + bool demangled = false; + }; + using SymbolCache = QVector<SymbolCacheEntry>; - AddressCacheEntry find(const PerfElfMap::ElfInfo& elf, quint64 addr) const; + AddressCacheEntry find(const PerfElfMap::ElfInfo& elf, quint64 addr, + OffsetAddressCache *invalidAddressCache) const; void cache(const PerfElfMap::ElfInfo& elf, quint64 addr, - const AddressCacheEntry& entry); - void clearInvalid(); + const AddressCacheEntry& entry, OffsetAddressCache *invalidAddressCache); + + /// check if @c setSymbolCache was called for @p filePath already + bool hasSymbolCache(const QByteArray &filePath) const; + /// take @p cache, sort it and use it for symbol lookups in @p filePath + void setSymbolCache(const QByteArray &filePath, SymbolCache cache); + /// find the symbol that encompasses @p relAddr in @p filePath + /// if the found symbol wasn't yet demangled, it will be demangled now + SymbolCacheEntry findSymbol(const QByteArray &filePath, quint64 relAddr); private: - QHash<QByteArray, QHash<quint64, AddressCacheEntry>> m_cache; + QHash<QByteArray, OffsetAddressCache> m_cache; + QHash<QByteArray, SymbolCache> m_symbolCache; }; +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(PerfAddressCache::SymbolCacheEntry, Q_MOVABLE_TYPE); +QT_END_NAMESPACE #endif |