From 70cd96d631e2a63381cde248f6b68e0b7c9289f0 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 25 Jan 2018 11:18:34 +0100 Subject: When analyzing samples in kernel space, use kernel symbols Without this we cannot properly report any kernel stack traces and get interesting error messages because the symbols aren't found in userspace. Change-Id: I981dbdac27beefa57c74bc9e8f41d5438e75668c Reviewed-by: Christian Kandeler --- app/perfunwind.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/perfunwind.cpp b/app/perfunwind.cpp index 849b220..fab3e15 100644 --- a/app/perfunwind.cpp +++ b/app/perfunwind.cpp @@ -509,8 +509,7 @@ void PerfUnwind::analyze(const PerfRecordSample &sample) return; const bool isKernel = ipIsInKernelSpace(sample.ip()); - - PerfSymbolTable *userSymbols = symbolTable(sample.pid()); + PerfSymbolTable *symbols = symbolTable(isKernel ? s_kernelPid : sample.pid()); for (int unwindingAttempt = 0; unwindingAttempt < 2; ++unwindingAttempt) { m_currentUnwind.isInterworking = false; @@ -518,31 +517,30 @@ void PerfUnwind::analyze(const PerfRecordSample &sample) m_currentUnwind.sample = &sample; m_currentUnwind.frames.clear(); - userSymbols->updatePerfMap(); + symbols->updatePerfMap(); - Dwfl *userDwfl = userSymbols->attachDwfl(&m_currentUnwind); + Dwfl *dwfl = symbols->attachDwfl(&m_currentUnwind); if (sample.callchain().length() > 0) resolveCallchain(); // only try to unwind when resolveCallchain did not dirty the cache - if (!userSymbols->cacheIsDirty()) { - if (userDwfl && sample.registerAbi() != 0 && sample.userStack().length() > 0) - unwindStack(userDwfl); + if (!symbols->cacheIsDirty()) { + if (dwfl && sample.registerAbi() != 0 && sample.userStack().length() > 0) + unwindStack(dwfl); else break; } // when the cache is dirty, we clean it up and try again, otherwise we can // stop as unwinding should have succeeded - if (userSymbols->cacheIsDirty()) - userSymbols->clearCache(); // fail, try again + if (symbols->cacheIsDirty()) + symbols->clearCache(); // fail, try again else break; // success } // If nothing was found, at least look up the IP if (m_currentUnwind.frames.isEmpty()) { - PerfSymbolTable *symbols = isKernel ? symbolTable(s_kernelPid) : userSymbols; m_currentUnwind.frames.append(symbols->lookupFrame(sample.ip(), isKernel, &m_currentUnwind.isInterworking)); } -- cgit v1.2.3