Commit 8e702387 authored by hjk's avatar hjk

Debugger: Start separating different process environments

Debugger and stub run locally, the debugged process not necessarily.

Change-Id: Ibf6aec3dcaec60069866ec0765ec2178ca0a26d6
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 36b3e3c8
...@@ -424,8 +424,8 @@ bool CdbEngine::startConsole(const DebuggerRunParameters &sp, QString *errorMess ...@@ -424,8 +424,8 @@ bool CdbEngine::startConsole(const DebuggerRunParameters &sp, QString *errorMess
connect(m_consoleStub.data(), &ConsoleProcess::stubStopped, connect(m_consoleStub.data(), &ConsoleProcess::stubStopped,
this, &CdbEngine::consoleStubExited); this, &CdbEngine::consoleStubExited);
m_consoleStub->setWorkingDirectory(sp.workingDirectory); m_consoleStub->setWorkingDirectory(sp.workingDirectory);
if (sp.environment.size()) if (sp.stubEnvironment.size())
m_consoleStub->setEnvironment(sp.environment); m_consoleStub->setEnvironment(sp.stubEnvironment);
if (!m_consoleStub->start(sp.executable, sp.processArgs)) { if (!m_consoleStub->start(sp.executable, sp.processArgs)) {
*errorMessage = tr("The console process \"%1\" could not be started.").arg(sp.executable); *errorMessage = tr("The console process \"%1\" could not be started.").arg(sp.executable);
return false; return false;
...@@ -620,10 +620,10 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage ...@@ -620,10 +620,10 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage
m_outputBuffer.clear(); m_outputBuffer.clear();
m_autoBreakPointCorrection = false; m_autoBreakPointCorrection = false;
const QStringList environment = sp.environment.size() == 0 ? const QStringList inferiorEnvironment = sp.inferiorEnvironment.size() == 0 ?
QProcessEnvironment::systemEnvironment().toStringList() : QProcessEnvironment::systemEnvironment().toStringList() :
sp.environment.toStringList(); sp.inferiorEnvironment.toStringList();
m_process.setEnvironment(mergeEnvironment(environment, extensionFi.absolutePath())); m_process.setEnvironment(mergeEnvironment(inferiorEnvironment, extensionFi.absolutePath()));
if (!sp.workingDirectory.isEmpty()) if (!sp.workingDirectory.isEmpty())
m_process.setWorkingDirectory(sp.workingDirectory); m_process.setWorkingDirectory(sp.workingDirectory);
......
...@@ -109,7 +109,8 @@ QDebug operator<<(QDebug str, const DebuggerRunParameters &sp) ...@@ -109,7 +109,8 @@ QDebug operator<<(QDebug str, const DebuggerRunParameters &sp)
nospace << "executable=" << sp.executable nospace << "executable=" << sp.executable
<< " coreFile=" << sp.coreFile << " coreFile=" << sp.coreFile
<< " processArgs=" << sp.processArgs << " processArgs=" << sp.processArgs
<< " environment=<" << sp.environment.size() << " variables>" << " inferior environment=<" << sp.inferiorEnvironment.size() << " variables>"
<< " debugger environment=<" << sp.debuggerEnvironment.size() << " variables>"
<< " workingDir=" << sp.workingDirectory << " workingDir=" << sp.workingDirectory
<< " attachPID=" << sp.attachPID << " attachPID=" << sp.attachPID
<< " useTerminal=" << sp.useTerminal << " useTerminal=" << sp.useTerminal
...@@ -566,7 +567,7 @@ void DebuggerEngine::startDebugger(DebuggerRunControl *runControl) ...@@ -566,7 +567,7 @@ void DebuggerEngine::startDebugger(DebuggerRunControl *runControl)
d->m_runControl->setApplicationProcessHandle(ProcessHandle(d->m_inferiorPid)); d->m_runControl->setApplicationProcessHandle(ProcessHandle(d->m_inferiorPid));
if (isNativeMixedActive()) if (isNativeMixedActive())
d->m_runParameters.environment.set(QLatin1String("QV4_FORCE_INTERPRETER"), QLatin1String("1")); d->m_runParameters.inferiorEnvironment.set(QLatin1String("QV4_FORCE_INTERPRETER"), QLatin1String("1"));
action(OperateByInstruction)->setEnabled(hasCapability(DisassemblerCapability)); action(OperateByInstruction)->setEnabled(hasCapability(DisassemblerCapability));
......
...@@ -1173,7 +1173,9 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, ...@@ -1173,7 +1173,9 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
rp.displayName = tr("Executable file \"%1\"").arg(rp.executable); rp.displayName = tr("Executable file \"%1\"").arg(rp.executable);
rp.startMessage = tr("Debugging file %1.").arg(rp.executable); rp.startMessage = tr("Debugging file %1.").arg(rp.executable);
} }
rp.environment = Utils::Environment::systemEnvironment(); rp.inferiorEnvironment = Utils::Environment::systemEnvironment();
rp.stubEnvironment = Utils::Environment::systemEnvironment();
rp.debuggerEnvironment = Utils::Environment::systemEnvironment();
m_scheduledStarts.append(QPair<DebuggerRunParameters, Kit *>(rp, kit)); m_scheduledStarts.append(QPair<DebuggerRunParameters, Kit *>(rp, kit));
return true; return true;
} }
......
...@@ -404,8 +404,11 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const ...@@ -404,8 +404,11 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const
} }
if (m_runConfig) { if (m_runConfig) {
if (auto envAspect = m_runConfig->extraAspect<EnvironmentAspect>()) if (auto envAspect = m_runConfig->extraAspect<EnvironmentAspect>()) {
m_rp.environment = envAspect->environment(); m_rp.inferiorEnvironment = envAspect->environment(); // Correct.
m_rp.stubEnvironment = m_rp.inferiorEnvironment; // FIXME: Wrong, but contains DYLD_IMAGE_SUFFIX
m_rp.debuggerEnvironment = m_rp.inferiorEnvironment; // FIXME: Wrong, but contains DYLD_IMAGE_SUFFIX
}
} }
if (ToolChain *tc = ToolChainKitInformation::toolChain(m_kit)) if (ToolChain *tc = ToolChainKitInformation::toolChain(m_kit))
...@@ -497,8 +500,8 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const ...@@ -497,8 +500,8 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const
// Makes sure that all bindings go through the JavaScript engine, so that // Makes sure that all bindings go through the JavaScript engine, so that
// breakpoints are actually hit! // breakpoints are actually hit!
const QString optimizerKey = _("QML_DISABLE_OPTIMIZER"); const QString optimizerKey = _("QML_DISABLE_OPTIMIZER");
if (!m_rp.environment.hasKey(optimizerKey)) if (!m_rp.inferiorEnvironment.hasKey(optimizerKey))
m_rp.environment.set(optimizerKey, _("1")); m_rp.inferiorEnvironment.set(optimizerKey, _("1"));
} }
} }
} }
......
...@@ -440,7 +440,7 @@ DebuggerSourcePathMappingWidget::SourcePathMap ...@@ -440,7 +440,7 @@ DebuggerSourcePathMappingWidget::SourcePathMap
DebuggerSourcePathMappingWidget::mergePlatformQtPath(const DebuggerRunParameters &sp, DebuggerSourcePathMappingWidget::mergePlatformQtPath(const DebuggerRunParameters &sp,
const SourcePathMap &in) const SourcePathMap &in)
{ {
const FileName qmake = BuildableHelperLibrary::findSystemQt(sp.environment); const FileName qmake = BuildableHelperLibrary::findSystemQt(sp.inferiorEnvironment);
// FIXME: Get this from the profile? // FIXME: Get this from the profile?
// We could query the QtVersion for this information directly, but then we // We could query the QtVersion for this information directly, but then we
// will need to add a dependency on QtSupport to the debugger. // will need to add a dependency on QtSupport to the debugger.
......
...@@ -73,7 +73,9 @@ public: ...@@ -73,7 +73,9 @@ public:
QString executable; QString executable;
QString displayName; // Used in the Snapshots view. QString displayName; // Used in the Snapshots view.
QString processArgs; QString processArgs;
Utils::Environment environment; Utils::Environment inferiorEnvironment;
Utils::Environment debuggerEnvironment;
Utils::Environment stubEnvironment;
QString workingDirectory; QString workingDirectory;
qint64 attachPID = InvalidPid; qint64 attachPID = InvalidPid;
QStringList solibSearchPath; QStringList solibSearchPath;
...@@ -81,7 +83,7 @@ public: ...@@ -81,7 +83,7 @@ public:
// Used by Qml debugging. // Used by Qml debugging.
QString qmlServerAddress; QString qmlServerAddress;
quint16 qmlServerPort; quint16 qmlServerPort = InvalidPort;
// Used by general remote debugging. // Used by general remote debugging.
QString remoteChannel; QString remoteChannel;
......
...@@ -59,6 +59,7 @@ void GdbAttachEngine::setupEngine() ...@@ -59,6 +59,7 @@ void GdbAttachEngine::setupEngine()
if (!runParameters().workingDirectory.isEmpty()) if (!runParameters().workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(runParameters().workingDirectory); m_gdbProc.setWorkingDirectory(runParameters().workingDirectory);
m_gdbProc.setEnvironment(runParameters().debuggerEnvironment);
startGdb(); startGdb();
} }
......
...@@ -4193,7 +4193,7 @@ void GdbEngine::loadInitScript() ...@@ -4193,7 +4193,7 @@ void GdbEngine::loadInitScript()
void GdbEngine::setEnvironmentVariables() void GdbEngine::setEnvironmentVariables()
{ {
Environment sysEnv = Environment::systemEnvironment(); Environment sysEnv = Environment::systemEnvironment();
Environment runEnv = runParameters().environment; Environment runEnv = runParameters().inferiorEnvironment;
foreach (const EnvironmentItem &item, sysEnv.diff(runEnv)) { foreach (const EnvironmentItem &item, sysEnv.diff(runEnv)) {
if (item.unset) if (item.unset)
runCommand({"unset environment " + item.name.toUtf8(), NoFlags}); runCommand({"unset environment " + item.name.toUtf8(), NoFlags});
......
...@@ -88,7 +88,7 @@ void GdbTermEngine::setupEngine() ...@@ -88,7 +88,7 @@ void GdbTermEngine::setupEngine()
m_stubProc.setWorkingDirectory(runParameters().workingDirectory); m_stubProc.setWorkingDirectory(runParameters().workingDirectory);
// Set environment + dumper preload. // Set environment + dumper preload.
m_stubProc.setEnvironment(runParameters().environment); m_stubProc.setEnvironment(runParameters().stubEnvironment);
connect(&m_stubProc, &ConsoleProcess::processError, connect(&m_stubProc, &ConsoleProcess::processError,
this, &GdbTermEngine::stubError); this, &GdbTermEngine::stubError);
......
...@@ -214,7 +214,7 @@ void LldbEngine::setupEngine() ...@@ -214,7 +214,7 @@ void LldbEngine::setupEngine()
m_stubProc.setWorkingDirectory(runParameters().workingDirectory); m_stubProc.setWorkingDirectory(runParameters().workingDirectory);
// Set environment + dumper preload. // Set environment + dumper preload.
m_stubProc.setEnvironment(runParameters().environment); m_stubProc.setEnvironment(runParameters().stubEnvironment);
connect(&m_stubProc, &ConsoleProcess::processError, this, &LldbEngine::stubError); connect(&m_stubProc, &ConsoleProcess::processError, this, &LldbEngine::stubError);
connect(&m_stubProc, &ConsoleProcess::processStarted, this, &LldbEngine::stubStarted); connect(&m_stubProc, &ConsoleProcess::processStarted, this, &LldbEngine::stubStarted);
...@@ -255,7 +255,7 @@ void LldbEngine::startLldb() ...@@ -255,7 +255,7 @@ void LldbEngine::startLldb()
this, &LldbEngine::handleResponse, Qt::QueuedConnection); this, &LldbEngine::handleResponse, Qt::QueuedConnection);
showMessage(_("STARTING LLDB: ") + m_lldbCmd); showMessage(_("STARTING LLDB: ") + m_lldbCmd);
m_lldbProc.setEnvironment(runParameters().environment); m_lldbProc.setEnvironment(runParameters().debuggerEnvironment);
if (!runParameters().workingDirectory.isEmpty()) if (!runParameters().workingDirectory.isEmpty())
m_lldbProc.setWorkingDirectory(runParameters().workingDirectory); m_lldbProc.setWorkingDirectory(runParameters().workingDirectory);
...@@ -293,7 +293,7 @@ void LldbEngine::startLldbStage2() ...@@ -293,7 +293,7 @@ void LldbEngine::startLldbStage2()
void LldbEngine::setupInferior() void LldbEngine::setupInferior()
{ {
Environment sysEnv = Environment::systemEnvironment(); Environment sysEnv = Environment::systemEnvironment();
Environment runEnv = runParameters().environment; Environment runEnv = runParameters().inferiorEnvironment;
foreach (const EnvironmentItem &item, sysEnv.diff(runEnv)) { foreach (const EnvironmentItem &item, sysEnv.diff(runEnv)) {
DebuggerCommand cmd("executeDebuggerCommand"); DebuggerCommand cmd("executeDebuggerCommand");
if (item.unset) if (item.unset)
...@@ -337,10 +337,9 @@ void LldbEngine::setupInferior() ...@@ -337,10 +337,9 @@ void LldbEngine::setupInferior()
cmd2.arg("startmode", rp.startMode); cmd2.arg("startmode", rp.startMode);
cmd2.arg("nativemixed", isNativeMixedActive()); cmd2.arg("nativemixed", isNativeMixedActive());
// FIXME: separate Inferior and Debugger environments properly cmd2.arg("dyldimagesuffix", rp.inferiorEnvironment.value(_("DYLD_IMAGE_SUFFIX")));
cmd2.arg("dyldimagesuffix", rp.environment.value(_("DYLD_IMAGE_SUFFIX"))); cmd2.arg("dyldframeworkpath", rp.inferiorEnvironment.value(_("DYLD_LIBRARY_PATH")));
cmd2.arg("dyldframeworkpath", rp.environment.value(_("DYLD_LIBRARY_PATH"))); cmd2.arg("dyldlibrarypath", rp.inferiorEnvironment.value(_("DYLD_FRAMEWORK_PATH")));
cmd2.arg("dyldlibrarypath", rp.environment.value(_("DYLD_FRAMEWORK_PATH")));
QJsonArray processArgs; QJsonArray processArgs;
foreach (const QString &arg, args.toUnixArgs()) foreach (const QString &arg, args.toUnixArgs())
......
...@@ -639,7 +639,7 @@ void QmlEngine::setupEngine() ...@@ -639,7 +639,7 @@ void QmlEngine::setupEngine()
// we need to get the port first // we need to get the port first
notifyEngineRequestRemoteSetup(); notifyEngineRequestRemoteSetup();
} else { } else {
d->applicationLauncher.setEnvironment(runParameters().environment); d->applicationLauncher.setEnvironment(runParameters().inferiorEnvironment);
d->applicationLauncher.setWorkingDirectory(runParameters().workingDirectory); d->applicationLauncher.setWorkingDirectory(runParameters().workingDirectory);
// We can't do this in the constructore because runControl() isn't yet defined // We can't do this in the constructore because runControl() isn't yet defined
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment