diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2017-06-01 22:05:53 +0200 |
---|---|---|
committer | Milian Wolff <milian.wolff@kdab.com> | 2017-08-28 09:57:32 +0000 |
commit | c17a75a27cef09495b9f4d62114e3758af2c3012 (patch) | |
tree | 1562ba6e1cf419041d1ee824862513b5a0911cfa | |
parent | 609c53d2e2eed8aa9a77f1fd4fd406077a9308a9 (diff) |
Delay loading of kallsyms file until it is needed
This is mostly done to enable a future patch that will load the
kallsyms file via it's build-id from the debug path.
Change-Id: Ic5c6ecd09dfdf7f8c42b13497f77bc6c43147cf8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | app/perfkallsyms.h | 1 | ||||
-rw-r--r-- | app/perfunwind.cpp | 16 | ||||
-rw-r--r-- | app/perfunwind.h | 5 |
3 files changed, 14 insertions, 8 deletions
diff --git a/app/perfkallsyms.h b/app/perfkallsyms.h index 3fd16bc..efce043 100644 --- a/app/perfkallsyms.h +++ b/app/perfkallsyms.h @@ -41,6 +41,7 @@ class PerfKallsyms public: bool parseMapping(const QString &path); QString errorString() const { return m_errorString; } + bool isEmpty() const { return m_entries.isEmpty(); } PerfKallsymEntry findEntry(quint64 address) const; diff --git a/app/perfunwind.cpp b/app/perfunwind.cpp index 12ccfef..09d17ce 100644 --- a/app/perfunwind.cpp +++ b/app/perfunwind.cpp @@ -91,7 +91,8 @@ PerfUnwind::PerfUnwind(QIODevice *output, const QString &systemRoot, const QStri int maxFrames) : m_output(output), m_architecture(PerfRegisterInfo::ARCH_INVALID), m_systemRoot(systemRoot), m_extraLibsPath(extraLibsPath), m_appPath(appPath), m_debugPath(debugPath), - m_maxEventBufferSize(maxEventBufferSize), m_eventBufferSize(0), m_lastFlushMaxTime(0) + m_kallsymsPath(kallsymsPath), m_maxEventBufferSize(maxEventBufferSize), m_eventBufferSize(0), + m_lastFlushMaxTime(0) { m_stats.enabled = printStats; m_currentUnwind.unwind = this; @@ -114,11 +115,6 @@ PerfUnwind::PerfUnwind(QIODevice *output, const QString &systemRoot, const QStri qint32 dataStreamVersion = qToLittleEndian(QDataStream::Qt_DefaultCompiledVersion); output->write(reinterpret_cast<const char *>(&dataStreamVersion), sizeof(qint32)); } - - if (!m_kallsyms.parseMapping(kallsymsPath)) - sendError(InvalidKallsyms, - tr("Failed to parse kernel symbol mapping file \"%1\": %2") - .arg(kallsymsPath, m_kallsyms.errorString())); } PerfUnwind::~PerfUnwind() @@ -553,8 +549,14 @@ void PerfUnwind::resolveSymbol(int locationId, const PerfUnwind::Symbol &symbol) sendSymbol(locationId, symbol); } -PerfKallsymEntry PerfUnwind::findKallsymEntry(quint64 address) const +PerfKallsymEntry PerfUnwind::findKallsymEntry(quint64 address) { + if (m_kallsyms.isEmpty() && m_kallsyms.errorString().isEmpty()) { + if (!m_kallsyms.parseMapping(m_kallsymsPath)) + sendError(InvalidKallsyms, + tr("Failed to parse kernel symbol mapping file \"%1\": %2") + .arg(m_kallsymsPath, m_kallsyms.errorString())); + } return m_kallsyms.findEntry(address); } diff --git a/app/perfunwind.h b/app/perfunwind.h index 209e863..740b6b8 100644 --- a/app/perfunwind.h +++ b/app/perfunwind.h @@ -140,7 +140,7 @@ public: bool hasSymbol(int locationId) const; void resolveSymbol(int locationId, const Symbol &symbol); - PerfKallsymEntry findKallsymEntry(quint64 address) const; + PerfKallsymEntry findKallsymEntry(quint64 address); enum ErrorCode { TimeOrderViolation = 1, @@ -192,6 +192,9 @@ private: // Path to debug information, e.g. ~/.debug and /usr/local/debug QString m_debugPath; + // Path to kallsyms path + QString m_kallsymsPath; + QList<PerfRecordSample> m_sampleBuffer; QList<PerfRecordMmap> m_mmapBuffer; QHash<quint32, PerfSymbolTable *> m_symbolTables; |