From c83a0be72d700bc56d32afc8eaaf84ac134f419e Mon Sep 17 00:00:00 2001 From: Daniel Trevitz Date: Fri, 15 Sep 2023 10:56:08 -0400 Subject: [PATCH] Only download from remote when we absolutely have to If the kit includes a correctly configured sysroot gdbserver will tell us our hostPath. Respect that hostPath if it exists, otherwise fall back to remote debug. Also, populate the hostPath with the symbol file from the run parameters. Task-number: QTCREATORBUG-29614 Change-Id: I3838cd44aa96d7dfcd4ded660b8102a1532c5362 Reviewed-by: hjk --- src/plugins/debugger/gdb/gdbengine.cpp | 5 +++-- src/plugins/debugger/moduleshandler.cpp | 9 ++++++++- src/plugins/debugger/moduleshandler.h | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 09755f68e6d..59d6d50a5b7 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -469,10 +469,10 @@ void GdbEngine::handleAsyncOutput(const QStringView asyncClass, const GdbMi &res Module module; module.startAddress = 0; module.endAddress = 0; - module.hostPath = result["host-name"].data(); + module.hostPath = Utils::FilePath::fromString(result["host-name"].data()); const QString target = result["target-name"].data(); module.modulePath = runParameters().inferior.command.executable().withNewPath(target); - module.moduleName = QFileInfo(module.hostPath).baseName(); + module.moduleName = module.hostPath.baseName(); modulesHandler()->updateModule(module); } else if (asyncClass == u"library-unloaded") { // Archer has 'id="/usr/lib/libdrm.so.2", @@ -3926,6 +3926,7 @@ void GdbEngine::handleGdbStarted() module.startAddress = 0; module.endAddress = 0; module.modulePath = rp.inferior.command.executable(); + module.hostPath = rp.symbolFile; module.moduleName = ""; modulesHandler()->updateModule(module); diff --git a/src/plugins/debugger/moduleshandler.cpp b/src/plugins/debugger/moduleshandler.cpp index 5d0d6d6a8b7..9072d02463d 100644 --- a/src/plugins/debugger/moduleshandler.cpp +++ b/src/plugins/debugger/moduleshandler.cpp @@ -273,9 +273,16 @@ void ModulesHandler::removeModule(const FilePath &modulePath) m_model->destroyItem(item); } +static FilePath pickPath(const FilePath &hostPath, const FilePath &modulePath) +{ + if (!hostPath.isEmpty() && hostPath.exists()) + return hostPath; + return modulePath; // Checking if this exists can be slow, delay it for as long as possible +} + void ModulesHandler::updateModule(const Module &module) { - const FilePath path = module.modulePath; + const FilePath path = pickPath(module.hostPath, module.modulePath); if (path.isEmpty()) return; diff --git a/src/plugins/debugger/moduleshandler.h b/src/plugins/debugger/moduleshandler.h index 03434edab28..97ab677b359 100644 --- a/src/plugins/debugger/moduleshandler.h +++ b/src/plugins/debugger/moduleshandler.h @@ -71,7 +71,7 @@ public: }; QString moduleName; Utils::FilePath modulePath; - QString hostPath; + Utils::FilePath hostPath; SymbolReadState symbolsRead = UnknownReadState; quint64 startAddress = 0; quint64 endAddress = 0;