From 10c8a4e0ce9134f2d5cabb162b3b6d1f287ce8b7 Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Sat, 28 May 2022 22:18:46 +0200 Subject: 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 --- app/perfsymboltable.cpp | 5 ++--- 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(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(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; } -- cgit v1.2.3