diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2022-05-28 22:18:46 +0200 |
---|---|---|
committer | Milian Wolff <milian.wolff@kdab.com> | 2022-06-08 20:18:15 +0000 |
commit | 10c8a4e0ce9134f2d5cabb162b3b6d1f287ce8b7 (patch) | |
tree | c8401df06ad3193a78eee812d589147f9c5fafa6 | |
parent | ba1d0501e3f3a3a26d7f2af1a89f25b5495e4709 (diff) |
Cleanup: Make PerfSymbolTable::attachDwfl more type safe
Replace `void* arg` by explicit `PerfUnwind::UnwindInfo *unwindInfo`
instead of casting the void to that type internally.
Change-Id: I64a716f7f89ae75e1b21470a927441f07beb70c6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | app/perfsymboltable.cpp | 5 | ||||
-rw-r--r-- | app/perfsymboltable.h | 2 |
2 files changed, 3 insertions, 4 deletions
diff --git a/app/perfsymboltable.cpp b/app/perfsymboltable.cpp index 55efb16..ac8ae11 100644 --- a/app/perfsymboltable.cpp +++ b/app/perfsymboltable.cpp @@ -836,7 +836,7 @@ bool PerfSymbolTable::containsAddress(quint64 address) const return m_elfs.isAddressInRange(address); } -Dwfl *PerfSymbolTable::attachDwfl(const Dwfl_Thread_Callbacks *callbacks, void *arg) +Dwfl *PerfSymbolTable::attachDwfl(const Dwfl_Thread_Callbacks *callbacks, PerfUnwind::UnwindInfo *unwindInfo) { if (static_cast<pid_t>(m_pid) == dwfl_pid(m_dwfl)) return m_dwfl; // Already attached, nothing to do @@ -844,14 +844,13 @@ Dwfl *PerfSymbolTable::attachDwfl(const Dwfl_Thread_Callbacks *callbacks, void * // only attach state when we have the required information for stack unwinding // for normal symbol resolution and inline frame resolution this is not needed // most notably, this isn't needed for frame pointer callchains - PerfUnwind::UnwindInfo *unwindInfo = static_cast<PerfUnwind::UnwindInfo *>(arg); const auto sampleType = unwindInfo->sample->type(); const auto hasSampleRegsUser = (sampleType & PerfEventAttributes::SAMPLE_REGS_USER); const auto hasSampleStackUser = (sampleType & PerfEventAttributes::SAMPLE_STACK_USER); if (!hasSampleRegsUser || !hasSampleStackUser) return nullptr; - if (!dwfl_attach_state(m_dwfl, m_firstElf.elf(), m_pid, callbacks, arg)) { + if (!dwfl_attach_state(m_dwfl, m_firstElf.elf(), m_pid, callbacks, unwindInfo)) { qWarning() << m_pid << "failed to attach state" << dwfl_errmsg(dwfl_errno()); return nullptr; } diff --git a/app/perfsymboltable.h b/app/perfsymboltable.h index 66ba74e..0367560 100644 --- a/app/perfsymboltable.h +++ b/app/perfsymboltable.h @@ -72,7 +72,7 @@ public: void updatePerfMap(); bool containsAddress(quint64 address) const; - Dwfl *attachDwfl(const Dwfl_Thread_Callbacks *callbacks, void *arg); + Dwfl *attachDwfl(const Dwfl_Thread_Callbacks *callbacks, PerfUnwind::UnwindInfo *unwindInfo); void clearCache(); bool cacheIsDirty() const { return m_cacheIsDirty; } |