Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perf map select #510

Merged
merged 3 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ MainWindow::MainWindow(QWidget* parent)
settings->setKallsyms(m_settingsDialog->kallsyms());
settings->setArch(m_settingsDialog->arch());
settings->setObjdump(m_settingsDialog->objdump());
settings->setPerfMapPath(m_settingsDialog->perfMapPath());
});

connect(settings, &Settings::sysrootChanged, m_resultsPage, &ResultsPage::setSysroot);
Expand Down
10 changes: 10 additions & 0 deletions src/parsers/perf/perfparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <QBuffer>
#include <QDataStream>
#include <QDebug>
#include <QDir>
#include <QEventLoop>
#include <QFileInfo>
#include <QLoggingCategory>
Expand Down Expand Up @@ -751,6 +752,9 @@ class PerfParserPrivate : public QObject
commands.names[threadStart.pid][threadStart.pid] = parentComm;
thread->name = parentComm;
}
// check if perf-$pid.map file exists
perfMapFileExists |= QFile::exists(QDir::tempPath() + QDir::separator()
+ QLatin1String("perf-%1.map").arg(QString::number(thread->pid)));
break;
}
case EventType::ThreadEnd: {
Expand Down Expand Up @@ -1388,6 +1392,7 @@ class PerfParserPrivate : public QObject
qint32 m_schedSwitchCostId = -1;
QHash<quint32, quint64> m_lastSampleTimePerCore;
Settings::CostAggregation costAggregation;
bool perfMapFileExists = false;

// samples recorded without --call-graph have only one frame
int m_numSamplesWithMoreThanOneFrame = 0;
Expand Down Expand Up @@ -1518,6 +1523,10 @@ bool PerfParser::initParserArgs(const QString& path)
if (!arch.isEmpty()) {
parserArgs += {QStringLiteral("--arch"), arch};
}
const auto perfMapPath = settings->perfMapPath();
if (!perfMapPath.isEmpty()) {
parserArgs += {QStringLiteral("--perf-map-path"), perfMapPath};
}
return parserArgs;
};

Expand Down Expand Up @@ -1564,6 +1573,7 @@ void PerfParser::startParseFile(const QString& path)
emit eventsAvailable(d.eventResult);
emit frequencyDataAvailable(d.frequencyResult);
emit threadNamesAvailable(d.commands);
emit perfMapFileExists(d.perfMapFileExists);

if (d.m_numSamplesWithMoreThanOneFrame == 0) {
emit parserWarning(tr("Samples contained no call stack frames. Consider passing <code>--call-graph "
Expand Down
1 change: 1 addition & 0 deletions src/parsers/perf/perfparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class PerfParser : public QObject
void progress(float progress);
void debugInfoDownloadProgress(const QString& module, const QString& url, qint64 numerator, qint64 denominator);
void stopRequested();
void perfMapFileExists(bool exists);

void parserWarning(const QString& errorMessage);
void exportFinished(const QUrl& url);
Expand Down
8 changes: 8 additions & 0 deletions src/resultspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ ResultsPage::ResultsPage(PerfParser* parser, QWidget* parent)
m_filterBusyIndicator->setVisible(false);
});

connect(parser, &PerfParser::perfMapFileExists, this, [errorWidget = ui->errorWidget](bool exists) {
if (exists) {
errorWidget->setText(tr("Perf Map file detected. Consider exporting in the perfparser format or copying "
"it to another location to keep all backtraces"));
errorWidget->show();
}
});

{
// create a busy indicator
m_filterBusyIndicator = new QWidget(this);
Expand Down
7 changes: 7 additions & 0 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ void Settings::setObjdump(const QString& objdump)
emit objdumpChanged(m_objdump);
}

void Settings::setPerfMapPath(const QString& perfMapPath)
{
m_perfMapPath = perfMapPath;
emit perfMapPathChanged(m_perfMapPath);
}

void Settings::setCallgraphParentDepth(int parent)
{
if (m_callgraphParentDepth != parent) {
Expand Down Expand Up @@ -221,6 +227,7 @@ void Settings::loadFromFile()
setKallsyms(currentConfig.readEntry("kallsyms", ""));
setArch(currentConfig.readEntry("arch", ""));
setObjdump(currentConfig.readEntry("objdump", ""));
setPerfMapPath(currentConfig.readEntry("perfMapPath", ""));
}

setPerfPath(sharedConfig->group("Perf").readEntry("path", ""));
Expand Down
8 changes: 8 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ class Settings : public QObject
return m_objdump;
}

QString perfMapPath() const
{
return m_perfMapPath;
}

int callgraphParentDepth() const
{
return m_callgraphParentDepth;
Expand Down Expand Up @@ -166,6 +171,7 @@ class Settings : public QObject
void appPathChanged(const QString& path);
void archChanged(const QString& arch);
void objdumpChanged(const QString& objdump);
void perfMapPathChanged(const QString& perfMapPath);
void callgraphChanged();
void lastUsedEnvironmentChanged(const QString& envName);
void sourceCodePathsChanged(const QString& paths);
Expand All @@ -185,6 +191,7 @@ public slots:
void setAppPath(const QString& path);
void setArch(const QString& arch);
void setObjdump(const QString& objdump);
void setPerfMapPath(const QString& perfMapPath);
void setCallgraphParentDepth(int parent);
void setCallgraphChildDepth(int child);
void setCallgraphColors(const QColor& active, const QColor& inactive);
Expand Down Expand Up @@ -214,6 +221,7 @@ public slots:
QString m_arch;
QString m_objdump;
QString m_sourceCodePaths;
QString m_perfMapPath;

QString m_lastUsedEnvironment;

Expand Down
5 changes: 5 additions & 0 deletions src/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ QString SettingsDialog::objdump() const
return unwindPage->lineEditObjdump->text();
}

QString SettingsDialog::perfMapPath() const
{
return unwindPage->lineEditPerfMapPath->text();
}

void SettingsDialog::addPerfSettingsPage()
{
auto page = new QWidget(this);
Expand Down
1 change: 1 addition & 0 deletions src/settingsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class SettingsDialog : public KPageDialog
QString kallsyms() const;
QString arch() const;
QString objdump() const;
QString perfMapPath() const;

void keyPressEvent(QKeyEvent* event) override;

Expand Down
16 changes: 15 additions & 1 deletion src/unwindsettingspage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>505</width>
<width>556</width>
<height>656</height>
</rect>
</property>
Expand Down Expand Up @@ -198,6 +198,20 @@
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="perfMapPath">
<property name="text">
<string>Custom perf-$pid.map directory:</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="KUrlRequester" name="lineEditPerfMapPath">
<property name="mode">
<set>KFile::Directory|KFile::ExistingOnly|KFile::LocalOnly</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
Expand Down