Skip to content

Commit 90451a7

Browse files
GitMenschmilianw
authored andcommitted
feat: allow handling of compressed perfparser files
all of the code was in place but checking for perfparser format used the original filename instead the temporary (unpacked) one
1 parent b0d370f commit 90451a7

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

src/mainwindow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ void MainWindow::closeEvent(QCloseEvent* event)
286286

287287
QString MainWindow::queryOpenDataFile()
288288
{
289-
const auto filter = tr("Hotspot data Files (perf*.data perf.data.* *.perfparser);;"
289+
const auto filter = tr("Hotspot data Files (perf*.data perf.data.* *.perfparser *.perfparser.*);;"
290290
"Linux Perf Files (perf*.data perf.data.*);;"
291-
"Perfparser Files (*.perfparser);;"
291+
"Perfparser Files (*.perfparser *.perfparser.*);;"
292292
"All Files (*)");
293293
return QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath(), filter);
294294
}

src/parsers/perf/perfparser.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,8 +1585,8 @@ void PerfParser::startParseFile(const QString& path)
15851585

15861586
emit parsingStarted();
15871587
using namespace ThreadWeaver;
1588-
stream() << make_job([path, parserBinary = m_parserBinary, parserArgs = m_parserArgs, debuginfodUrls,
1589-
costAggregation, this]() {
1588+
stream() << make_job([origPath = path, path = m_parserArgs[1], parserBinary = m_parserBinary,
1589+
parserArgs = m_parserArgs, debuginfodUrls, costAggregation, this]() {
15901590
PerfParserPrivate d(costAggregation);
15911591
connect(&d, &PerfParserPrivate::progress, this, &PerfParser::progress);
15921592
connect(&d, &PerfParserPrivate::debugInfoDownloadProgress, this, &PerfParser::debugInfoDownloadProgress);
@@ -1622,7 +1622,8 @@ void PerfParser::startParseFile(const QString& path)
16221622
while (!file.atEnd() && !d.stopRequested) {
16231623
if (!d.tryParse()) {
16241624
// TODO: provide reason
1625-
emit parsingFailed(tr("Failed to parse file %1: %2").arg(path, QStringLiteral("Unknown reason")));
1625+
emit parsingFailed(
1626+
tr("Failed to parse file %1: %2").arg(origPath, QStringLiteral("Unknown reason")));
16261627
return;
16271628
}
16281629
}
130 Bytes
Binary file not shown.
1020 Bytes
Binary file not shown.

tests/integrationtests/tst_perfparser.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ private slots:
234234

235235
const auto perfData = QFINDTESTDATA("file_content/true.perfparser");
236236
QTest::addRow("pre-exported perfparser") << perfData << QString();
237+
#if KFArchive_FOUND
238+
QTest::addRow("perfparser, xzipped") << QFINDTESTDATA("file_content/true.perfparser.xz") << QString();
239+
#endif
237240
const auto perfDataSomeName = QStringLiteral("fruitper");
238241
QFile::copy(perfData, perfDataSomeName); // we can ignore errors (file exist) here
239242
QTest::addRow("pre-exported perfparser \"bad extension\"") << perfDataSomeName << QString();
@@ -244,6 +247,8 @@ private slots:
244247
QTest::addRow("PERF v2") << QFINDTESTDATA("file_content/perf.data.true.v2") << QString();
245248
#if KFArchive_FOUND
246249
QTest::addRow("PERF v2, gzipped") << QFINDTESTDATA("file_content/perf.data.true.v2.gz") << QString();
250+
QTest::addRow("no expected magic header, gzipped")
251+
<< QFINDTESTDATA("file_content/perf.data.broken.gz") << QStringLiteral("File format unknown");
247252
#endif
248253
}
249254

0 commit comments

Comments
 (0)