Commit 8e702387 authored by hjk's avatar hjk
Browse files

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
connect(m_consoleStub.data(), &ConsoleProcess::stubStopped,
this, &CdbEngine::consoleStubExited);
m_consoleStub->setWorkingDirectory(sp.workingDirectory);
if (sp.environment.size())
m_consoleStub->setEnvironment(sp.environment);
if (sp.stubEnvironment.size())
m_consoleStub->setEnvironment(sp.stubEnvironment);
if (!m_consoleStub->start(sp.executable, sp.processArgs)) {
*errorMessage = tr("The console process \"%1\" could not be started.").arg(sp.executable);
return false;
......@@ -620,10 +620,10 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage
m_outputBuffer.clear();
m_autoBreakPointCorrection = false;
const QStringList environment = sp.environment.size() == 0 ?
const QStringList inferiorEnvironment = sp.inferiorEnvironment.size() == 0 ?
QProcessEnvironment::systemEnvironment().toStringList() :
sp.environment.toStringList();
m_process.setEnvironment(mergeEnvironment(environment, extensionFi.absolutePath()));
sp.inferiorEnvironment.toStringList();
m_process.setEnvironment(mergeEnvironment(inferiorEnvironment, extensionFi.absolutePath()));
if (!sp.workingDirectory.isEmpty())
m_process.setWorkingDirectory(sp.workingDirectory);
......
......@@ -109,7 +109,8 @@ QDebug operator<<(QDebug str, const DebuggerRunParameters &sp)
nospace << "executable=" << sp.executable
<< " coreFile=" << sp.coreFile
<< " processArgs=" << sp.processArgs
<< " environment=<" << sp.environment.size() << " variables>"
<< " inferior environment=<" << sp.inferiorEnvironment.size() << " variables>"
<< " debugger environment=<" << sp.debuggerEnvironment.size() << " variables>"
<< " workingDir=" << sp.workingDirectory
<< " attachPID=" << sp.attachPID
<< " useTerminal=" << sp.useTerminal
......@@ -566,7 +567,7 @@ void DebuggerEngine::startDebugger(DebuggerRunControl *runControl)
d->m_runControl->setApplicationProcessHandle(ProcessHandle(d->m_inferiorPid));
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));
......
......@@ -1173,7 +1173,9 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
rp.displayName = tr("Executable 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));
return true;
}
......
......@@ -404,8 +404,11 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const
}
if (m_runConfig) {
if (auto envAspect = m_runConfig->extraAspect<EnvironmentAspect>())
m_rp.environment = envAspect->environment();
if (auto envAspect = m_runConfig->extraAspect<EnvironmentAspect>()) {
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))
......@@ -497,8 +500,8 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const
// Makes sure that all bindings go through the JavaScript engine, so that
// breakpoints are actually hit!
const QString optimizerKey = _("QML_DISABLE_OPTIMIZER");
if (!m_rp.environment.hasKey(optimizerKey))
m_rp.environment.set(optimizerKey, _("1"));
if (!m_rp.inferiorEnvironment.hasKey(optimizerKey))
m_rp.inferiorEnvironment.set(optimizerKey, _("1"));
}
}
}
......
......@@ -440,7 +440,7 @@ DebuggerSourcePathMappingWidget::SourcePathMap
DebuggerSourcePathMappingWidget::mergePlatformQtPath(const DebuggerRunParameters &sp,
const SourcePathMap &in)
{
const FileName qmake = BuildableHelperLibrary::findSystemQt(sp.environment);
const FileName qmake = BuildableHelperLibrary::findSystemQt(sp.inferiorEnvironment);
// FIXME: Get this from the profile?
// We could query the QtVersion for this information directly, but then we
// will need to add a dependency on QtSupport to the debugger.
......
......@@ -73,7 +73,9 @@ public:
QString executable;
QString displayName; // Used in the Snapshots view.
QString processArgs;
Utils::Environment environment;
Utils::Environment inferiorEnvironment;
Utils::Environment debuggerEnvironment;
Utils::Environment stubEnvironment;
QString workingDirectory;
qint64 attachPID = InvalidPid;
QStringList solibSearchPath;
......@@ -81,7 +83,7 @@ public:
// Used by Qml debugging.
QString qmlServerAddress;
quint16 qmlServerPort;
quint16 qmlServerPort = InvalidPort;
// Used by general remote debugging.
QString remoteChannel;
......
......@@ -59,6 +59,7 @@ void GdbAttachEngine::setupEngine()
if (!runParameters().workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(runParameters().workingDirectory);
m_gdbProc.setEnvironment(runParameters().debuggerEnvironment);
startGdb();
}
......
......@@ -4193,7 +4193,7 @@ void GdbEngine::loadInitScript()
void GdbEngine::setEnvironmentVariables()
{
Environment sysEnv = Environment::systemEnvironment();
Environment runEnv = runParameters().environment;
Environment runEnv = runParameters().inferiorEnvironment;
foreach (const EnvironmentItem &item, sysEnv.diff(runEnv)) {
if (item.unset)
runCommand({"unset environment " + item.name.toUtf8(), NoFlags});
......
......@@ -88,7 +88,7 @@ void GdbTermEngine::setupEngine()
m_stubProc.setWorkingDirectory(runParameters().workingDirectory);
// Set environment + dumper preload.
m_stubProc.setEnvironment(runParameters().environment);
m_stubProc.setEnvironment(runParameters().stubEnvironment);
connect(&m_stubProc, &ConsoleProcess::processError,
this, &GdbTermEngine::stubError);
......
......@@ -214,7 +214,7 @@ void LldbEngine::setupEngine()
m_stubProc.setWorkingDirectory(runParameters().workingDirectory);
// 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::processStarted, this, &LldbEngine::stubStarted);
......@@ -255,7 +255,7 @@ void LldbEngine::startLldb()
this, &LldbEngine::handleResponse, Qt::QueuedConnection);
showMessage(_("STARTING LLDB: ") + m_lldbCmd);
m_lldbProc.setEnvironment(runParameters().environment);
m_lldbProc.setEnvironment(runParameters().debuggerEnvironment);
if (!runParameters().workingDirectory.isEmpty())
m_lldbProc.setWorkingDirectory(runParameters().workingDirectory);
......@@ -293,7 +293,7 @@ void LldbEngine::startLldbStage2()
void LldbEngine::setupInferior()
{
Environment sysEnv = Environment::systemEnvironment();
Environment runEnv = runParameters().environment;
Environment runEnv = runParameters().inferiorEnvironment;
foreach (const EnvironmentItem &item, sysEnv.diff(runEnv)) {
DebuggerCommand cmd("executeDebuggerCommand");
if (item.unset)
......@@ -337,10 +337,9 @@ void LldbEngine::setupInferior()
cmd2.arg("startmode", rp.startMode);
cmd2.arg("nativemixed", isNativeMixedActive());
// FIXME: separate Inferior and Debugger environments properly
cmd2.arg("dyldimagesuffix", rp.environment.value(_("DYLD_IMAGE_SUFFIX")));
cmd2.arg("dyldframeworkpath", rp.environment.value(_("DYLD_LIBRARY_PATH")));
cmd2.arg("dyldlibrarypath", rp.environment.value(_("DYLD_FRAMEWORK_PATH")));
cmd2.arg("dyldimagesuffix", rp.inferiorEnvironment.value(_("DYLD_IMAGE_SUFFIX")));
cmd2.arg("dyldframeworkpath", rp.inferiorEnvironment.value(_("DYLD_LIBRARY_PATH")));
cmd2.arg("dyldlibrarypath", rp.inferiorEnvironment.value(_("DYLD_FRAMEWORK_PATH")));
QJsonArray processArgs;
foreach (const QString &arg, args.toUnixArgs())
......
......@@ -639,7 +639,7 @@ void QmlEngine::setupEngine()
// we need to get the port first
notifyEngineRequestRemoteSetup();
} else {
d->applicationLauncher.setEnvironment(runParameters().environment);
d->applicationLauncher.setEnvironment(runParameters().inferiorEnvironment);
d->applicationLauncher.setWorkingDirectory(runParameters().workingDirectory);
// 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