From ab22c8582c9edec450a30edf316b078cfb10b09f Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Sun, 4 Dec 2022 20:52:45 +0100 Subject: Fix compile with QStringBuilder Change-Id: I66c034497e23d9a92d779c9ade85e51d49b71fa9 Reviewed-by: Ulf Hermann Reviewed-by: Milian Wolff --- CMakeLists.txt | 1 + app/perfsymboltable.cpp | 4 ++-- tests/auto/perfdata/tst_perfdata.cpp | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0684030..c7f3ad6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,5 +26,6 @@ include(CheckSymbolExists) set(CMAKE_REQUIRED_LIBRARIES elfutils::dw elfutils::elf) check_symbol_exists(dwfl_get_debuginfod_client "libdwfl.h" HAVE_DWFL_GET_DEBUGINFOD_CLIENT) +add_definitions(-DQT_USE_QSTRINGBUILDER) add_subdirectory(app) add_subdirectory(tests) diff --git a/app/perfsymboltable.cpp b/app/perfsymboltable.cpp index 4fbc6bb..bdadf0c 100644 --- a/app/perfsymboltable.cpp +++ b/app/perfsymboltable.cpp @@ -366,12 +366,12 @@ static QFileInfo findDebugInfoFile(const QString &root, const QString &file, // try again in /usr/lib/debug folder // some distros use for example /usr/lib/debug/lib (ubuntu) and some use /usr/lib/debug/usr/lib (fedora) - const auto usr = QDir::separator() + QLatin1String("usr") + QDir::separator(); + const auto usr = QString(QDir::separator() + QLatin1String("usr") + QDir::separator()); auto folderWithoutUsr = folder; folderWithoutUsr.replace(usr, QDir::separator()); // make sure both (/usr/ and /) are searched - for (const auto& path : {folderWithoutUsr, usr + folderWithoutUsr}) { + for (const auto& path : {folderWithoutUsr, QString(usr + folderWithoutUsr)}) { debugLinkFile.setFile(dir.path() + QDir::separator() + QLatin1String("usr") + QDir::separator() + QLatin1String("lib") + QDir::separator() + QLatin1String("debug") + QDir::separator() + path + QDir::separator() + debugLinkString); diff --git a/tests/auto/perfdata/tst_perfdata.cpp b/tests/auto/perfdata/tst_perfdata.cpp index d0706c9..8d65e7d 100644 --- a/tests/auto/perfdata/tst_perfdata.cpp +++ b/tests/auto/perfdata/tst_perfdata.cpp @@ -282,9 +282,9 @@ void TestPerfData::testFiles() const auto perfDataFile = QFINDTESTDATA(dataFile); QVERIFY(!perfDataFile.isEmpty() && QFile::exists(perfDataFile)); - const auto expectedOutputFileCompressed = perfDataFile + ".expected.txt.zlib"; - const auto expectedOutputFileUncompressed = perfDataFile + ".expected.txt"; - const auto actualOutputFile = perfDataFile + ".actual.txt"; + const auto expectedOutputFileCompressed = QString(perfDataFile + ".expected.txt.zlib"); + const auto expectedOutputFileUncompressed = QString(perfDataFile + ".expected.txt"); + const auto actualOutputFile = QString(perfDataFile + ".actual.txt"); QBuffer output; QVERIFY(output.open(QIODevice::WriteOnly)); -- cgit v1.2.3 From 0e9d09e73279d0e1d9052810b1aea4fcc7915a72 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 5 Dec 2022 10:04:36 +0100 Subject: Make findDebugInfoFile() accessible from the test If it's static in perfsymboltable.cpp's file scope, we cannot use it from anywhere else. Change-Id: I60ac203120b7c88feff2acb26b224a8761469bf8 Reviewed-by: Milian Wolff --- app/perfsymboltable.cpp | 5 +++-- app/perfsymboltable.h | 3 +++ tests/auto/finddebugsym/tst_finddebugsym.cpp | 5 ++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/perfsymboltable.cpp b/app/perfsymboltable.cpp index bdadf0c..e3737d5 100644 --- a/app/perfsymboltable.cpp +++ b/app/perfsymboltable.cpp @@ -343,8 +343,9 @@ Dwfl_Module *PerfSymbolTable::module(quint64 addr, const PerfElfMap::ElfInfo &el return reportElf(elf); } -static QFileInfo findDebugInfoFile(const QString &root, const QString &file, - const QString &debugLinkString) +QFileInfo PerfSymbolTable::findDebugInfoFile( + const QString &root, const QString &file, + const QString &debugLinkString) { auto dir = QFileInfo(root).dir(); const auto folder = QFileInfo(file).path(); diff --git a/app/perfsymboltable.h b/app/perfsymboltable.h index 366c9f5..27ba205 100644 --- a/app/perfsymboltable.h +++ b/app/perfsymboltable.h @@ -44,6 +44,9 @@ public: PerfSymbolTable(qint32 pid, Dwfl_Callbacks *callbacks, PerfUnwind *parent); ~PerfSymbolTable(); + static QFileInfo findDebugInfoFile( + const QString& root, const QString& file, const QString& debugLinkString); + struct PerfMapSymbol { PerfMapSymbol(quint64 start = 0, quint64 length = 0, QByteArray name = QByteArray()) : start(start), length(length), name(name) {} diff --git a/tests/auto/finddebugsym/tst_finddebugsym.cpp b/tests/auto/finddebugsym/tst_finddebugsym.cpp index c298749..fb45852 100644 --- a/tests/auto/finddebugsym/tst_finddebugsym.cpp +++ b/tests/auto/finddebugsym/tst_finddebugsym.cpp @@ -29,8 +29,6 @@ #include "perfsymboltable.h" -QFileInfo findDebugInfoFile(const QString& root, const QString& file, const QString& debugLinkString); - class TestFindDebugSymbols : public QObject { Q_OBJECT @@ -86,7 +84,8 @@ private slots: QFETCH(QString, file); QFETCH(QString, debugLinkString); - auto debugFile = findDebugInfoFile(tempDir.path() + QDir::separator(), root, file); + auto debugFile = PerfSymbolTable::findDebugInfoFile( + tempDir.path() + QDir::separator(), root, file); QCOMPARE(debugFile.absoluteFilePath(), QFileInfo(tempDir.path() + debugLinkString).absoluteFilePath()); } -- cgit v1.2.3