summaryrefslogtreecommitdiffstats
path: root/app/perfaddresscache.h
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2022-05-28 22:28:37 +0200
committerMilian Wolff <milian.wolff@kdab.com>2022-06-08 20:18:20 +0000
commit443bd9ba86615f319fecd3fbb47f1c2413ae373c (patch)
treeac280fdd1a6130f31fe65133ddca5cdb111a0f17 /app/perfaddresscache.h
parent10c8a4e0ce9134f2d5cabb162b3b6d1f287ce8b7 (diff)
Move code to extract symbol cache into perfaddresscache
This makes the code more easily reusable and moves code that belongs together logically into the same file. Change-Id: Icce3a1ce4dc05f3a7cd9333fa7c88bd3a1b118ec Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'app/perfaddresscache.h')
-rw-r--r--app/perfaddresscache.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/perfaddresscache.h b/app/perfaddresscache.h
index 055ac3e..fd978bd 100644
--- a/app/perfaddresscache.h
+++ b/app/perfaddresscache.h
@@ -25,9 +25,23 @@
#include "perfelfmap.h"
+#include <libdwfl.h>
+
class PerfAddressCache
{
public:
+ static quint64 symbolAddress(quint64 addr, bool isArmArch)
+ {
+ // For dwfl API call we need the raw pointer into symtab, so we need to adjust ip.
+ return (!isArmArch || (addr & 1)) ? addr : addr + 1;
+ }
+
+ static quint64 alignedAddress(quint64 addr, bool isArmArch)
+ {
+ // Adjust addr back. The symtab entries are 1 off for all practical purposes.
+ return (isArmArch && (addr & 1)) ? addr - 1 : addr;
+ }
+
struct AddressCacheEntry
{
AddressCacheEntry(int locationId = -1, bool isInterworking = false)
@@ -73,6 +87,10 @@ public:
/// 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);
+
+ /// extract all symbols in @p module into a structure suitable to be passed to @p setSymbols
+ static SymbolCache extractSymbols(Dwfl_Module *module, quint64 elfStart, bool isArmArch);
+
private:
QHash<QByteArray, OffsetAddressCache> m_cache;
QHash<QByteArray, SymbolCache> m_symbolCache;