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() ...@@ -1268,7 +1268,7 @@ void AndroidConfigurations::updateAutomaticKitList()
// Update code for 3.0 beta, which shipped with a bug for the debugger settings // Update code for 3.0 beta, which shipped with a bug for the debugger settings
ToolChain *tc = ToolChainKitInformation::toolChain(k, ToolChain::Language::Cxx); 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::DebuggerItem debugger;
debugger.setCommand(tc->suggestedDebugger()); debugger.setCommand(tc->suggestedDebugger());
debugger.setEngineType(Debugger::GdbEngineType); debugger.setEngineType(Debugger::GdbEngineType);
......
...@@ -506,7 +506,7 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage ...@@ -506,7 +506,7 @@ bool CdbEngine::launchCDB(const DebuggerRunParameters &sp, QString *errorMessage
// Determine binary (force MSVC), extension lib name and path to use // Determine binary (force MSVC), extension lib name and path to use
// The extension is passed as relative name with the path variable set // The extension is passed as relative name with the path variable set
//(does not work with absolute path names) //(does not work with absolute path names)
const QString executable = sp.debuggerCommand; const QString executable = sp.debugger.executable;
if (executable.isEmpty()) { if (executable.isEmpty()) {
*errorMessage = tr("There is no CDB executable specified."); *errorMessage = tr("There is no CDB executable specified.");
return false; return false;
...@@ -975,7 +975,7 @@ void CdbEngine::doInterruptInferior(SpecialStopMode sm) ...@@ -975,7 +975,7 @@ void CdbEngine::doInterruptInferior(SpecialStopMode sm)
connect(m_signalOperation.data(), &DeviceProcessSignalOperation::finished, connect(m_signalOperation.data(), &DeviceProcessSignalOperation::finished,
this, &CdbEngine::handleDoInterruptInferior); this, &CdbEngine::handleDoInterruptInferior);
m_signalOperation->setDebuggerCommand(runParameters().debuggerCommand); m_signalOperation->setDebuggerCommand(runParameters().debugger.executable);
m_signalOperation->interruptProcess(inferiorPid()); m_signalOperation->interruptProcess(inferiorPid());
} }
......
...@@ -104,7 +104,7 @@ QDebug operator<<(QDebug str, const DebuggerRunParameters &sp) ...@@ -104,7 +104,7 @@ QDebug operator<<(QDebug str, const DebuggerRunParameters &sp)
<< " coreFile=" << sp.coreFile << " coreFile=" << sp.coreFile
<< " processArgs=" << sp.inferior.commandLineArguments << " processArgs=" << sp.inferior.commandLineArguments
<< " inferior environment=<" << sp.inferior.environment.size() << " variables>" << " inferior environment=<" << sp.inferior.environment.size() << " variables>"
<< " debugger environment=<" << sp.debuggerEnvironment.size() << " variables>" << " debugger environment=<" << sp.debugger.environment.size() << " variables>"
<< " workingDir=" << sp.inferior.workingDirectory << " workingDir=" << sp.inferior.workingDirectory
<< " attachPID=" << sp.attachPID << " attachPID=" << sp.attachPID
<< " useTerminal=" << sp.useTerminal << " useTerminal=" << sp.useTerminal
......
...@@ -27,10 +27,12 @@ ...@@ -27,10 +27,12 @@
#include "debugger_global.h" #include "debugger_global.h"
#include "debuggerconstants.h" #include "debuggerconstants.h"
#include "debuggeritem.h"
#include "debuggerprotocol.h" #include "debuggerprotocol.h"
#include "debuggerstartparameters.h" #include "debuggerstartparameters.h"
#include <projectexplorer/devicesupport/idevice.h> #include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/runnables.h>
#include <texteditor/textmark.h> #include <texteditor/textmark.h>
#include <QObject> #include <QObject>
...@@ -89,7 +91,7 @@ public: ...@@ -89,7 +91,7 @@ public:
bool breakOnMain = false; bool breakOnMain = false;
bool multiProcess = false; // Whether to set detach-on-fork off. bool multiProcess = false; // Whether to set detach-on-fork off.
QString debuggerCommand; ProjectExplorer::StandardRunnable debugger;
QString coreFile; QString coreFile;
QString overrideStartScript; // Used in attach to core and remote debugging QString overrideStartScript; // Used in attach to core and remote debugging
QString startMessage; // First status message shown. QString startMessage; // First status message shown.
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "debuggeroptionspage.h" #include "debuggeroptionspage.h"
#include "debuggerprotocol.h" #include "debuggerprotocol.h"
#include <coreplugin/coreicons.h>
#include <projectexplorer/abi.h> #include <projectexplorer/abi.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
...@@ -59,6 +60,7 @@ const char DEBUGGER_INFORMATION_AUTODETECTION_SOURCE[] = "AutoDetectionSource"; ...@@ -59,6 +60,7 @@ const char DEBUGGER_INFORMATION_AUTODETECTION_SOURCE[] = "AutoDetectionSource";
const char DEBUGGER_INFORMATION_VERSION[] = "Version"; const char DEBUGGER_INFORMATION_VERSION[] = "Version";
const char DEBUGGER_INFORMATION_ABIS[] = "Abis"; const char DEBUGGER_INFORMATION_ABIS[] = "Abis";
const char DEBUGGER_INFORMATION_LASTMODIFIED[] = "LastModified"; const char DEBUGGER_INFORMATION_LASTMODIFIED[] = "LastModified";
const char DEBUGGER_INFORMATION_WORKINGDIRECTORY[] = "WorkingDirectory";
namespace Debugger { namespace Debugger {
...@@ -81,8 +83,9 @@ DebuggerItem::DebuggerItem(const QVariant &id) ...@@ -81,8 +83,9 @@ DebuggerItem::DebuggerItem(const QVariant &id)
DebuggerItem::DebuggerItem(const QVariantMap &data) 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_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_unexpandedDisplayName = data.value(QLatin1String(DEBUGGER_INFORMATION_DISPLAYNAME)).toString();
m_isAutoDetected = data.value(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTED), false).toBool(); m_isAutoDetected = data.value(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTED), false).toBool();
m_autoDetectionSource = data.value(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTION_SOURCE)).toString(); m_autoDetectionSource = data.value(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTION_SOURCE)).toString();
...@@ -213,9 +216,15 @@ QDateTime DebuggerItem::lastModified() const ...@@ -213,9 +216,15 @@ QDateTime DebuggerItem::lastModified() const
return m_lastModified; 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 QString DebuggerItem::validityMessage() const
...@@ -230,7 +239,8 @@ bool DebuggerItem::operator==(const DebuggerItem &other) const ...@@ -230,7 +239,8 @@ bool DebuggerItem::operator==(const DebuggerItem &other) const
return m_id == other.m_id return m_id == other.m_id
&& m_unexpandedDisplayName == other.m_unexpandedDisplayName && m_unexpandedDisplayName == other.m_unexpandedDisplayName
&& m_isAutoDetected == other.m_isAutoDetected && m_isAutoDetected == other.m_isAutoDetected
&& m_command == other.m_command; && m_command == other.m_command
&& m_workingDirectory == other.m_workingDirectory;
} }
QVariantMap DebuggerItem::toMap() const QVariantMap DebuggerItem::toMap() const
...@@ -239,6 +249,7 @@ 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_DISPLAYNAME), m_unexpandedDisplayName);
data.insert(QLatin1String(DEBUGGER_INFORMATION_ID), m_id); data.insert(QLatin1String(DEBUGGER_INFORMATION_ID), m_id);
data.insert(QLatin1String(DEBUGGER_INFORMATION_COMMAND), m_command.toString()); 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_ENGINETYPE), int(m_engineType));
data.insert(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTED), m_isAutoDetected); data.insert(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTED), m_isAutoDetected);
data.insert(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTION_SOURCE), m_autoDetectionSource); data.insert(QLatin1String(DEBUGGER_INFORMATION_AUTODETECTION_SOURCE), m_autoDetectionSource);
......
...@@ -94,7 +94,7 @@ public: ...@@ -94,7 +94,7 @@ public:
QStringList abiNames() const; QStringList abiNames() const;
QDateTime lastModified() const; QDateTime lastModified() const;
bool isGood() const; QIcon decoration() const;
QString validityMessage() const; QString validityMessage() const;
bool operator==(const DebuggerItem &other) const; bool operator==(const DebuggerItem &other) const;
...@@ -102,6 +102,9 @@ public: ...@@ -102,6 +102,9 @@ public:
void reinitializeFromFile(); void reinitializeFromFile();
Utils::FileName workingDirectory() const { return m_workingDirectory; }
void setWorkingDirectory(const Utils::FileName &workingPath) { m_workingDirectory = workingPath; }
private: private:
DebuggerItem(const QVariant &id); DebuggerItem(const QVariant &id);
void initMacroExpander(); void initMacroExpander();
...@@ -110,6 +113,7 @@ private: ...@@ -110,6 +113,7 @@ private:
QString m_unexpandedDisplayName; QString m_unexpandedDisplayName;
DebuggerEngineType m_engineType; DebuggerEngineType m_engineType;
Utils::FileName m_command; Utils::FileName m_command;
Utils::FileName m_workingDirectory;
bool m_isAutoDetected; bool m_isAutoDetected;
QString m_autoDetectionSource; QString m_autoDetectionSource;
QString m_version; QString m_version;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <projectexplorer/toolchain.h> #include <projectexplorer/toolchain.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <utils/environment.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/macroexpander.h> #include <utils/macroexpander.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
...@@ -244,6 +245,18 @@ const DebuggerItem *DebuggerKitInformation::debugger(const Kit *kit) ...@@ -244,6 +245,18 @@ const DebuggerItem *DebuggerKitInformation::debugger(const Kit *kit)
return DebuggerItemManager::findById(id); 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) bool DebuggerKitInformation::isValidDebugger(const Kit *k)
{ {
return debuggerConfigurationErrors(k) == 0; return debuggerConfigurationErrors(k) == 0;
...@@ -326,14 +339,6 @@ KitInformation::ItemList DebuggerKitInformation::toUserOutput(const Kit *k) cons ...@@ -326,14 +339,6 @@ KitInformation::ItemList DebuggerKitInformation::toUserOutput(const Kit *k) cons
return ItemList() << qMakePair(tr("Debugger"), displayString(k)); 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) DebuggerEngineType DebuggerKitInformation::engineType(const Kit *k)
{ {
const DebuggerItem *item = debugger(k); const DebuggerItem *item = debugger(k);
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "debuggerconstants.h" #include "debuggerconstants.h"
#include <projectexplorer/kitinformation.h> #include <projectexplorer/kitinformation.h>
#include <projectexplorer/runnables.h>
namespace Debugger { namespace Debugger {
class DebuggerItem; class DebuggerItem;
...@@ -49,6 +50,7 @@ public: ...@@ -49,6 +50,7 @@ public:
void fix(ProjectExplorer::Kit *k) override; void fix(ProjectExplorer::Kit *k) override;
static const DebuggerItem *debugger(const ProjectExplorer::Kit *kit); 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 QList<ProjectExplorer::Task> validateDebugger(const ProjectExplorer::Kit *k);
static bool isValidDebugger(const ProjectExplorer::Kit *k); static bool isValidDebugger(const ProjectExplorer::Kit *k);
...@@ -61,7 +63,6 @@ public: ...@@ -61,7 +63,6 @@ public:
static void setDebugger(ProjectExplorer::Kit *k, const QVariant &id); static void setDebugger(ProjectExplorer::Kit *k, const QVariant &id);
static Core::Id id(); static Core::Id id();
static Utils::FileName debuggerCommand(const ProjectExplorer::Kit *k);
static DebuggerEngineType engineType(const ProjectExplorer::Kit *k); static DebuggerEngineType engineType(const ProjectExplorer::Kit *k);
static QString displayString(const ProjectExplorer::Kit *k); static QString displayString(const ProjectExplorer::Kit *k);
}; };
......
...@@ -65,8 +65,6 @@ public: ...@@ -65,8 +65,6 @@ public:
QVariant data(int column, int role) const QVariant data(int column, int role) const
{ {
static const QIcon errorIcon = Core::Icons::ERROR.icon();
switch (role) { switch (role) {
case Qt::DisplayRole: case Qt::DisplayRole:
switch (column) { switch (column) {
...@@ -74,19 +72,23 @@ public: ...@@ -74,19 +72,23 @@ public:
case 1: return m_item.command().toUserOutput(); case 1: return m_item.command().toUserOutput();
case 2: return m_item.engineTypeName(); 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: { case Qt::ToolTipRole:
QFont font;
font.setBold(m_changed);
return font;
}
case Qt::DecorationRole: {
if (column == 0 && !m_item.isGood())
return errorIcon;
}
case Qt::ToolTipRole: {
return m_item.validityMessage(); return m_item.validityMessage();
}
} }
return QVariant(); return QVariant();
} }
...@@ -214,6 +216,7 @@ private: ...@@ -214,6 +216,7 @@ private:
QLabel *m_cdbLabel; QLabel *m_cdbLabel;
QLineEdit *m_versionLabel; QLineEdit *m_versionLabel;
PathChooser *m_binaryChooser; PathChooser *m_binaryChooser;
PathChooser *m_workingDirectoryChooser;
QLineEdit *m_abis; QLineEdit *m_abis;
bool m_autodetected; bool m_autodetected;
DebuggerEngineType m_engineType; DebuggerEngineType m_engineType;
...@@ -231,7 +234,12 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget(DebuggerItemModel *model) ...@@ -231,7 +234,12 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget(DebuggerItemModel *model)
m_binaryChooser = new PathChooser(this); m_binaryChooser = new PathChooser(this);
m_binaryChooser->setExpectedKind(PathChooser::ExistingCommand); m_binaryChooser->setExpectedKind(PathChooser::ExistingCommand);
m_binaryChooser->setMinimumWidth(400); 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 = new QLabel(this);
m_cdbLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); m_cdbLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
...@@ -252,9 +260,12 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget(DebuggerItemModel *model) ...@@ -252,9 +260,12 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget(DebuggerItemModel *model)
formLayout->addRow(new QLabel(tr("Type:")), m_typeLineEdit); formLayout->addRow(new QLabel(tr("Type:")), m_typeLineEdit);
formLayout->addRow(new QLabel(tr("ABIs:")), m_abis); formLayout->addRow(new QLabel(tr("ABIs:")), m_abis);
formLayout->addRow(new QLabel(tr("Version:")), m_versionLabel); formLayout->addRow(new QLabel(tr("Version:")), m_versionLabel);
formLayout->addRow(new QLabel(tr("Working directory:")), m_workingDirectoryChooser);
connect(m_binaryChooser, &PathChooser::pathChanged, connect(m_binaryChooser, &PathChooser::pathChanged,
this, &DebuggerItemConfigWidget::binaryPathHasChanged); this, &DebuggerItemConfigWidget::binaryPathHasChanged);
connect(m_workingDirectoryChooser, &PathChooser::pathChanged,
this, &DebuggerItemConfigWidget::store);
connect(m_displayNameLineEdit, &QLineEdit::textChanged, connect(m_displayNameLineEdit, &QLineEdit::textChanged,
this, &DebuggerItemConfigWidget::store); this, &DebuggerItemConfigWidget::store);
} }
...@@ -264,6 +275,7 @@ DebuggerItem DebuggerItemConfigWidget::item() const ...@@ -264,6 +275,7 @@ DebuggerItem DebuggerItemConfigWidget::item() const
DebuggerItem item(m_id); DebuggerItem item(m_id);
item.setUnexpandedDisplayName(m_displayNameLineEdit->text()); item.setUnexpandedDisplayName(m_displayNameLineEdit->text());
item.setCommand(m_binaryChooser->fileName()); item.setCommand(m_binaryChooser->fileName());
item.setWorkingDirectory(m_workingDirectoryChooser->fileName());
item.setAutoDetected(m_autodetected); item.setAutoDetected(m_autodetected);
QList<ProjectExplorer::Abi> abiList; QList<ProjectExplorer::Abi> abiList;
foreach (const QString &a, m_abis->text().split(QRegExp(QLatin1String("[^A-Za-z0-9-_]+")))) { foreach (const QString &a, m_abis->text().split(QRegExp(QLatin1String("[^A-Za-z0-9-_]+")))) {
...@@ -305,6 +317,9 @@ void DebuggerItemConfigWidget::load(const DebuggerItem *item) ...@@ -305,6 +317,9 @@ void DebuggerItemConfigWidget::load(const DebuggerItem *item)
m_binaryChooser->setReadOnly(item->isAutoDetected()); m_binaryChooser->setReadOnly(item->isAutoDetected());
m_binaryChooser->setFileName(item->command()); m_binaryChooser->setFileName(item->command());
m_workingDirectoryChooser->setReadOnly(item->isAutoDetected());
m_workingDirectoryChooser->setFileName(item->workingDirectory());
QString text; QString text;
QString versionCommand; QString versionCommand;
if (item->engineType() == CdbEngineType) { if (item->engineType() == CdbEngineType) {
......
...@@ -1204,7 +1204,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, ...@@ -1204,7 +1204,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
} }
rp.inferior.environment = Utils::Environment::systemEnvironment(); rp.inferior.environment = Utils::Environment::systemEnvironment();
rp.stubEnvironment = Utils::Environment::systemEnvironment(); rp.stubEnvironment = Utils::Environment::systemEnvironment();
rp.debuggerEnvironment = Utils::Environment::systemEnvironment(); rp.debugger.environment = Utils::Environment::systemEnvironment();
if (!kit) if (!kit)
kit = guessKitFromParameters(rp); kit = guessKitFromParameters(rp);
...@@ -2912,7 +2912,7 @@ static QString formatStartParameters(DebuggerRunParameters &sp) ...@@ -2912,7 +2912,7 @@ static QString formatStartParameters(DebuggerRunParameters &sp)
str << "Directory: " << QDir::toNativeSeparators(sp.inferior.workingDirectory) str << "Directory: " << QDir::toNativeSeparators(sp.inferior.workingDirectory)
<< '\n'; << '\n';
} }
QString cmd = sp.debuggerCommand; QString cmd = sp.debugger.executable;
if (!cmd.isEmpty()) if (!cmd.isEmpty())
str << "Debugger: " << QDir::toNativeSeparators(cmd) << '\n'; str << "Debugger: " << QDir::toNativeSeparators(cmd) << '\n';
if (!sp.coreFile.isEmpty()) if (!sp.coreFile.isEmpty())
......
...@@ -354,11 +354,20 @@ static DebuggerRunControl *doCreate(DebuggerRunParameters rp, RunConfiguration * ...@@ -354,11 +354,20 @@ static DebuggerRunControl *doCreate(DebuggerRunParameters rp, RunConfiguration *
if (rp.symbolFile.isEmpty()) if (rp.symbolFile.isEmpty())
rp.symbolFile = rp.inferior.executable; 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 (runConfig) {
if (auto envAspect = runConfig->extraAspect<EnvironmentAspect>()) { if (auto envAspect = runConfig->extraAspect<EnvironmentAspect>()) {
rp.inferior.environment = envAspect->environment(); // Correct. rp.inferior.environment = envAspect->environment(); // Correct.
rp.stubEnvironment = rp.inferior.environment; // FIXME: Wrong, but contains DYLD_IMAGE_SUFFIX 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()) { if (Project *project = runConfig->target()->project()) {
rp.projectSourceDirectory = project->projectDirectory().toString(); rp.projectSourceDirectory = project->projectDirectory().toString();
...@@ -380,7 +389,6 @@ static DebuggerRunControl *doCreate(DebuggerRunParameters rp, RunConfiguration * ...@@ -380,7 +389,6 @@ static DebuggerRunControl *doCreate(DebuggerRunParameters rp, RunConfiguration *
rp.cppEngineType = DebuggerKitInformation::engineType(kit); rp.cppEngineType = DebuggerKitInformation::engineType(kit);
rp.sysRoot = SysRootKitInformation::sysRoot(kit).toString(); rp.sysRoot = SysRootKitInformation::sysRoot(kit).toString();
rp.debuggerCommand = DebuggerKitInformation::debuggerCommand(kit).toString();
rp.device = DeviceKitInformation::device(kit); rp.device = DeviceKitInformation::device(kit);
if (rp.displayName.isEmpty() && runConfig) if (rp.displayName.isEmpty() && runConfig)
......
...@@ -72,7 +72,6 @@ public: ...@@ -72,7 +72,6 @@ public:
ProjectExplorer::StandardRunnable inferior; ProjectExplorer::StandardRunnable inferior;
QString displayName; // Used in the Snapshots view. QString displayName; // Used in the Snapshots view.
Utils::Environment debuggerEnvironment;
Utils::Environment stubEnvironment; Utils::Environment stubEnvironment;
qint64 attachPID = InvalidPid; qint64 attachPID = InvalidPid;
QStringList solibSearchPath; QStringList solibSearchPath;
......
...@@ -45,10 +45,6 @@ void GdbAttachEngine::setupEngine() ...@@ -45,10 +45,6 @@ void GdbAttachEngine::setupEngine()
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
showMessage("TRYING TO START ADAPTER"); showMessage("TRYING TO START ADAPTER");
if (!runParameters().inferior.workingDirectory.isEmpty())
m_gdbProc.setWorkingDirectory(runParameters().inferior.workingDirectory);
m_gdbProc.setEnvironment(runParameters().debuggerEnvironment);
startGdb(); startGdb();
} }
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <QTemporaryFile> #include <QTemporaryFile>
using namespace Utils; using namespace Utils;
using namespace ProjectExplorer;
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
...@@ -121,7 +122,7 @@ static QString findExecutableFromName(const QString &fileNameFromCore, const QSt ...@@ -121,7 +122,7 @@ static QString findExecutableFromName(const QString &fileNameFromCore, const QSt
} }
GdbCoreEngine::CoreInfo GdbCoreEngine::CoreInfo
GdbCoreEngine::readExecutableNameFromCore(const QString &debuggerCommand, const QString &coreFile) GdbCoreEngine::readExecutableNameFromCore(const StandardRunnable &debugger, const QString &coreFile)
{ {
CoreInfo cinfo; CoreInfo cinfo;
#if 0 #if 0
...@@ -139,7 +140,7 @@ GdbCoreEngine::readExecutableNameFromCore(const QString &debuggerCommand, const ...@@ -139,7 +140,7 @@ GdbCoreEngine::readExecutableNameFromCore(const QString &debuggerCommand, const
QStringList envLang = QProcess::systemEnvironment(); QStringList envLang = QProcess::systemEnvironment();
Utils::Environment::setupEnglishOutput(&envLang); Utils::Environment::setupEnglishOutput(&envLang);