Skip to content

Commit

Permalink
feat: allow handling of compressed perfparser files
Browse files Browse the repository at this point in the history
all of the code was in place but checking for perfparser format used the original filename instead the temporary (unpacked) one
  • Loading branch information
GitMensch authored and milianw committed Oct 7, 2024
1 parent b0d370f commit 90451a7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ void MainWindow::closeEvent(QCloseEvent* event)

QString MainWindow::queryOpenDataFile()
{
const auto filter = tr("Hotspot data Files (perf*.data perf.data.* *.perfparser);;"
const auto filter = tr("Hotspot data Files (perf*.data perf.data.* *.perfparser *.perfparser.*);;"
"Linux Perf Files (perf*.data perf.data.*);;"
"Perfparser Files (*.perfparser);;"
"Perfparser Files (*.perfparser *.perfparser.*);;"
"All Files (*)");
return QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath(), filter);
}
Expand Down
7 changes: 4 additions & 3 deletions src/parsers/perf/perfparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1585,8 +1585,8 @@ void PerfParser::startParseFile(const QString& path)

emit parsingStarted();
using namespace ThreadWeaver;
stream() << make_job([path, parserBinary = m_parserBinary, parserArgs = m_parserArgs, debuginfodUrls,
costAggregation, this]() {
stream() << make_job([origPath = path, path = m_parserArgs[1], parserBinary = m_parserBinary,
parserArgs = m_parserArgs, debuginfodUrls, costAggregation, this]() {
PerfParserPrivate d(costAggregation);
connect(&d, &PerfParserPrivate::progress, this, &PerfParser::progress);
connect(&d, &PerfParserPrivate::debugInfoDownloadProgress, this, &PerfParser::debugInfoDownloadProgress);
Expand Down Expand Up @@ -1622,7 +1622,8 @@ void PerfParser::startParseFile(const QString& path)
while (!file.atEnd() && !d.stopRequested) {
if (!d.tryParse()) {
// TODO: provide reason
emit parsingFailed(tr("Failed to parse file %1: %2").arg(path, QStringLiteral("Unknown reason")));
emit parsingFailed(
tr("Failed to parse file %1: %2").arg(origPath, QStringLiteral("Unknown reason")));
return;
}
}
Expand Down
Binary file not shown.
Binary file added tests/integrationtests/file_content/true.perfparser.xz
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/integrationtests/tst_perfparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ private slots:

const auto perfData = QFINDTESTDATA("file_content/true.perfparser");
QTest::addRow("pre-exported perfparser") << perfData << QString();
#if KFArchive_FOUND
QTest::addRow("perfparser, xzipped") << QFINDTESTDATA("file_content/true.perfparser.xz") << QString();
#endif
const auto perfDataSomeName = QStringLiteral("fruitper");
QFile::copy(perfData, perfDataSomeName); // we can ignore errors (file exist) here
QTest::addRow("pre-exported perfparser \"bad extension\"") << perfDataSomeName << QString();
Expand All @@ -244,6 +247,8 @@ private slots:
QTest::addRow("PERF v2") << QFINDTESTDATA("file_content/perf.data.true.v2") << QString();
#if KFArchive_FOUND
QTest::addRow("PERF v2, gzipped") << QFINDTESTDATA("file_content/perf.data.true.v2.gz") << QString();
QTest::addRow("no expected magic header, gzipped")
<< QFINDTESTDATA("file_content/perf.data.broken.gz") << QStringLiteral("File format unknown");
#endif
}

Expand Down

0 comments on commit 90451a7

Please sign in to comment.