diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2017-04-13 16:37:26 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2017-04-28 10:19:05 +0000 |
commit | fb27768c3aef57c00a5bd7d8948ae7ef21c92046 (patch) | |
tree | 66b753d9a08c72e2c424b18511f50691d42ac641 | |
parent | 94de6084841143a9dc1be3202ad5900c9a5c90c1 (diff) |
Use platform-specific path conventions
On windows we want backslashes as directory separators and semicolons as
path separators.
Change-Id: I4feaf4864ddd5c1ddaf7d60a5e8f2de3319af8ef
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
-rw-r--r-- | app/main.cpp | 22 | ||||
-rw-r--r-- | app/perfsymboltable.cpp | 9 | ||||
-rw-r--r-- | app/perfunwind.cpp | 7 |
3 files changed, 21 insertions, 17 deletions
diff --git a/app/main.cpp b/app/main.cpp index 5a6023a..7cdc22d 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -105,20 +105,22 @@ int main(int argc, char *argv[]) QCommandLineOption sysroot(QLatin1String("sysroot"), QCoreApplication::translate( - "main", "Look for system libraries in <path> (default: /)."), + "main", "Look for system libraries in <path> (default: %1).") + .arg(QDir::rootPath()), QLatin1String("path"), - QLatin1String("/")); + QDir::rootPath()); parser.addOption(sysroot); + const auto defaultDebug = QString::fromLatin1("%1usr%1lib%1debug%2%3%1.debug%2.debug") + .arg(QDir::separator(), QDir::listSeparator(), QDir::homePath()); QCommandLineOption debug(QLatin1String("debug"), QCoreApplication::translate( "main", "Look for debug information in <path>. " "You can specify multiple paths separated by ':'. " "Relative paths are relative to the original file's path. " - "The default is: <sysroot>/usr/lib/debug:~/.debug:.debug ."), - QLatin1String("path"), - QString("/usr/lib/debug:%1/.debug:.debug").arg(QDir::homePath())); + "The default is: <sysroot>%1 .").arg(defaultDebug), + QLatin1String("path"), defaultDebug); parser.addOption(debug); QCommandLineOption extra(QLatin1String("extra"), @@ -145,12 +147,12 @@ int main(int argc, char *argv[]) defaultArch); parser.addOption(arch); + const auto defaultKallsyms = QString::fromLatin1("%1proc%1kallsyms").arg(QDir::separator()); QCommandLineOption kallsymsPath(QLatin1String("kallsyms"), - QCoreApplication::translate( - "main", "Path to kallsyms mapping to resolve kernel symbols. " - "The default is: <sysroot>/proc/kallsyms ."), - QLatin1String("path"), - QLatin1String("/proc/kallsyms")); + QCoreApplication::translate( + "main", "Path to kallsyms mapping to resolve kernel " + "symbols. The default is: <sysroot>%1 .") + .arg(defaultKallsyms), QLatin1String("path"), defaultKallsyms); parser.addOption(kallsymsPath); QCommandLineOption printStats(QLatin1String("print-stats"), diff --git a/app/perfsymboltable.cpp b/app/perfsymboltable.cpp index 14b2e09..a448f96 100644 --- a/app/perfsymboltable.cpp +++ b/app/perfsymboltable.cpp @@ -36,7 +36,8 @@ #endif PerfSymbolTable::PerfSymbolTable(quint32 pid, Dwfl_Callbacks *callbacks, PerfUnwind *parent) : - m_perfMapFile(QString::fromLatin1("/tmp/perf-%1.map").arg(pid)), + m_perfMapFile(QDir::tempPath() + QDir::separator() + + QString::fromLatin1("perf-%1.map").arg(pid)), m_cacheIsDirty(false), m_unwind(parent), m_firstElf(nullptr), @@ -215,7 +216,7 @@ static bool findBuildIdPath(QFileInfo &path, const QString &fileName) static QStringList splitPath(const QString &path) { - return path.split(QLatin1Char(':'), QString::SkipEmptyParts); + return path.split(QDir::listSeparator(), QString::SkipEmptyParts); } void PerfSymbolTable::registerElf(const PerfRecordMmap &mmap, const QByteArray &buildId, @@ -234,8 +235,8 @@ void PerfSymbolTable::registerElf(const PerfRecordMmap &mmap, const QByteArray & bool found = false; // first try to find the debug information via build id, if available if (!buildId.isEmpty()) { - const QString buildIdPath = QString::fromUtf8(mmap.filename() + '/' - + buildId.toHex()); + const QString buildIdPath = QString::fromUtf8(mmap.filename()) + QDir::separator() + + QString::fromUtf8(buildId.toHex()); foreach (const QString &extraPath, splitPath(debugInfoPath)) { fullPath.setFile(extraPath); if (findBuildIdPath(fullPath, buildIdPath)) { diff --git a/app/perfunwind.cpp b/app/perfunwind.cpp index 0878dbb..9c84811 100644 --- a/app/perfunwind.cpp +++ b/app/perfunwind.cpp @@ -25,6 +25,7 @@ #include <QDebug> #include <QtEndian> #include <QVersionNumber> +#include <QDir> #include <cstring> @@ -88,9 +89,9 @@ PerfUnwind::PerfUnwind(QIODevice *output, const QString &systemRoot, const QStri m_offlineCallbacks.find_elf = dwfl_build_id_find_elf; m_offlineCallbacks.find_debuginfo = dwfl_standard_find_debuginfo; m_offlineCallbacks.section_address = dwfl_offline_section_address; - const QChar colon = QLatin1Char(':'); - QByteArray newDebugInfo = (colon + debugPath + colon + appPath + colon + extraLibsPath + colon - + systemRoot).toUtf8(); + const QChar separator = QDir::listSeparator(); + QByteArray newDebugInfo = (separator + debugPath + separator + appPath + separator + + extraLibsPath + separator + systemRoot).toUtf8(); m_debugInfoPath = new char[newDebugInfo.length() + 1]; m_debugInfoPath[newDebugInfo.length()] = 0; std::memcpy(m_debugInfoPath, newDebugInfo.data(), newDebugInfo.length()); |