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 <hjk@qt.io>
This commit is contained in:
Daniel Trevitz
2023-09-15 10:56:08 -04:00
parent 72fb52f767
commit c83a0be72d
3 changed files with 12 additions and 4 deletions

View File

@@ -469,10 +469,10 @@ void GdbEngine::handleAsyncOutput(const QStringView asyncClass, const GdbMi &res
Module module; Module module;
module.startAddress = 0; module.startAddress = 0;
module.endAddress = 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(); const QString target = result["target-name"].data();
module.modulePath = runParameters().inferior.command.executable().withNewPath(target); module.modulePath = runParameters().inferior.command.executable().withNewPath(target);
module.moduleName = QFileInfo(module.hostPath).baseName(); module.moduleName = module.hostPath.baseName();
modulesHandler()->updateModule(module); modulesHandler()->updateModule(module);
} else if (asyncClass == u"library-unloaded") { } else if (asyncClass == u"library-unloaded") {
// Archer has 'id="/usr/lib/libdrm.so.2", // Archer has 'id="/usr/lib/libdrm.so.2",
@@ -3926,6 +3926,7 @@ void GdbEngine::handleGdbStarted()
module.startAddress = 0; module.startAddress = 0;
module.endAddress = 0; module.endAddress = 0;
module.modulePath = rp.inferior.command.executable(); module.modulePath = rp.inferior.command.executable();
module.hostPath = rp.symbolFile;
module.moduleName = "<executable>"; module.moduleName = "<executable>";
modulesHandler()->updateModule(module); modulesHandler()->updateModule(module);

View File

@@ -273,9 +273,16 @@ void ModulesHandler::removeModule(const FilePath &modulePath)
m_model->destroyItem(item); 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) void ModulesHandler::updateModule(const Module &module)
{ {
const FilePath path = module.modulePath; const FilePath path = pickPath(module.hostPath, module.modulePath);
if (path.isEmpty()) if (path.isEmpty())
return; return;

View File

@@ -71,7 +71,7 @@ public:
}; };
QString moduleName; QString moduleName;
Utils::FilePath modulePath; Utils::FilePath modulePath;
QString hostPath; Utils::FilePath hostPath;
SymbolReadState symbolsRead = UnknownReadState; SymbolReadState symbolsRead = UnknownReadState;
quint64 startAddress = 0; quint64 startAddress = 0;
quint64 endAddress = 0; quint64 endAddress = 0;