Commit 60a8442d authored by hjk's avatar hjk

Debugger: Rework start parameter completion.

It's again a linear process now, with explicit entrance point for
all users.

Task-number: QTCREATORBUG-14618
Change-Id: I96c08947270ce34d7bc6c8be1d7f350dbfa14794
Reviewed-by: default avatarKai Koehne <kai.koehne@theqtcompany.com>
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent f886c701
......@@ -267,14 +267,14 @@ static inline bool validMode(DebuggerStartMode sm)
}
// Accessed by RunControlFactory
DebuggerEngine *createCdbEngine(const DebuggerRunParameters &rp, QString *errorMessage)
DebuggerEngine *createCdbEngine(const DebuggerRunParameters &rp, QStringList *errors)
{
if (HostOsInfo::isWindowsHost()) {
if (validMode(rp.startMode))
return new CdbEngine(rp);
*errorMessage = QLatin1String("Internal error: Invalid start parameters passed for thee CDB engine.");
errors->append(QLatin1String("Internal error: Invalid start parameters passed for thee CDB engine."));
} else {
*errorMessage = QString::fromLatin1("Unsupported debug mode");
errors->append(QString::fromLatin1("Unsupported debug mode"));
}
return 0;
}
......
......@@ -358,7 +358,7 @@ void StartApplicationDialog::updateState()
d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(okEnabled);
}
bool StartApplicationDialog::run(QWidget *parent, DebuggerRunParameters *rp)
bool StartApplicationDialog::run(QWidget *parent, DebuggerRunParameters *rp, Kit **kit)
{
const bool attachRemote = rp->startMode == AttachToRemoteServer;
const QString settingsGroup = QLatin1String("DebugMode");
......@@ -409,11 +409,6 @@ bool StartApplicationDialog::run(QWidget *parent, DebuggerRunParameters *rp)
settings->endGroup();
}
Kit *kit = dialog.d->kitChooser->currentKit();
QTC_ASSERT(kit, return false);
bool res = fillParametersFromKit(rp, kit);
QTC_ASSERT(res, return false);
rp->executable = newParameters.localExecutable;
const QString inputAddress = dialog.d->serverAddressEdit->text();
if (!inputAddress.isEmpty())
......@@ -430,10 +425,13 @@ bool StartApplicationDialog::run(QWidget *parent, DebuggerRunParameters *rp)
rp->serverStartScript = newParameters.serverStartScript;
rp->debugInfoLocation = newParameters.debugInfoLocation;
IDevice::ConstPtr dev = DeviceKitInformation::device(kit);
Kit *k = dialog.d->kitChooser->currentKit();
IDevice::ConstPtr dev = DeviceKitInformation::device(k);
bool isLocal = !dev || (dev->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
if (!attachRemote)
rp->startMode = isLocal ? StartExternal : StartRemoteProcess;
if (kit)
*kit = k;
return true;
}
......
......@@ -85,7 +85,7 @@ public:
explicit StartApplicationDialog(QWidget *parent);
~StartApplicationDialog();
static bool run(QWidget *parent, DebuggerRunParameters *rp);
static bool run(QWidget *parent, DebuggerRunParameters *rp, ProjectExplorer::Kit **kit);
private slots:
void historyIndexChanged(int);
......
......@@ -92,22 +92,6 @@ enum { debug = 0 };
#include <valgrind/callgrind.h>
#endif
///////////////////////////////////////////////////////////////////////
//
// DebuggerRunParameters
//
///////////////////////////////////////////////////////////////////////
DebuggerRunParameters::DebuggerRunParameters()
: isSnapshot(false),
testCase(0)
{}
void DebuggerRunParameters::initialize(const DebuggerStartParameters &sp)
{
DebuggerStartParameters::operator=(sp);
}
// VariableManager Prefix
const char PrefixDebugExecutable[] = "DebuggedExecutable";
......
......@@ -83,9 +83,7 @@ class ThreadId;
class DebuggerRunParameters : public DebuggerStartParameters
{
public:
DebuggerRunParameters();
void initialize(const DebuggerStartParameters &sp);
DebuggerRunParameters() {}
QString coreFile;
QString overrideStartScript; // Used in attach to core and remote debugging
......@@ -98,13 +96,13 @@ public:
QString serverStartScript;
QString localMountDir;
ProjectExplorer::IDevice::ConstPtr device;
bool isSnapshot; // Set if created internally.
bool isSnapshot = false; // Set if created internally.
// Used by AttachCrashedExternal.
QString crashParameter;
// For Debugger testing.
int testCase;
int testCase = 0;
};
class UpdateParameters
......@@ -427,12 +425,9 @@ private:
DebuggerEnginePrivate *d;
};
DebuggerEngine *createEngine(DebuggerEngineType et, const DebuggerRunParameters &rp, QString *errorMessage);
bool fillParametersFromKit(DebuggerStartParameters *sp, const ProjectExplorer::Kit *kit, QString *errorMessage = 0);
DebuggerRunControl *createAndScheduleRun(const DebuggerRunParameters &rp);
DebuggerEngine *createEngine(DebuggerEngineType et, const DebuggerRunParameters &rp, QStringList *errors);
DebuggerRunControl *createAndScheduleRun(const DebuggerRunParameters &rp, const ProjectExplorer::Kit *kit);
} // namespace Internal
} // namespace Debugger
......
......@@ -957,7 +957,7 @@ public:
DebuggerMainWindow *m_mainWindow;
Id m_previousMode;
QList<DebuggerRunParameters> m_scheduledStarts;
QVector<QPair<DebuggerRunParameters, Kit *>> m_scheduledStarts;
ProxyAction *m_visibleStartAction;
ProxyAction *m_hiddenStopAction;
......@@ -1183,13 +1183,11 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
}
}
}
if (!fillParametersFromKit(&rp, kit, errorMessage))
return false;
if (rp.startMode == StartExternal) {
rp.displayName = tr("Executable file \"%1\"").arg(rp.executable);
rp.startMessage = tr("Debugging file %1.").arg(rp.executable);
}
m_scheduledStarts.append(rp);
m_scheduledStarts.append(QPair<DebuggerRunParameters, Kit *>(rp, kit));
return true;
}
// -wincrashevent <event-handle>:<pid>. A handle used for
......@@ -1204,8 +1202,6 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
return false;
}
DebuggerRunParameters rp;
if (!fillParametersFromKit(&rp, findUniversalCdbKit(), errorMessage))
return false;
rp.startMode = AttachCrashedExternal;
rp.crashParameter = it->section(QLatin1Char(':'), 0, 0);
rp.attachPID = it->section(QLatin1Char(':'), 1, 1).toULongLong();
......@@ -1216,7 +1212,7 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
"does not match the pattern <handle>:<pid>.").arg(*it, option);
return false;
}
m_scheduledStarts.append(rp);
m_scheduledStarts.append(QPair<DebuggerRunParameters, Kit *>(rp, findUniversalCdbKit()));
return true;
}
......@@ -1320,8 +1316,9 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project)
void DebuggerPluginPrivate::startAndDebugApplication()
{
DebuggerRunParameters rp;
if (StartApplicationDialog::run(ICore::dialogParent(), &rp))
createAndScheduleRun(rp);
Kit *kit;
if (StartApplicationDialog::run(ICore::dialogParent(), &rp, &kit))
createAndScheduleRun(rp, kit);
}
void DebuggerPluginPrivate::attachCore()
......@@ -1349,8 +1346,6 @@ void DebuggerPluginPrivate::attachCore()
QString display = dlg.useLocalCoreFile() ? dlg.localCoreFile() : dlg.remoteCoreFile();
DebuggerRunParameters rp;
bool res = fillParametersFromKit(&rp, dlg.kit());
QTC_ASSERT(res, return);
rp.masterEngineType = DebuggerKitInformation::engineType(dlg.kit());
rp.executable = dlg.localExecutableFile();
rp.coreFile = dlg.localCoreFile();
......@@ -1358,7 +1353,7 @@ void DebuggerPluginPrivate::attachCore()
rp.startMode = AttachCore;
rp.closeMode = DetachAtClose;
rp.overrideStartScript = dlg.overrideStartScript();
createAndScheduleRun(rp);
createAndScheduleRun(rp, dlg.kit());
}
void DebuggerPluginPrivate::startRemoteCdbSession()
......@@ -1367,8 +1362,6 @@ void DebuggerPluginPrivate::startRemoteCdbSession()
DebuggerRunParameters rp;
Kit *kit = findUniversalCdbKit();
QTC_ASSERT(kit, return);
bool res = fillParametersFromKit(&rp, kit);
QTC_ASSERT(res, return);
rp.startMode = AttachToRemoteServer;
rp.closeMode = KillAtClose;
StartRemoteCdbDialog dlg(ICore::dialogParent());
......@@ -1380,17 +1373,18 @@ void DebuggerPluginPrivate::startRemoteCdbSession()
return;
rp.remoteChannel = dlg.connection();
setConfigValue(connectionKey, rp.remoteChannel);
createAndScheduleRun(rp);
createAndScheduleRun(rp, kit);
}
void DebuggerPluginPrivate::attachToRemoteServer()
{
DebuggerRunParameters rp;
Kit *kit;
rp.startMode = AttachToRemoteServer;
if (StartApplicationDialog::run(ICore::dialogParent(), &rp)) {
if (StartApplicationDialog::run(ICore::dialogParent(), &rp, &kit)) {
rp.closeMode = KillAtClose;
rp.serverStartScript.clear();
createAndScheduleRun(rp);
createAndScheduleRun(rp, kit);
}
}
......@@ -1488,15 +1482,13 @@ DebuggerRunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit,
}
DebuggerRunParameters rp;
bool res = fillParametersFromKit(&rp, kit);
QTC_ASSERT(res, return 0);
rp.attachPID = process.pid;
rp.displayName = tr("Process %1").arg(process.pid);
rp.executable = process.exe;
rp.startMode = AttachExternal;
rp.closeMode = DetachAtClose;
rp.continueAfterAttach = contAfterAttach;
return createAndScheduleRun(rp);
return createAndScheduleRun(rp, kit);
}
void DebuggerPlugin::attachExternalApplication(RunControl *rc)
......@@ -1511,9 +1503,7 @@ void DebuggerPlugin::attachExternalApplication(RunControl *rc)
if (const RunConfiguration *runConfiguration = rc->runConfiguration())
if (const Target *target = runConfiguration->target())
kit = target->kit();
bool res = fillParametersFromKit(&rp, kit);
QTC_ASSERT(res, return);
createAndScheduleRun(rp);
createAndScheduleRun(rp, kit);
}
void DebuggerPluginPrivate::attachToQmlPort()
......@@ -1536,8 +1526,6 @@ void DebuggerPluginPrivate::attachToQmlPort()
Kit *kit = dlg.kit();
QTC_ASSERT(kit, return);
bool res = fillParametersFromKit(&rp, kit);
QTC_ASSERT(res, return);
setConfigValue("LastQmlServerPort", dlg.port());
setConfigValue("LastProfile", kit->id().toSetting());
......@@ -1568,8 +1556,7 @@ void DebuggerPluginPrivate::attachToQmlPort()
rp.projectSourceDirectory =
!projects.isEmpty() ? projects.first()->projectDirectory().toString() : QString();
rp.projectSourceFiles = sourceFiles;
rp.sysRoot = SysRootKitInformation::sysRoot(kit).toString();
createAndScheduleRun(rp);
createAndScheduleRun(rp, kit);
}
void DebuggerPluginPrivate::enableReverseDebuggingTriggered(const QVariant &value)
......@@ -1582,8 +1569,8 @@ void DebuggerPluginPrivate::enableReverseDebuggingTriggered(const QVariant &valu
void DebuggerPluginPrivate::runScheduled()
{
foreach (const DebuggerRunParameters &rp, m_scheduledStarts)
createAndScheduleRun(rp);
for (int i = 0, n = m_scheduledStarts.size(); i != n; ++i)
createAndScheduleRun(m_scheduledStarts.at(i).first, m_scheduledStarts.at(i).second);
}
void DebuggerPluginPrivate::editorOpened(IEditor *editor)
......@@ -3375,7 +3362,7 @@ void DebuggerPluginPrivate::testUnloadProject()
void DebuggerPluginPrivate::testRunProject(const DebuggerRunParameters &rp, const TestCallBack &cb)
{
m_testCallbacks.append(cb);
RunControl *rc = createAndScheduleRun(rp);
RunControl *rc = createAndScheduleRun(rp, 0);
connect(rc, &RunControl::finished, this, &DebuggerPluginPrivate::testRunControlFinished);
}
......
This diff is collapsed.
......@@ -43,8 +43,8 @@ class DebuggerStartParameters;
class DebuggerRunControl;
namespace Internal {
class DebuggerRunParameters;
DebuggerRunControl *createDebuggerRunControlInternal(const DebuggerRunParameters &, QString *);
class DebuggerEngine;
class DebuggerRunControlCreator;
}
DEBUGGER_EXPORT DebuggerRunControl *createDebuggerRunControl(const DebuggerStartParameters &sp,
......@@ -54,8 +54,6 @@ DEBUGGER_EXPORT bool fillParametersFromRunConfiguration(DebuggerStartParameters
const ProjectExplorer::RunConfiguration *runConfig,
QString *errorMessage);
namespace Internal { class DebuggerEngine; }
class DEBUGGER_EXPORT DebuggerRunControl
: public ProjectExplorer::RunControl
{
......@@ -92,8 +90,7 @@ signals:
private:
void handleFinished();
friend DebuggerRunControl *Debugger::Internal::createDebuggerRunControlInternal(
const Internal::DebuggerRunParameters &rp, QString *errorMessage);
friend class Internal::DebuggerRunControlCreator;
DebuggerRunControl(ProjectExplorer::RunConfiguration *runConfig,
Internal::DebuggerEngine *engine);
......
......@@ -3526,7 +3526,7 @@ void GdbEngine::handleMakeSnapshot(const DebuggerResponse &response, const QStri
}
rp.displayName = function + _(": ") + QDateTime::currentDateTime().toString();
rp.isSnapshot = true;
createAndScheduleRun(rp);
createAndScheduleRun(rp, 0);
} else {
QByteArray msg = response.data["msg"].data();
AsynchronousMessageBox::critical(tr("Snapshot Creation Error"),
......
......@@ -213,8 +213,6 @@ void GdbServerStarter::attach(int port)
}
DebuggerRunParameters rp;
bool res = fillParametersFromKit(&rp, d->kit);
QTC_ASSERT(res, return);
rp.masterEngineType = GdbEngineType;
rp.connParams.port = port;
rp.remoteChannel = rp.connParams.host + QLatin1Char(':') + QString::number(rp.connParams.port);
......@@ -222,7 +220,7 @@ void GdbServerStarter::attach(int port)
rp.executable = localExecutable;
rp.startMode = AttachToRemoteServer;
rp.closeMode = KillAtClose;
createAndScheduleRun(rp);
createAndScheduleRun(rp, d->kit);
}
void GdbServerStarter::handleProcessClosed(int status)
......
......@@ -60,10 +60,9 @@ enum { debug = 0 };
} \
} while (0)
DebuggerEngine *createQmlCppEngine(const DebuggerRunParameters &sp,
QString *errorMessage)
DebuggerEngine *createQmlCppEngine(const DebuggerRunParameters &sp, QStringList *errors)
{
QmlCppEngine *newEngine = new QmlCppEngine(sp, errorMessage);
QmlCppEngine *newEngine = new QmlCppEngine(sp, errors);
if (newEngine->cppEngine())
return newEngine;
delete newEngine;
......@@ -77,14 +76,17 @@ DebuggerEngine *createQmlCppEngine(const DebuggerRunParameters &sp,
//
////////////////////////////////////////////////////////////////////////
QmlCppEngine::QmlCppEngine(const DebuggerRunParameters &rp, QString *errorMessage)
QmlCppEngine::QmlCppEngine(const DebuggerRunParameters &rp, QStringList *errors)
: DebuggerEngine(rp)
{
setObjectName(QLatin1String("QmlCppEngine"));
m_qmlEngine = new QmlEngine(rp, this);
m_cppEngine = createEngine(rp.cppEngineType, rp, errorMessage);
QStringList innerErrors;
m_cppEngine = createEngine(rp.cppEngineType, rp, &innerErrors);
if (!m_cppEngine) {
*errorMessage = tr("The slave debugging engine required for combined QML/C++-Debugging could not be created: %1").arg(*errorMessage);
errors->append(tr("The slave debugging engine required for combined "
"QML/C++-Debugging could not be created: %1")
.arg(innerErrors.join(QLatin1Char('\n'))));
return;
}
m_cppEngine->setMasterEngine(this);
......
......@@ -43,7 +43,7 @@ class QmlCppEngine : public DebuggerEngine
Q_OBJECT
public:
QmlCppEngine(const DebuggerRunParameters &sp, QString *errorMessage);
QmlCppEngine(const DebuggerRunParameters &sp, QStringList *errors);
~QmlCppEngine();
bool canDisplayTooltip() const;
......
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