diff --git a/src/main.cpp b/src/main.cpp index a1221c56..2da859ae 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -156,6 +156,16 @@ int main(int argc, char** argv) QStringLiteral("path")); parser.addOption(exportTo); + const auto perfBinary = + QCommandLineOption(QStringLiteral("perf-binary"), + QCoreApplication::translate("main", "Path to the perf binary."), QStringLiteral("path")); + parser.addOption(perfBinary); + + const auto objdumpBinary = + QCommandLineOption(QStringLiteral("objdump-binary"), + QCoreApplication::translate("main", "Path to the objdump binary."), QStringLiteral("path")); + parser.addOption(objdumpBinary); + parser.addPositionalArgument( QStringLiteral("files"), QCoreApplication::translate("main", "Optional input files to open on startup, i.e. perf.data files."), @@ -183,6 +193,8 @@ int main(int argc, char** argv) applyArg(appPath, &Settings::setAppPath); applyArg(arch, &Settings::setArch); applyArg(sourcePath, &Settings::setSourceCodePaths); + applyArg(perfBinary, &Settings::setPerfPath); + applyArg(objdumpBinary, &Settings::setObjdump); }; auto* settings = Settings::instance(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 50f63669..6db41eb7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -124,7 +124,6 @@ MainWindow::MainWindow(QWidget* parent) connect(settings, &Settings::sysrootChanged, m_resultsPage, &ResultsPage::setSysroot); connect(settings, &Settings::appPathChanged, m_resultsPage, &ResultsPage::setAppPath); - connect(settings, &Settings::objdumpChanged, m_resultsPage, &ResultsPage::setObjdump); connect(m_startPage, &StartPage::pathSettingsButtonClicked, this, &MainWindow::openSettingsDialog); connect(m_startPage, &StartPage::openFileButtonClicked, this, &MainWindow::onOpenFileButtonClicked); diff --git a/src/models/disassemblyoutput.cpp b/src/models/disassemblyoutput.cpp index f83d7526..4698d590 100644 --- a/src/models/disassemblyoutput.cpp +++ b/src/models/disassemblyoutput.cpp @@ -306,7 +306,13 @@ DisassemblyOutput DisassemblyOutput::disassemble(const QString& objdump, const Q return disassemblyOutput; } - const auto processPath = QStandardPaths::findExecutable(objdump); + auto findObjdump = [](const QString& objdump) { + if (!objdump.isEmpty() && QFile::exists(objdump)) + return objdump; + return QStandardPaths::findExecutable(objdump); + }; + + const auto processPath = findObjdump(objdump); if (processPath.isEmpty()) { disassemblyOutput.errorMessage = QApplication::translate("DisassemblyOutput", diff --git a/src/resultsdisassemblypage.cpp b/src/resultsdisassemblypage.cpp index 0983a093..229adbbc 100644 --- a/src/resultsdisassemblypage.cpp +++ b/src/resultsdisassemblypage.cpp @@ -567,9 +567,9 @@ void ResultsDisassemblyPage::showDisassembly() } // TODO: add the ability to configure the arch <-> objdump mapping somehow in the settings - const auto objdump = [this]() { - if (!m_objdump.isEmpty()) - return m_objdump; + const auto objdump = [this](const QString& objdump) { + if (!objdump.isEmpty()) + return objdump; if (m_arch.startsWith(QLatin1String("armv8")) || m_arch.startsWith(QLatin1String("aarch64"))) { return QStringLiteral("aarch64-linux-gnu-objdump"); @@ -583,9 +583,10 @@ void ResultsDisassemblyPage::showDisassembly() auto settings = Settings::instance(); const auto colon = QLatin1Char(':'); - showDisassembly(DisassemblyOutput::disassemble( - objdump(), m_arch, settings->debugPaths().split(colon), settings->extraLibPaths().split(colon), - settings->sourceCodePaths().split(colon), settings->sysroot(), curSymbol)); + showDisassembly( + DisassemblyOutput::disassemble(objdump(settings->objdump()), m_arch, settings->debugPaths().split(colon), + settings->extraLibPaths().split(colon), settings->sourceCodePaths().split(colon), + settings->sysroot(), curSymbol)); } void ResultsDisassemblyPage::showDisassembly(const DisassemblyOutput& disassemblyOutput) @@ -653,11 +654,6 @@ void ResultsDisassemblyPage::setCostsMap(const Data::CallerCalleeResults& caller m_callerCalleeResults = callerCalleeResults; } -void ResultsDisassemblyPage::setObjdump(const QString& objdump) -{ - m_objdump = objdump; -} - void ResultsDisassemblyPage::setArch(const QString& arch) { m_arch = arch.trimmed().toLower(); diff --git a/src/resultsdisassemblypage.h b/src/resultsdisassemblypage.h index d00e9908..3cbb91ec 100644 --- a/src/resultsdisassemblypage.h +++ b/src/resultsdisassemblypage.h @@ -49,7 +49,6 @@ class ResultsDisassemblyPage : public QWidget void clear(); void setSymbol(const Data::Symbol& data); void setCostsMap(const Data::CallerCalleeResults& callerCalleeResults); - void setObjdump(const QString& objdump); void setArch(const QString& arch); void jumpToSourceLine(const Data::FileLine& line); @@ -78,8 +77,6 @@ class ResultsDisassemblyPage : public QWidget QModelIndex m_currentDisasmSearchIndex; // Architecture QString m_arch; - // Objdump binary name - QString m_objdump; // Map of symbols and its locations with costs Data::CallerCalleeResults m_callerCalleeResults; // Cost delegate diff --git a/src/resultspage.cpp b/src/resultspage.cpp index 2f4ddbf9..39c6ff3c 100644 --- a/src/resultspage.cpp +++ b/src/resultspage.cpp @@ -266,11 +266,6 @@ void ResultsPage::onJumpToSourceCode(const Data::Symbol& symbol, const Data::Fil } } -void ResultsPage::setObjdump(const QString& objdump) -{ - m_resultsDisassemblyPage->setObjdump(objdump); -} - void ResultsPage::onOpenEditor(const Data::Symbol& symbol) { m_resultsCallerCalleePage->openEditor(symbol); diff --git a/src/resultspage.h b/src/resultspage.h index baf1bb18..f450a0d5 100644 --- a/src/resultspage.h +++ b/src/resultspage.h @@ -56,7 +56,6 @@ class ResultsPage : public QWidget public slots: void setSysroot(const QString& path); void setAppPath(const QString& path); - void setObjdump(const QString& objdump); void onJumpToCallerCallee(const Data::Symbol& symbol); void onOpenEditor(const Data::Symbol& symbol);