diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 379ad29f6d5b03f4b9b6b9488c3dea837359f350..ddcabf2e5ea38822d544eb915503caaca9c9c369 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -1259,6 +1259,19 @@ BreakpointModelIds BreakHandler::engineBreakpointIds(DebuggerEngine *engine) con return ids; } +QStringList BreakHandler::engineBreakpointPaths(DebuggerEngine *engine) const +{ + QSet<QString> set; + ConstIterator it = m_storage.constBegin(), et = m_storage.constEnd(); + for ( ; it != et; ++it) { + if (it->engine == engine) { + if (it->data.type == BreakpointByFileAndLine) + set.insert(QFileInfo(it->data.fileName).dir().path()); + } + } + return set.toList(); +} + void BreakHandler::cleanupBreakpoint(BreakpointModelId id) { QTC_ASSERT(state(id) == BreakpointDead, qDebug() << state(id)); diff --git a/src/plugins/debugger/breakhandler.h b/src/plugins/debugger/breakhandler.h index 47917e464928c4e9adf3f794d900204820c13444..82a92b2d75de3b8e327ffe9d91bcf4eef95d4e73 100644 --- a/src/plugins/debugger/breakhandler.h +++ b/src/plugins/debugger/breakhandler.h @@ -79,6 +79,7 @@ public: BreakpointModelIds engineBreakpointIds(DebuggerEngine *engine) const; BreakpointModelIds unclaimedBreakpointIds() const; int size() const { return m_storage.size(); } + QStringList engineBreakpointPaths(DebuggerEngine *engine) const; // Find a breakpoint matching approximately the data in needle. BreakpointModelId findSimilarBreakpoint(const BreakpointResponse &needle) const; diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 9feac3ee45f9fede2f44d1753a9946439e8c193f..23aee74157a9c7cdaf70f16c2dc2010c8584fe04 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1198,11 +1198,10 @@ void DebuggerPluginPrivate::maybeEnrichParameters(DebuggerStartParameters *sp) return; if (sp->sysroot.isEmpty() && (sp->startMode == AttachToRemoteServer || sp->startMode == StartRemote)) { - // FIXME: Get from BaseQtVersion + // FIXME: Get from BaseQtVersion. sp->sysroot = QString::fromLocal8Bit(qgetenv("QTC_DEBUGGER_SYSROOT")); - //if (sp->sysroot.isEmpty()) - // sp->sysroot = debuggerCore()->configValue(_("LastSysroot")).toString(); - showMessage(QLatin1String("### USING FAKE SYSROOT ###") + sp->sysroot, LogWarning); + showMessage(QString::fromLatin1("USING QTC_DEBUGGER_SYSROOT %1") + .arg(sp->sysroot), LogWarning); } if (sp->debugInfoLocation.isEmpty()) sp->debugInfoLocation = sp->sysroot + "/usr/lib/debug"; diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index cd3849325e15998f41d02a560e89fa8278edaf3f..2f7229724ef9d81abeea3d77d37be823c4d377d6 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -4758,16 +4758,45 @@ void GdbEngine::handleAdapterStarted() void GdbEngine::setupInferior() { QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); + typedef GlobalDebuggerOptions::SourcePathMap SourcePathMap; + typedef SourcePathMap::const_iterator SourcePathMapIterator; + showStatusMessage(tr("Setting up inferior...")); const DebuggerStartParameters &sp = startParameters(); + + // Apply source path mappings from global options. + const SourcePathMap sourcePathMap = + DebuggerSourcePathMappingWidget::mergePlatformQtPath(sp.qtInstallPath, + debuggerCore()->globalDebuggerOptions()->sourcePathMap); + const SourcePathMapIterator cend = sourcePathMap.constEnd(); + SourcePathMapIterator it = sourcePathMap.constBegin(); + for ( ; it != cend; ++it) { + QByteArray command = "set substitute-path "; + command += it.key().toLocal8Bit(); + command += ' '; + command += it.value().toLocal8Bit(); + postCommand(command); + } + + if (!sp.sysroot.isEmpty()) + postCommand("set substitute-path / " + sp.sysroot.toLocal8Bit()); + const QByteArray debugInfoLocation = sp.debugInfoLocation.toLocal8Bit(); if (!debugInfoLocation.isEmpty()) postCommand("set debug-file-directory " + debugInfoLocation); + // Spaces just will not work. foreach (const QString &src, sp.debugSourceLocation) - postCommand("directory " + src.toLocal8Bit()); + postCommand("directory " + src.toLocal8Bit()); if (!sp.solibSearchPath.isEmpty()) postCommand("set solib-search-path " + sp.solibSearchPath.toLocal8Bit()); + + // Take locations of actual breakpoints into account. + if (debuggerCore()->boolSetting(AutoEnrichParameters)) { + foreach (const QString &src, breakHandler()->engineBreakpointPaths(this)) + postCommand("directory " + src.toLocal8Bit()); + } + m_gdbAdapter->setupInferior(); } @@ -4781,29 +4810,10 @@ void GdbEngine::notifyInferiorSetupFailed() void GdbEngine::handleInferiorPrepared() { - typedef GlobalDebuggerOptions::SourcePathMap SourcePathMap; - typedef SourcePathMap::const_iterator SourcePathMapIterator; const DebuggerStartParameters &sp = startParameters(); QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); - // Apply source path mappings from global options. - const SourcePathMap sourcePathMap = - DebuggerSourcePathMappingWidget::mergePlatformQtPath(sp.qtInstallPath, - debuggerCore()->globalDebuggerOptions()->sourcePathMap); - const SourcePathMapIterator cend = sourcePathMap.constEnd(); - SourcePathMapIterator it = sourcePathMap.constBegin(); - for ( ; it != cend; ++it) { - QByteArray command = "set substitute-path "; - command += it.key().toLocal8Bit(); - command += ' '; - command += it.value().toLocal8Bit(); - postCommand(command); - } - - if (!sp.sysroot.isEmpty()) - postCommand("set substitute-path / " + sp.sysroot.toLocal8Bit()); - // Initial attempt to set breakpoints. if (sp.startMode != AttachCore && !isSlaveEngine()) { showStatusMessage(tr("Setting breakpoints..."));