From c08322900fe3b20152feb831cd8500e3dce7bfc2 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 14 Mar 2023 08:27:50 +0100 Subject: [PATCH] Debugger: Use more FilePaths in module handling interface Change-Id: Ie058b928900015d0f71776151547bf7ba32a62bf Reviewed-by: David Schulz Reviewed-by: --- src/plugins/debugger/cdb/cdbengine.cpp | 5 +++-- src/plugins/debugger/cdb/cdbengine.h | 4 ++-- src/plugins/debugger/debuggerengine.cpp | 18 +++++++++--------- src/plugins/debugger/debuggerengine.h | 10 +++++----- src/plugins/debugger/gdb/gdbengine.cpp | 18 +++++++++--------- src/plugins/debugger/gdb/gdbengine.h | 8 ++++---- src/plugins/debugger/lldb/lldbengine.cpp | 10 +++++----- src/plugins/debugger/lldb/lldbengine.h | 4 ++-- src/plugins/debugger/pdb/pdbengine.cpp | 8 ++++---- src/plugins/debugger/pdb/pdbengine.h | 4 ++-- src/plugins/debugger/qml/qmlengine.cpp | 4 ++-- src/plugins/debugger/qml/qmlengine.h | 4 ++-- 12 files changed, 49 insertions(+), 48 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 450d36b8f04..8400eee7510 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -1441,15 +1441,16 @@ void CdbEngine::reloadModules() runCommand({"modules", ExtensionCommand, CB(handleModules)}); } -void CdbEngine::loadSymbols(const QString & /* moduleName */) +void CdbEngine::loadSymbols(const FilePath &moduleName) { + Q_UNUSED(moduleName) } void CdbEngine::loadAllSymbols() { } -void CdbEngine::requestModuleSymbols(const QString &moduleName) +void CdbEngine::requestModuleSymbols(const FilePath &moduleName) { Q_UNUSED(moduleName) } diff --git a/src/plugins/debugger/cdb/cdbengine.h b/src/plugins/debugger/cdb/cdbengine.h index 3bea692d5b5..a231ce39c23 100644 --- a/src/plugins/debugger/cdb/cdbengine.h +++ b/src/plugins/debugger/cdb/cdbengine.h @@ -65,9 +65,9 @@ public: void changeMemory(MemoryAgent *, quint64 addr, const QByteArray &data) override; void reloadModules() override; - void loadSymbols(const QString &moduleName) override; + void loadSymbols(const Utils::FilePath &moduleName) override; void loadAllSymbols() override; - void requestModuleSymbols(const QString &moduleName) override; + void requestModuleSymbols(const Utils::FilePath &moduleName) override; void reloadRegisters() override; void reloadSourceFiles() override; diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index a9609584c6e..5a465e2798b 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -2083,7 +2083,7 @@ void DebuggerEngine::examineModules() { } -void DebuggerEngine::loadSymbols(const QString &) +void DebuggerEngine::loadSymbols(const FilePath &) { } @@ -2095,11 +2095,11 @@ void DebuggerEngine::loadSymbolsForStack() { } -void DebuggerEngine::requestModuleSymbols(const QString &) +void DebuggerEngine::requestModuleSymbols(const FilePath &) { } -void DebuggerEngine::requestModuleSections(const QString &) +void DebuggerEngine::requestModuleSections(const FilePath &) { } @@ -2652,7 +2652,7 @@ static void createNewDock(QWidget *widget) dockWidget->show(); } -void DebuggerEngine::showModuleSymbols(const QString &moduleName, const Symbols &symbols) +void DebuggerEngine::showModuleSymbols(const FilePath &moduleName, const Symbols &symbols) { auto w = new QTreeWidget; w->setUniformRowHeights(true); @@ -2660,7 +2660,7 @@ void DebuggerEngine::showModuleSymbols(const QString &moduleName, const Symbols w->setRootIsDecorated(false); w->setAlternatingRowColors(true); w->setSortingEnabled(true); - w->setObjectName("Symbols." + moduleName); + w->setObjectName("Symbols." + moduleName.toFSPathString()); QStringList header; header.append(Tr::tr("Symbol")); header.append(Tr::tr("Address")); @@ -2668,7 +2668,7 @@ void DebuggerEngine::showModuleSymbols(const QString &moduleName, const Symbols header.append(Tr::tr("Section")); header.append(Tr::tr("Name")); w->setHeaderLabels(header); - w->setWindowTitle(Tr::tr("Symbols in \"%1\"").arg(moduleName)); + w->setWindowTitle(Tr::tr("Symbols in \"%1\"").arg(moduleName.toUserOutput())); for (const Symbol &s : symbols) { auto it = new QTreeWidgetItem; it->setData(0, Qt::DisplayRole, s.name); @@ -2681,7 +2681,7 @@ void DebuggerEngine::showModuleSymbols(const QString &moduleName, const Symbols createNewDock(w); } -void DebuggerEngine::showModuleSections(const QString &moduleName, const Sections §ions) +void DebuggerEngine::showModuleSections(const FilePath &moduleName, const Sections §ions) { auto w = new QTreeWidget; w->setUniformRowHeights(true); @@ -2689,7 +2689,7 @@ void DebuggerEngine::showModuleSections(const QString &moduleName, const Section w->setRootIsDecorated(false); w->setAlternatingRowColors(true); w->setSortingEnabled(true); - w->setObjectName("Sections." + moduleName); + w->setObjectName("Sections." + moduleName.toFSPathString()); QStringList header; header.append(Tr::tr("Name")); header.append(Tr::tr("From")); @@ -2697,7 +2697,7 @@ void DebuggerEngine::showModuleSections(const QString &moduleName, const Section header.append(Tr::tr("Address")); header.append(Tr::tr("Flags")); w->setHeaderLabels(header); - w->setWindowTitle(Tr::tr("Sections in \"%1\"").arg(moduleName)); + w->setWindowTitle(Tr::tr("Sections in \"%1\"").arg(moduleName.toUserOutput())); for (const Section &s : sections) { auto it = new QTreeWidgetItem; it->setData(0, Qt::DisplayRole, s.name); diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index 422d4eb788c..c07ce656da8 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -303,11 +303,11 @@ public: virtual void reloadModules(); virtual void examineModules(); - virtual void loadSymbols(const QString &moduleName); + virtual void loadSymbols(const Utils::FilePath &moduleName); virtual void loadSymbolsForStack(); virtual void loadAllSymbols(); - virtual void requestModuleSymbols(const QString &moduleName); - virtual void requestModuleSections(const QString &moduleName); + virtual void requestModuleSymbols(const Utils::FilePath &moduleName); + virtual void requestModuleSections(const Utils::FilePath &moduleName); virtual void reloadRegisters(); virtual void reloadPeripheralRegisters(); @@ -452,8 +452,8 @@ public: void openMemoryEditor(); - static void showModuleSymbols(const QString &moduleName, const QVector &symbols); - static void showModuleSections(const QString &moduleName, const QVector
§ions); + static void showModuleSymbols(const Utils::FilePath &moduleName, const QVector &symbols); + static void showModuleSections(const Utils::FilePath &moduleName, const QVector
§ions); void handleExecDetach(); void handleExecContinue(); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index de3c075fe3f..bf9647e2203 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -2783,10 +2783,10 @@ static QString dotEscape(QString str) return str; } -void GdbEngine::loadSymbols(const QString &modulePath) +void GdbEngine::loadSymbols(const FilePath &modulePath) { // FIXME: gdb does not understand quoted names here (tested with 6.8) - runCommand({"sharedlibrary " + dotEscape(modulePath)}); + runCommand({"sharedlibrary " + dotEscape(modulePath.path())}); reloadModulesInternal(); reloadStack(); updateLocals(); @@ -2824,7 +2824,7 @@ void GdbEngine::loadSymbolsForStack() } static void handleShowModuleSymbols(const DebuggerResponse &response, - const QString &modulePath, const QString &fileName) + const FilePath &modulePath, const QString &fileName) { if (response.resultClass == ResultDone) { Symbols symbols; @@ -2883,21 +2883,21 @@ static void handleShowModuleSymbols(const DebuggerResponse &response, } } -void GdbEngine::requestModuleSymbols(const QString &modulePath) +void GdbEngine::requestModuleSymbols(const FilePath &modulePath) { - Utils::TemporaryFile tf("gdbsymbols"); + TemporaryFile tf("gdbsymbols"); if (!tf.open()) return; QString fileName = tf.fileName(); tf.close(); - DebuggerCommand cmd("maint print msymbols \"" + fileName + "\" " + modulePath, NeedsTemporaryStop); + DebuggerCommand cmd("maint print msymbols \"" + fileName + "\" " + modulePath.path(), NeedsTemporaryStop); cmd.callback = [modulePath, fileName](const DebuggerResponse &r) { handleShowModuleSymbols(r, modulePath, fileName); }; runCommand(cmd); } -void GdbEngine::requestModuleSections(const QString &moduleName) +void GdbEngine::requestModuleSections(const FilePath &moduleName) { // There seems to be no way to get the symbols from a single .so. DebuggerCommand cmd("maint info section ALLOBJ", NeedsTemporaryStop); @@ -2908,14 +2908,14 @@ void GdbEngine::requestModuleSections(const QString &moduleName) } void GdbEngine::handleShowModuleSections(const DebuggerResponse &response, - const QString &moduleName) + const FilePath &moduleName) { // ~" Object file: /usr/lib/i386-linux-gnu/libffi.so.6\n" // ~" 0xb44a6114->0xb44a6138 at 0x00000114: .note.gnu.build-id ALLOC LOAD READONLY DATA HAS_CONTENTS\n" if (response.resultClass == ResultDone) { const QStringList lines = response.consoleStreamOutput.split('\n'); const QString prefix = " Object file: "; - const QString needle = prefix + moduleName; + const QString needle = prefix + moduleName.path(); Sections sections; bool active = false; for (const QString &line : std::as_const(lines)) { diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index cd3a21ffbde..9fac0347eb3 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -216,17 +216,17 @@ private: ////////// General Interface ////////// // // Modules specific stuff // - void loadSymbols(const QString &moduleName) final; + void loadSymbols(const Utils::FilePath &moduleName) final; void loadAllSymbols() final; void loadSymbolsForStack() final; - void requestModuleSymbols(const QString &moduleName) final; - void requestModuleSections(const QString &moduleName) final; + void requestModuleSymbols(const Utils::FilePath &moduleName) final; + void requestModuleSections(const Utils::FilePath &moduleName) final; void reloadModules() final; void examineModules() final; void reloadModulesInternal(); void handleModulesList(const DebuggerResponse &response); - void handleShowModuleSections(const DebuggerResponse &response, const QString &moduleName); + void handleShowModuleSections(const DebuggerResponse &response, const Utils::FilePath &moduleName); // // Snapshot specific stuff diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 5de46911576..8912375477c 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -630,7 +630,7 @@ void LldbEngine::handleInterpreterBreakpointModified(const GdbMi &bpItem) updateBreakpointData(bp, bpItem, false); } -void LldbEngine::loadSymbols(const QString &moduleName) +void LldbEngine::loadSymbols(const FilePath &moduleName) { Q_UNUSED(moduleName) } @@ -660,13 +660,13 @@ void LldbEngine::reloadModules() runCommand(cmd); } -void LldbEngine::requestModuleSymbols(const QString &moduleName) +void LldbEngine::requestModuleSymbols(const FilePath &moduleName) { DebuggerCommand cmd("fetchSymbols"); - cmd.arg("module", moduleName); + cmd.arg("module", moduleName.path()); cmd.callback = [moduleName](const DebuggerResponse &response) { const GdbMi &symbols = response.data["symbols"]; - QString moduleName = response.data["module"].data(); + const QString module = response.data["module"].data(); Symbols syms; for (const GdbMi &item : symbols) { Symbol symbol; @@ -677,7 +677,7 @@ void LldbEngine::requestModuleSymbols(const QString &moduleName) symbol.demangled = item["demangled"].data(); syms.append(symbol); } - showModuleSymbols(moduleName, syms); + showModuleSymbols(moduleName.withNewPath(module), syms); }; runCommand(cmd); } diff --git a/src/plugins/debugger/lldb/lldbengine.h b/src/plugins/debugger/lldb/lldbengine.h index 0a0d9adfb55..8c0396ba509 100644 --- a/src/plugins/debugger/lldb/lldbengine.h +++ b/src/plugins/debugger/lldb/lldbengine.h @@ -68,9 +68,9 @@ private: void assignValueInDebugger(WatchItem *item, const QString &expr, const QVariant &value) override; void executeDebuggerCommand(const QString &command) override; - void loadSymbols(const QString &moduleName) override; + void loadSymbols(const Utils::FilePath &moduleName) override; void loadAllSymbols() override; - void requestModuleSymbols(const QString &moduleName) override; + void requestModuleSymbols(const Utils::FilePath &moduleName) override; void reloadModules() override; void reloadRegisters() override; void reloadSourceFiles() override {} diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index fd749a2d0ce..a8766691147 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -263,7 +263,7 @@ void PdbEngine::removeBreakpoint(const Breakpoint &bp) notifyBreakpointRemoveOk(bp); } -void PdbEngine::loadSymbols(const QString &moduleName) +void PdbEngine::loadSymbols(const FilePath &moduleName) { Q_UNUSED(moduleName) } @@ -300,10 +300,10 @@ void PdbEngine::refreshModules(const GdbMi &modules) handler->endUpdateAll(); } -void PdbEngine::requestModuleSymbols(const QString &moduleName) +void PdbEngine::requestModuleSymbols(const FilePath &moduleName) { DebuggerCommand cmd("listSymbols"); - cmd.arg("module", moduleName); + cmd.arg("module", moduleName.path()); runCommand(cmd); } @@ -341,7 +341,7 @@ void PdbEngine::refreshSymbols(const GdbMi &symbols) symbol.name = item["name"].data(); syms.append(symbol); } - showModuleSymbols(moduleName, syms); + showModuleSymbols(runParameters().inferior.command.executable().withNewPath(moduleName), syms); } bool PdbEngine::canHandleToolTip(const DebuggerToolTipContext &) const diff --git a/src/plugins/debugger/pdb/pdbengine.h b/src/plugins/debugger/pdb/pdbengine.h index d65f0e33b1c..c4003884578 100644 --- a/src/plugins/debugger/pdb/pdbengine.h +++ b/src/plugins/debugger/pdb/pdbengine.h @@ -52,9 +52,9 @@ private: const QString &expr, const QVariant &value) override; void executeDebuggerCommand(const QString &command) override; - void loadSymbols(const QString &moduleName) override; + void loadSymbols(const Utils::FilePath &moduleName) override; void loadAllSymbols() override; - void requestModuleSymbols(const QString &moduleName) override; + void requestModuleSymbols(const Utils::FilePath &moduleName) override; void reloadModules() override; void reloadRegisters() override {} void reloadSourceFiles() override {} diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index c0cf98cfb4a..eb1ebc939a8 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -736,7 +736,7 @@ bool QmlEngine::acceptsBreakpoint(const BreakpointParameters &bp) const return bp.isQmlFileAndLineBreakpoint(); } -void QmlEngine::loadSymbols(const QString &moduleName) +void QmlEngine::loadSymbols(const FilePath &moduleName) { Q_UNUSED(moduleName) } @@ -759,7 +759,7 @@ void QmlEngine::updateAll() d->updateLocals(); } -void QmlEngine::requestModuleSymbols(const QString &moduleName) +void QmlEngine::requestModuleSymbols(const FilePath &moduleName) { Q_UNUSED(moduleName) } diff --git a/src/plugins/debugger/qml/qmlengine.h b/src/plugins/debugger/qml/qmlengine.h index 331176d4269..bfdc9bfb005 100644 --- a/src/plugins/debugger/qml/qmlengine.h +++ b/src/plugins/debugger/qml/qmlengine.h @@ -75,9 +75,9 @@ private: void assignValueInDebugger(WatchItem *item, const QString &expr, const QVariant &value) override; - void loadSymbols(const QString &moduleName) override; + void loadSymbols(const Utils::FilePath &moduleName) override; void loadAllSymbols() override; - void requestModuleSymbols(const QString &moduleName) override; + void requestModuleSymbols(const Utils::FilePath &moduleName) override; void reloadModules() override; void reloadRegisters() override {} void reloadSourceFiles() override;