Commit 588443b2 authored by hjk's avatar hjk Committed by hjk

Debugger: Use a StandardRunnable for the debugger process

One step further to separate the debugger environment from the
inferior environment and to make it possible to configure a
working directory. Guessing one from the inferior's working
directory is not always a good idea.

Change-Id: I33d139c0f228ec0870556b82bc6aecca0a8e62d6
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent 506e23dc
......@@ -1268,7 +1268,7 @@ void AndroidConfigurations::updateAutomaticKitList()
// Update code for 3.0 beta, which shipped with a bug for the debugger settings
ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx);
if (tc && Debugger::DebuggerKitInformation::debuggerCommand(k) != tc->suggestedDebugger()) {
if (tc && Debugger::DebuggerKitInformation::runnable(k).executable != tc->suggestedDebugger().toString()) {
Debugger::DebuggerItem debugger;
debugger.setCommand(tc->suggestedDebugger());
debugger.setEngineType(Debugger::GdbEngineType);
......
......@@ -506,7 +506,7 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage
// Determine binary (force MSVC), extension lib name and path to use
// The extension is passed as relative name with the path variable set
//(does not work with absolute path names)
const QString executable = sp.debuggerCommand;
const QString executable = sp.debugger.executable;
if (executable.isEmpty()) {
*errorMessage = tr("There is no CDB executable specified.");
return false;
......@@ -975,7 +975,7 @@ void CdbEngine::doInterruptInferior(SpecialStopMode sm)
connect(m_signalOperation.data(), &DeviceProcessSignalOperation::finished,
this, &CdbEngine::handleDoInterruptInferior);
m_signalOperation->setDebuggerCommand(runParameters().debuggerCommand);
m_signalOperation->setDebuggerCommand(runParameters().debugger.executable);
m_signalOperation->interruptProcess(inferiorPid());
}
......
......@@ -104,7 +104,7 @@ QDebug operator<<(QDebug str, const DebuggerRunParameters &sp)
<< " coreFile=" << sp.coreFile
<< " processArgs=" << sp.inferior.commandLineArguments
<< " inferior environment=<" << sp.inferior.environment.size() << " variables>"
<< " debugger environment=<" << sp.debuggerEnvironment.size() << " variables>"
<< " debugger environment=<" << sp.debugger.environment.size() << " variables>"
<< " workingDir=" << sp.inferior.workingDirectory
<< " attachPID=" << sp.attachPID
<< " useTerminal=" << sp.useTerminal
......
......@@ -27,10 +27,12 @@
#include "debugger_global.h"
#include "debuggerconstants.h"
#include "debuggeritem.h"
#include "debuggerprotocol.h"
#include "debuggerstartparameters.h"
#include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/runnables.h>
#include <texteditor/textmark.h>
#include <QObject>
......@@ -89,7 +91,7 @@ public:
bool breakOnMain = false;
bool multiProcess = false; // Whether to set detach-on-fork off.
QString debuggerCommand;
ProjectExplorer::StandardRunnable debugger;
QString coreFile;
QString overrideStartScript; // Used in attach to core and remote debugging
QString startMessage; // First status message shown.
......
......@@ -29,6 +29,7 @@
#include "debuggeroptionspage.h"
#include "debuggerprotocol.h"
#include <coreplugin/coreicons.h>
#include <projectexplorer/abi.h>
#include <utils/fileutils.h>
......@@ -59,6 +60,7 @@ const char DEBUGGER_INFORMATION_AUTODETECTION_SOURCE[] = "AutoDetectionSource";
const char DEBUGGER_INFORMATION_VERSION[] = "Version";
const char DEBUGGER_INFORMATION_ABIS[] = "Abis";
const char DEBUGGER_INFORMATION_LASTMODIFIED[] = "LastModified";
const char DEBUGGER_INFORMATION_WORKINGDIRECTORY[] = "WorkingDirectory";
namespace Debugger {
......@@ -81,8 +83,9 @@ DebuggerItem::DebuggerItem(const QVariant &id)
DebuggerItem::DebuggerItem(const QVariantMap &data)
{
m_command = FileName::fromUserInput(data.value(QLatin1String(DEBUGGER_INFORMATION_COMMAND)).toString());
m_id = data.value(QLatin1String(DEBUGGER_INFORMATION_ID)).toString();
m_command = FileName::fromUserInput(data.value(QLatin1String(DEBUGGER_INFORMATION_COMMAND)).toString());
m_workingDirectory = FileName::fromUserInput(data.value(DEBUGGER_INFORMATION_WORKINGDIRECTORY).toString());
m_unexpandedDisplayName = data.value(QLatin1String(DEBUGGER_INFORMATION_DISPLAYNAME)).toString();
m_isAutoDetected = data.value(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTED), false).toBool();
m_autoDetectionSource = data.value(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTION_SOURCE)).toString();
......@@ -213,9 +216,15 @@ QDateTime DebuggerItem::lastModified() const
return m_lastModified;
}
bool DebuggerItem::isGood() const
QIcon DebuggerItem::decoration() const
{
return m_engineType != NoEngineType;
if (m_engineType == NoEngineType)
return Core::Icons::ERROR.icon();
if (!m_command.toFileInfo().isExecutable())
return Core::Icons::WARNING.icon();
if (!m_workingDirectory.isEmpty() && !m_workingDirectory.toFileInfo().isDir())
return Core::Icons::WARNING.icon();
return QIcon();
}
QString DebuggerItem::validityMessage() const
......@@ -230,7 +239,8 @@ bool DebuggerItem::operator==(const DebuggerItem &other) const
return m_id == other.m_id
&& m_unexpandedDisplayName == other.m_unexpandedDisplayName
&& m_isAutoDetected == other.m_isAutoDetected
&& m_command == other.m_command;
&& m_command == other.m_command
&& m_workingDirectory == other.m_workingDirectory;
}
QVariantMap DebuggerItem::toMap() const
......@@ -239,6 +249,7 @@ QVariantMap DebuggerItem::toMap() const
data.insert(QLatin1String(DEBUGGER_INFORMATION_DISPLAYNAME), m_unexpandedDisplayName);
data.insert(QLatin1String(DEBUGGER_INFORMATION_ID), m_id);
data.insert(QLatin1String(DEBUGGER_INFORMATION_COMMAND), m_command.toString());
data.insert(QLatin1String(DEBUGGER_INFORMATION_WORKINGDIRECTORY), m_workingDirectory.toString());
data.insert(QLatin1String(DEBUGGER_INFORMATION_ENGINETYPE), int(m_engineType));
data.insert(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTED), m_isAutoDetected);
data.insert(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTION_SOURCE), m_autoDetectionSource);
......
......@@ -94,7 +94,7 @@ public:
QStringList abiNames() const;
QDateTime lastModified() const;
bool isGood() const;
QIcon decoration() const;
QString validityMessage() const;
bool operator==(const DebuggerItem &other) const;
......@@ -102,6 +102,9 @@ public:
void reinitializeFromFile();
Utils::FileName workingDirectory() const { return m_workingDirectory; }
void setWorkingDirectory(const Utils::FileName &workingPath) { m_workingDirectory = workingPath; }
private:
DebuggerItem(const QVariant &id);
void initMacroExpander();
......@@ -110,6 +113,7 @@ private:
QString m_unexpandedDisplayName;
DebuggerEngineType m_engineType;
Utils::FileName m_command;
Utils::FileName m_workingDirectory;
bool m_isAutoDetected;
QString m_autoDetectionSource;
QString m_version;
......
......@@ -32,6 +32,7 @@
#include <projectexplorer/toolchain.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/environment.h>
#include <utils/fileutils.h>
#include <utils/macroexpander.h>
#include <utils/qtcassert.h>
......@@ -244,6 +245,18 @@ const DebuggerItem *DebuggerKitInformation::debugger(const Kit *kit)
return DebuggerItemManager::findById(id);
}
StandardRunnable DebuggerKitInformation::runnable(const Kit *kit)
{
StandardRunnable runnable;
if (const DebuggerItem *item = debugger(kit)) {
runnable.executable = item->command().toString();
runnable.workingDirectory = item->workingDirectory().toString();
runnable.environment = Utils::Environment::systemEnvironment();
runnable.environment.set("LC_NUMERIC", "C");
}
return runnable;
}
bool DebuggerKitInformation::isValidDebugger(const Kit *k)
{
return debuggerConfigurationErrors(k) == 0;
......@@ -326,14 +339,6 @@ KitInformation::ItemList DebuggerKitInformation::toUserOutput(const Kit *k) cons
return ItemList() << qMakePair(tr("Debugger"), displayString(k));
}
FileName DebuggerKitInformation::debuggerCommand(const Kit *k)
{
const DebuggerItem *item = debugger(k);
if (item)
return item->command();
return FileName();
}
DebuggerEngineType DebuggerKitInformation::engineType(const Kit *k)
{
const DebuggerItem *item = debugger(k);
......
......@@ -29,6 +29,7 @@
#include "debuggerconstants.h"
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/runnables.h>
namespace Debugger {
class DebuggerItem;
......@@ -49,6 +50,7 @@ public:
void fix(ProjectExplorer::Kit *k) override;
static const DebuggerItem *debugger(const ProjectExplorer::Kit *kit);
static ProjectExplorer::StandardRunnable runnable(const ProjectExplorer::Kit *kit);
static QList<ProjectExplorer::Task> validateDebugger(const ProjectExplorer::Kit *k);
static bool isValidDebugger(const ProjectExplorer::Kit *k);
......@@ -61,7 +63,6 @@ public:
static void setDebugger(ProjectExplorer::Kit *k, const QVariant &id);
static Core::Id id();
static Utils::FileName debuggerCommand(const ProjectExplorer::Kit *k);
static DebuggerEngineType engineType(const ProjectExplorer::Kit *k);
static QString displayString(const ProjectExplorer::Kit *k);
};
......
......@@ -65,8 +65,6 @@ public:
QVariant data(int column, int role) const
{
static const QIcon errorIcon = Core::Icons::ERROR.icon();
switch (role) {
case Qt::DisplayRole:
switch (column) {
......@@ -74,19 +72,23 @@ public:
case 1: return m_item.command().toUserOutput();
case 2: return m_item.engineTypeName();
}
break;
case Qt::FontRole:
if (m_changed) {
QFont font;
font.setBold(true);
return font;
}
break;
case Qt::DecorationRole:
if (column == 0)
return m_item.decoration();
break;
case Qt::FontRole: {
QFont font;
font.setBold(m_changed);
return font;
}
case Qt::DecorationRole: {
if (column == 0 && !m_item.isGood())
return errorIcon;
}
case Qt::ToolTipRole: {
case Qt::ToolTipRole:
return m_item.validityMessage();
}
}
return QVariant();
}
......@@ -214,6 +216,7 @@ private:
QLabel *m_cdbLabel;
QLineEdit *m_versionLabel;
PathChooser *m_binaryChooser;
PathChooser *m_workingDirectoryChooser;
QLineEdit *m_abis;
bool m_autodetected;
DebuggerEngineType m_engineType;
......@@ -231,7 +234,12 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget(DebuggerItemModel *model)
m_binaryChooser = new PathChooser(this);
m_binaryChooser->setExpectedKind(PathChooser::ExistingCommand);
m_binaryChooser->setMinimumWidth(400);
m_binaryChooser->setHistoryCompleter(QLatin1String("DebuggerPaths"));
m_binaryChooser->setHistoryCompleter("DebuggerPaths");
m_workingDirectoryChooser = new PathChooser(this);
m_workingDirectoryChooser->setExpectedKind(PathChooser::Directory);
m_workingDirectoryChooser->setMinimumWidth(400);
m_workingDirectoryChooser->setHistoryCompleter("DebuggerPaths");
m_cdbLabel = new QLabel(this);
m_cdbLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
......@@ -252,9 +260,12 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget(DebuggerItemModel *model)
formLayout->addRow(new QLabel(tr("Type:")), m_typeLineEdit);
formLayout->addRow(new QLabel(tr("ABIs:")), m_abis);
formLayout->addRow(new QLabel(tr("Version:")), m_versionLabel);
formLayout->addRow(new QLabel(tr("Working directory:")), m_workingDirectoryChooser);
connect(m_binaryChooser, &PathChooser::pathChanged,
this, &DebuggerItemConfigWidget::binaryPathHasChanged);
connect(m_workingDirectoryChooser, &PathChooser::pathChanged,
this, &DebuggerItemConfigWidget::store);
connect(m_displayNameLineEdit, &QLineEdit::textChanged,
this, &DebuggerItemConfigWidget::store);
}
......@@ -264,6 +275,7 @@ DebuggerItem DebuggerItemConfigWidget::item() const
DebuggerItem item(m_id);
item.setUnexpandedDisplayName(m_displayNameLineEdit->text());
item.setCommand(m_binaryChooser->fileName());
item.setWorkingDirectory(m_workingDirectoryChooser->fileName());
item.setAutoDetected(m_autodetected);
QList<ProjectExplorer::Abi> abiList;
foreach (const QString &a, m_abis->text().split(QRegExp(QLatin1String("[^A-Za-z0-9-_]+")))) {
......@@ -305,6 +317,9 @@ void DebuggerItemConfigWidget::load(const DebuggerItem *item)
m_binaryChooser->setReadOnly(item->isAutoDetected());
m_binaryChooser->setFileName(item->command());
m_workingDirectoryChooser->setReadOnly(item->isAutoDetected());
m_workingDirectoryChooser->setFileName(item->workingDirectory());
QString text;
QString versionCommand;
if (item->engineType() == CdbEngineType) {
......
......@@ -1204,7 +1204,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
}
rp.inferior.environment = Utils::Environment::systemEnvironment();
rp.stubEnvironment = Utils::Environment::systemEnvironment();
rp.debuggerEnvironment = Utils::Environment::systemEnvironment();
rp.debugger.environment = Utils::Environment::systemEnvironment();
if (!kit)
kit = guessKitFromParameters(rp);
......@@ -2912,7 +2912,7 @@ static QString formatStartParameters(DebuggerRunParameters &sp)
str << "Directory: " << QDir::toNativeSeparators(sp.inferior.workingDirectory)
<< '\n';
}
QString cmd = sp.debuggerCommand;
QString cmd = sp.debugger.executable;
if (!cmd.isEmpty())
str << "Debugger: " << QDir::toNativeSeparators(cmd) << '\n';
if (!sp.coreFile.isEmpty())
......
......@@ -354,11 +354,20 @@ static DebuggerRunControl *doCreate(DebuggerRunParameters rp, RunConfiguration *
if (rp.symbolFile.isEmpty())
rp.symbolFile = rp.inferior.executable;
rp.debugger = DebuggerKitInformation::runnable(kit);
const QByteArray envBinary = qgetenv("QTC_DEBUGGER_PATH");
if (!envBinary.isEmpty())
rp.debugger.executable = QString::fromLocal8Bit(envBinary);
if (runConfig) {
if (auto envAspect = runConfig->extraAspect<EnvironmentAspect>()) {
rp.inferior.environment = envAspect->environment(); // Correct.
rp.stubEnvironment = rp.inferior.environment; // FIXME: Wrong, but contains DYLD_IMAGE_SUFFIX
rp.debuggerEnvironment = rp.inferior.environment; // FIXME: Wrong, but contains DYLD_IMAGE_SUFFIX
// Copy over DYLD_IMAGE_SUFFIX etc
for (auto var : QStringList({"DYLD_IMAGE_SUFFIX", "DYLD_LIBRARY_PATH", "DYLD_FRAMEWORK_PATH"}))
if (rp.inferior.environment.hasKey(var))
rp.debugger.environment.set(var, rp.inferior.environment.value(var));
}
if (Project *project = runConfig->target()->project()) {
rp.projectSourceDirectory = project->projectDirectory().toString();
......@@ -380,7 +389,6 @@ static DebuggerRunControl *doCreate(DebuggerRunParameters rp, RunConfiguration *
rp.cppEngineType = DebuggerKitInformation::engineType(kit);
rp.sysRoot = SysRootKitInformation::sysRoot(kit).toString();
rp.debuggerCommand = DebuggerKitInformation::debuggerCommand(kit).toString();
rp.device = DeviceKitInformation::device(kit);
if (rp.displayName.isEmpty() && runConfig)
......
......@@ -72,7 +72,6 @@ public:
ProjectExplorer::StandardRunnable inferior;
QString displayName; // Used in the Snapshots view.
Utils::Environment debuggerEnvironment;
Utils::Environment stubEnvironment;
qint64 attachPID = InvalidPid;
QStringList solibSearchPath;
......
......@@ -45,10 +45,6 @@ void GdbAttachEngine::setupEngine()
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
showMessage("TRYING TO START ADAPTER");
if (!runParameters().inferior.workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(runParameters().inferior.workingDirectory);
m_gdbProc.setEnvironment(runParameters().debuggerEnvironment);
startGdb();
}
......
......@@ -39,6 +39,7 @@
#include <QTemporaryFile>
using namespace Utils;
using namespace ProjectExplorer;
namespace Debugger {
namespace Internal {
......@@ -121,7 +122,7 @@ static QString findExecutableFromName(const QString &fileNameFromCore, const QSt
}
GdbCoreEngine::CoreInfo
GdbCoreEngine::readExecutableNameFromCore(const QString &debuggerCommand, const QString &coreFile)
GdbCoreEngine::readExecutableNameFromCore(const StandardRunnable &debugger, const QString &coreFile)
{
CoreInfo cinfo;
#if 0
......@@ -139,7 +140,7 @@ GdbCoreEngine::readExecutableNameFromCore(const QString &debuggerCommand, const
QStringList envLang = QProcess::systemEnvironment();
Utils::Environment::setupEnglishOutput(&envLang);
proc.setEnvironment(envLang);
SynchronousProcessResponse response = proc.runBlocking(debuggerCommand, args);
SynchronousProcessResponse response = proc.runBlocking(debugger.executable, args);
if (response.result == SynchronousProcessResponse::Finished) {
QString output = response.stdOut();
......@@ -171,9 +172,8 @@ void GdbCoreEngine::continueSetupEngine()
m_tempCoreFile.close();
}
if (isCore && m_executable.isEmpty()) {
GdbCoreEngine::CoreInfo cinfo = readExecutableNameFromCore(
runParameters().debuggerCommand,
coreFileName());
GdbCoreEngine::CoreInfo cinfo =
readExecutableNameFromCore(runParameters().debugger, coreFileName());
if (cinfo.isCore) {
m_executable = cinfo.foundExecutableName;
......
......@@ -46,7 +46,8 @@ public:
QString foundExecutableName; // empty if no corresponding exec could be found
bool isCore = false;
};
static CoreInfo readExecutableNameFromCore(const QString &debuggerCmd, const QString &coreFile);
static CoreInfo readExecutableNameFromCore(const ProjectExplorer::StandardRunnable &debugger,
const QString &coreFile);
private:
void setupEngine() override;
......
......@@ -267,14 +267,19 @@ DebuggerStartMode GdbEngine::startMode() const
return runParameters().startMode;
}
QString GdbEngine::failedToStartMessage()
{
return tr("The gdb process failed to start.");
}
QString GdbEngine::errorMessage(QProcess::ProcessError error)
{
switch (error) {
case QProcess::FailedToStart:
return tr("The gdb process failed to start. Either the "
return failedToStartMessage() + ' ' + tr("Either the "
"invoked program \"%1\" is missing, or you may have insufficient "
"permissions to invoke the program.\n%2")
.arg(m_gdb, m_gdbProc.errorString());
.arg(runParameters().debugger.executable, m_gdbProc.errorString());
case QProcess::Crashed:
if (targetState() == DebuggerFinished)
return tr("The gdb process crashed some time after starting "
......@@ -860,7 +865,7 @@ void GdbEngine::interruptInferior()
connect(m_signalOperation.data(), &DeviceProcessSignalOperation::finished,
this, &GdbEngine::handleInterruptDeviceInferior);
m_signalOperation->setDebuggerCommand(runParameters().debuggerCommand);
m_signalOperation->setDebuggerCommand(runParameters().debugger.executable);
m_signalOperation->interruptProcess(inferiorPid());
} else {
interruptInferior2();
......@@ -3945,18 +3950,6 @@ bool GdbEngine::handleCliDisassemblerResult(const QString &output, DisassemblerA
return false;
}
// Binary/configuration check logic.
static QString gdbBinary(const DebuggerRunParameters &sp)
{
// 1) Environment.
const QByteArray envBinary = qgetenv("QTC_DEBUGGER_PATH");
if (!envBinary.isEmpty())
return QString::fromLocal8Bit(envBinary);
// 2) Command from profile.
return sp.debuggerCommand;
}
static SourcePathMap mergeStartParametersSourcePathMap(const DebuggerRunParameters &sp,
const SourcePathMap &in)
{
......@@ -3982,14 +3975,14 @@ void GdbEngine::startGdb(const QStringList &args)
m_gdbProc.disconnect(); // From any previous runs
const DebuggerRunParameters &rp = runParameters();
m_gdb = gdbBinary(rp);
if (m_gdb.isEmpty()) {
if (rp.debugger.executable.isEmpty()) {
handleGdbStartFailed();
handleAdapterStartFailed(
msgNoGdbBinaryForToolChain(rp.toolChainAbi),
Constants::DEBUGGER_COMMON_SETTINGS_ID);
return;
}
QStringList gdbArgs;
gdbArgs << "-i";
gdbArgs << "mi";
......@@ -4004,16 +3997,21 @@ void GdbEngine::startGdb(const QStringList &args)
connect(&m_gdbProc, &QtcProcess::readyReadStandardOutput, this, &GdbEngine::readGdbStandardOutput);
connect(&m_gdbProc, &QtcProcess::readyReadStandardError, this, &GdbEngine::readGdbStandardError);
showMessage("STARTING " + m_gdb + " " + gdbArgs.join(' '));
m_gdbProc.setCommand(m_gdb, QtcProcess::joinArgs(gdbArgs));
Environment env = Environment(m_gdbProc.systemEnvironment());
env.set("LC_NUMERIC", "C");
m_gdbProc.setEnvironment(env);
showMessage("STARTING " + rp.debugger.executable + " " + gdbArgs.join(' '));
m_gdbProc.setCommand(rp.debugger.executable, QtcProcess::joinArgs(gdbArgs));
if (QFileInfo(rp.debugger.workingDirectory).isDir())
m_gdbProc.setWorkingDirectory(rp.debugger.workingDirectory);
m_gdbProc.setEnvironment(rp.debugger.environment);
m_gdbProc.start();
if (!m_gdbProc.waitForStarted()) {
handleGdbStartFailed();
const QString msg = errorMessage(QProcess::FailedToStart);
QString msg;
QString wd = m_gdbProc.workingDirectory();
if (!QFileInfo(wd).isDir())
msg = failedToStartMessage() + ' ' + tr("The working directory \"%s\" is not usable.").arg(wd);
else
msg = errorMessage(QProcess::FailedToStart);
handleAdapterStartFailed(msg);
return;
}
......@@ -4136,7 +4134,7 @@ void GdbEngine::startGdb(const QStringList &args)
if (terminal()->isUsable())
runCommand({"set inferior-tty " + QString::fromUtf8(terminal()->slaveDevice()), NoFlags});
const QFileInfo gdbBinaryFile(m_gdb);
const QFileInfo gdbBinaryFile(rp.debugger.executable);
const QString uninstalledData = gdbBinaryFile.absolutePath() + "/data-directory/python";
runCommand({"python sys.path.insert(1, '" + dumperSourcePath + "')", NoFlags});
......
......@@ -31,6 +31,7 @@
#include <debugger/registerhandler.h>
#include <debugger/watchhandler.h>
#include <debugger/watchutils.h>
#include <debugger/debuggeritem.h>
#include <debugger/debuggertooltipmanager.h>
#include <coreplugin/id.h>
......@@ -397,13 +398,12 @@ protected:
//
void reloadDebuggingHelpers() override;
QString m_gdb;
//
// Convenience Functions
//
QString errorMessage(QProcess::ProcessError error);
void showExecutionError(const QString &message);
QString failedToStartMessage();
static QString tooltipIName(const QString &exp);
......
......@@ -121,10 +121,6 @@ void GdbPlainEngine::setupEngine()
}
gdbArgs.append("--tty=" + m_outputCollector.serverName());
QString workingDirectory = runParameters().inferior.workingDirectory;
if (!workingDirectory.isEmpty() && QFileInfo::exists(workingDirectory))
m_gdbProc.setWorkingDirectory(workingDirectory);
startGdb(gdbArgs);
}
......
......@@ -86,8 +86,6 @@ void GdbRemoteServerEngine::setupEngine()
m_uploadProc.start(arglist);
m_uploadProc.waitForStarted();
}
if (!runParameters().inferior.workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(runParameters().inferior.workingDirectory);
if (runParameters().remoteSetupNeeded) {
notifyEngineRequestRemoteSetup();
......
......@@ -247,7 +247,7 @@ void LldbEngine::setupEngine()
void LldbEngine::startLldb()
{
m_lldbCmd = runParameters().debuggerCommand;
QString lldbCmd = runParameters().debugger.executable;
connect(&m_lldbProc, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error),
this, &LldbEngine::handleLldbError);
connect(&m_lldbProc, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
......@@ -260,17 +260,17 @@ void LldbEngine::startLldb()
connect(this, &LldbEngine::outputReady,
this, &LldbEngine::handleResponse, Qt::QueuedConnection);
showMessage("STARTING LLDB: " + m_lldbCmd);
m_lldbProc.setEnvironment(runParameters().debuggerEnvironment);
if (!runParameters().inferior.workingDirectory.isEmpty())
m_lldbProc.setWorkingDirectory(runParameters().inferior.workingDirectory);
showMessage("STARTING LLDB: " + lldbCmd);
m_lldbProc.setEnvironment(runParameters().debugger.environment);
if (QFileInfo(runParameters().debugger.workingDirectory).isDir())
m_lldbProc.setWorkingDirectory(runParameters().debugger.workingDirectory);
m_lldbProc.setCommand(m_lldbCmd, QString());
m_lldbProc.setCommand(lldbCmd, QString());
m_lldbProc.start();
if (!m_lldbProc.waitForStarted()) {
const QString msg = tr("Unable to start LLDB \"%1\": %2")
.arg(m_lldbCmd, m_lldbProc.errorString());
.arg(lldbCmd, m_lldbProc.errorString());
notifyEngineSetupFailed();
showMessage("ADAPTER START FAILED");
if (!msg.isEmpty())
......@@ -852,7 +852,7 @@ QString LldbEngine::errorMessage(QProcess::ProcessError error) const
return tr("The LLDB process failed to start. Either the "
"invoked program \"%1\" is missing, or you may have insufficient "
"permissions to invoke the program.")
.arg(m_lldbCmd);
.arg(runParameters().debugger.executable);
case QProcess::Crashed:
return tr("The LLDB process crashed some time after starting "
"successfully.");
......
......@@ -150,7 +150,6 @@ private:
QString m_inbuffer;
QString m_scriptFileName;
Utils::QtcProcess m_lldbProc;
QString m_lldbCmd;