diff --git a/src/parsers/perf/perfparser.cpp b/src/parsers/perf/perfparser.cpp index f5efdd569..a67a25814 100644 --- a/src/parsers/perf/perfparser.cpp +++ b/src/parsers/perf/perfparser.cpp @@ -1583,16 +1583,18 @@ void PerfParser::startParseFile(const QString& path) emit parsingFinished(); }; - if (path.endsWith(QLatin1String(".perfparser"))) { - QFile file(path); - if (!file.open(QIODevice::ReadOnly)) { - emit parsingFailed(tr("Failed to open file %1: %2").arg(path, file.errorString())); - return; - } + QFile file(path); + if (!file.open(QIODevice::ReadOnly)) { + emit parsingFailed(tr("Failed to open file %1: %2").arg(path, file.errorString())); + return; + } + + if (file.peek(11) == "QPERFSTREAM") { d.setInput(&file); while (!file.atEnd() && !d.stopRequested) { if (!d.tryParse()) { - emit parsingFailed(tr("Failed to parse file")); + // TODO: provide reason + emit parsingFailed(tr("Failed to parse file %1: %2").arg(path, QStringLiteral("unknown reason"))); return; } } @@ -1600,6 +1602,16 @@ void PerfParser::startParseFile(const QString& path) return; } + if (file.peek(8) == "PERFFILE") { + emit parsingFailed(tr("Failed to parse file %1: %2").arg(path, tr("we don't support V1 perf data"))); + return; + } + + if (file.peek(8) != "PERFILE2") { + emit parsingFailed(tr("Failed to parse file %1: %2").arg(path, tr("File format unknown"))); + return; + } + QProcess process; process.setProcessEnvironment(perfparserEnvironment(debuginfodUrls)); process.setProcessChannelMode(QProcess::ForwardedErrorChannel);