diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 8400eee7510..ed7e0da9c82 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -1488,12 +1488,13 @@ void CdbEngine::handleModules(const DebuggerResponse &response) { if (response.resultClass == ResultDone) { if (response.data.type() == GdbMi::List) { + const FilePath inferior = runParameters().inferior.command.executable(); ModulesHandler *handler = modulesHandler(); handler->beginUpdateAll(); for (const GdbMi &gdbmiModule : response.data) { Module module; module.moduleName = gdbmiModule["name"].data(); - module.modulePath = gdbmiModule["image"].data(); + module.modulePath = inferior.withNewPath(gdbmiModule["image"].data()); module.startAddress = gdbmiModule["start"].data().toULongLong(nullptr, 0); module.endAddress = gdbmiModule["end"].data().toULongLong(nullptr, 0); if (gdbmiModule["deferred"].type() == GdbMi::Invalid) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index bf9647e2203..095e46f1770 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -470,7 +470,8 @@ void GdbEngine::handleAsyncOutput(const QStringView asyncClass, const GdbMi &res module.startAddress = 0; module.endAddress = 0; module.hostPath = result["host-name"].data(); - module.modulePath = result["target-name"].data(); + const QString target = result["target-name"].data(); + module.modulePath = runParameters().inferior.command.executable().withNewPath(target); module.moduleName = QFileInfo(module.hostPath).baseName(); modulesHandler()->updateModule(module); } else if (asyncClass == u"library-unloaded") { @@ -478,7 +479,8 @@ void GdbEngine::handleAsyncOutput(const QStringView asyncClass, const GdbMi &res // target-name="/usr/lib/libdrm.so.2", // host-name="/usr/lib/libdrm.so.2" QString id = result["id"].data(); - modulesHandler()->removeModule(result["target-name"].data()); + const QString target = result["target-name"].data(); + modulesHandler()->removeModule(runParameters().inferior.command.executable().withNewPath(target)); progressPing(); showStatusMessage(Tr::tr("Library %1 unloaded.").arg(id), 1000); } else if (asyncClass == u"thread-group-added") { @@ -2811,7 +2813,7 @@ void GdbEngine::loadSymbolsForStack() for (const Module &module : modules) { if (module.startAddress <= frame.address && frame.address < module.endAddress) { - runCommand({"sharedlibrary " + dotEscape(module.modulePath)}); + runCommand({"sharedlibrary " + dotEscape(module.modulePath.path())}); needUpdate = true; } } @@ -2956,11 +2958,6 @@ void GdbEngine::reloadModulesInternal() runCommand({"info shared", NeedsTemporaryStop, CB(handleModulesList)}); } -static QString nameFromPath(const QString &path) -{ - return QFileInfo(path).baseName(); -} - void GdbEngine::handleModulesList(const DebuggerResponse &response) { if (response.resultClass == ResultDone) { @@ -2971,14 +2968,15 @@ void GdbEngine::handleModulesList(const DebuggerResponse &response) QString data = response.consoleStreamOutput; QTextStream ts(&data, QIODevice::ReadOnly); bool found = false; + const FilePath inferior = runParameters().inferior.command.executable(); while (!ts.atEnd()) { QString line = ts.readLine(); QString symbolsRead; QTextStream ts(&line, QIODevice::ReadOnly); if (line.startsWith("0x")) { ts >> module.startAddress >> module.endAddress >> symbolsRead; - module.modulePath = ts.readLine().trimmed(); - module.moduleName = nameFromPath(module.modulePath); + module.modulePath = inferior.withNewPath(ts.readLine().trimmed()); + module.moduleName = module.modulePath.baseName(); module.symbolsRead = (symbolsRead == "Yes" ? Module::ReadOk : Module::ReadFailed); handler->updateModule(module); @@ -2989,8 +2987,8 @@ void GdbEngine::handleModulesList(const DebuggerResponse &response) QTC_ASSERT(symbolsRead == "No", continue); module.startAddress = 0; module.endAddress = 0; - module.modulePath = ts.readLine().trimmed(); - module.moduleName = nameFromPath(module.modulePath); + module.modulePath = inferior.withNewPath(ts.readLine().trimmed()); + module.moduleName = module.modulePath.baseName(); handler->updateModule(module); found = true; } @@ -3002,8 +3000,8 @@ void GdbEngine::handleModulesList(const DebuggerResponse &response) // loaded_addr="0x8fe00000",slide="0x0",prefix="__dyld_"}, // shlib-info={...}... for (const GdbMi &item : response.data) { - module.modulePath = item["path"].data(); - module.moduleName = nameFromPath(module.modulePath); + module.modulePath = inferior.withNewPath(item["path"].data()); + module.moduleName = module.modulePath.baseName(); module.symbolsRead = (item["state"].data() == "Y") ? Module::ReadOk : Module::ReadFailed; module.startAddress = @@ -3922,7 +3920,7 @@ void GdbEngine::handleGdbStarted() Module module; module.startAddress = 0; module.endAddress = 0; - module.modulePath = rp.inferior.command.executable().toString(); + module.modulePath = rp.inferior.command.executable(); module.moduleName = ""; modulesHandler()->updateModule(module); diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 8912375477c..f2c7c23744c 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -643,12 +643,13 @@ void LldbEngine::reloadModules() { DebuggerCommand cmd("fetchModules"); cmd.callback = [this](const DebuggerResponse &response) { + const FilePath inferior = runParameters().inferior.command.executable(); const GdbMi &modules = response.data["modules"]; ModulesHandler *handler = modulesHandler(); handler->beginUpdateAll(); for (const GdbMi &item : modules) { Module module; - module.modulePath = item["file"].data(); + module.modulePath = inferior.withNewPath(item["file"].data()); module.moduleName = item["name"].data(); module.symbolsRead = Module::UnknownReadState; module.startAddress = item["loaded_addr"].toAddress(); diff --git a/src/plugins/debugger/moduleshandler.cpp b/src/plugins/debugger/moduleshandler.cpp index 26d1cd23409..9ae6b068af8 100644 --- a/src/plugins/debugger/moduleshandler.cpp +++ b/src/plugins/debugger/moduleshandler.cpp @@ -48,7 +48,7 @@ QVariant ModuleItem::data(int column, int role) const break; case 1: if (role == Qt::DisplayRole) - return module.modulePath; + return module.modulePath.toUserOutput(); if (role == Qt::ToolTipRole) { QString msg; if (!module.elfData.buildId.isEmpty()) @@ -150,7 +150,7 @@ bool ModulesModel::contextMenuEvent(const ItemViewEvent &ev) const bool canShowSymbols = engine->hasCapability(ShowModuleSymbolsCapability); const bool moduleNameValid = item && !item->module.moduleName.isEmpty(); const QString moduleName = item ? item->module.moduleName : QString(); - const QString modulePath = item ? item->module.modulePath : QString(); + const FilePath modulePath = item ? item->module.modulePath : FilePath(); auto menu = new QMenu; @@ -161,13 +161,13 @@ bool ModulesModel::contextMenuEvent(const ItemViewEvent &ev) addAction(this, menu, Tr::tr("Show Source Files for Module \"%1\"").arg(moduleName), Tr::tr("Show Source Files for Module"), moduleNameValid && enabled && canReload, - [this, modulePath] { engine->loadSymbols(FilePath::fromUserInput(modulePath)); }); + [this, modulePath] { engine->loadSymbols(modulePath); }); // FIXME: Dependencies only available on Windows, when "depends" is installed. addAction(this, menu, Tr::tr("Show Dependencies of \"%1\"").arg(moduleName), Tr::tr("Show Dependencies"), moduleNameValid && !moduleName.isEmpty() && HostOsInfo::isWindowsHost(), - [modulePath] { QtcProcess::startDetached({{"depends"}, {modulePath}}); }); + [modulePath] { QtcProcess::startDetached({{"depends"}, {modulePath.toString()}}); }); addAction(this, menu, Tr::tr("Load Symbols for All Modules"), enabled && canLoadSymbols, @@ -180,22 +180,22 @@ bool ModulesModel::contextMenuEvent(const ItemViewEvent &ev) addAction(this, menu, Tr::tr("Load Symbols for Module \"%1\"").arg(moduleName), Tr::tr("Load Symbols for Module"), moduleNameValid && canLoadSymbols, - [this, modulePath] { engine->loadSymbols(FilePath::fromUserInput(modulePath)); }); + [this, modulePath] { engine->loadSymbols(modulePath); }); addAction(this, menu, Tr::tr("Edit File \"%1\"").arg(moduleName), Tr::tr("Edit File"), moduleNameValid, - [this, modulePath] { engine->gotoLocation(FilePath::fromString(modulePath)); }); + [this, modulePath] { engine->gotoLocation(modulePath); }); addAction(this, menu, Tr::tr("Show Symbols in File \"%1\"").arg(moduleName), Tr::tr("Show Symbols"), canShowSymbols && moduleNameValid, - [this, modulePath] { engine->requestModuleSymbols(FilePath::fromUserInput(modulePath)); }); + [this, modulePath] { engine->requestModuleSymbols(modulePath); }); addAction(this, menu, Tr::tr("Show Sections in File \"%1\"").arg(moduleName), Tr::tr("Show Sections"), canShowSymbols && moduleNameValid, - [this, modulePath] { engine->requestModuleSections(FilePath::fromUserInput(modulePath)); }); + [this, modulePath] { engine->requestModuleSections(modulePath); }); menu->addAction(debuggerSettings()->settingsDialog.action()); @@ -239,7 +239,7 @@ QAbstractItemModel *ModulesHandler::model() const return m_proxyModel; } -ModuleItem *ModulesHandler::moduleFromPath(const QString &modulePath) const +ModuleItem *ModulesHandler::moduleFromPath(const FilePath &modulePath) const { // Recent modules are more likely to be unloaded first. return m_model->findItemAtLevel<1>([modulePath](ModuleItem *item) { @@ -259,7 +259,7 @@ const Modules ModulesHandler::modules() const return mods; } -void ModulesHandler::removeModule(const QString &modulePath) +void ModulesHandler::removeModule(const FilePath &modulePath) { if (ModuleItem *item = moduleFromPath(modulePath)) m_model->destroyItem(item); @@ -267,7 +267,7 @@ void ModulesHandler::removeModule(const QString &modulePath) void ModulesHandler::updateModule(const Module &module) { - const QString path = module.modulePath; + const FilePath path = module.modulePath; if (path.isEmpty()) return; @@ -281,12 +281,12 @@ void ModulesHandler::updateModule(const Module &module) } try { // MinGW occasionallly throws std::bad_alloc. - ElfReader reader(FilePath::fromUserInput(path)); + ElfReader reader(path); item->module.elfData = reader.readHeaders(); item->update(); } catch(...) { qWarning("%s: An exception occurred while reading module '%s'", - Q_FUNC_INFO, qPrintable(module.modulePath)); + Q_FUNC_INFO, qPrintable(module.modulePath.toUserOutput())); } item->updated = true; } diff --git a/src/plugins/debugger/moduleshandler.h b/src/plugins/debugger/moduleshandler.h index 082a66f2ca0..03434edab28 100644 --- a/src/plugins/debugger/moduleshandler.h +++ b/src/plugins/debugger/moduleshandler.h @@ -70,7 +70,7 @@ public: ReadOk // Dwarf index available. }; QString moduleName; - QString modulePath; + Utils::FilePath modulePath; QString hostPath; SymbolReadState symbolsRead = UnknownReadState; quint64 startAddress = 0; @@ -99,7 +99,7 @@ public: QAbstractItemModel *model() const; - void removeModule(const QString &modulePath); + void removeModule(const Utils::FilePath &modulePath); void updateModule(const Module &module); void beginUpdateAll(); @@ -109,7 +109,7 @@ public: const Modules modules() const; private: - ModuleItem *moduleFromPath(const QString &modulePath) const; + ModuleItem *moduleFromPath(const Utils::FilePath &modulePath) const; ModulesModel *m_model; QSortFilterProxyModel *m_proxyModel; diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index a8766691147..4435409506b 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -294,7 +294,7 @@ void PdbEngine::refreshModules(const GdbMi &modules) && path.endsWith("' (built-in)>")) { path = "(builtin)"; } - module.modulePath = path; + module.modulePath = FilePath::fromString(path); handler->updateModule(module); } handler->endUpdateAll(); diff --git a/src/plugins/debugger/uvsc/uvscengine.cpp b/src/plugins/debugger/uvsc/uvscengine.cpp index 2bb0bef8e76..06450651de2 100644 --- a/src/plugins/debugger/uvsc/uvscengine.cpp +++ b/src/plugins/debugger/uvsc/uvscengine.cpp @@ -600,7 +600,7 @@ void UvscEngine::handleProjectClosed() Module module; module.startAddress = 0; module.endAddress = 0; - module.modulePath = rp.inferior.command.executable().toString(); + module.modulePath = rp.inferior.command.executable(); module.moduleName = ""; modulesHandler()->updateModule(module);