forked from qt-creator/qt-creator
Debugger: Replace a few more uses of setRunParameters
Change-Id: I8f35bcd3812402cda7d3c69eb01ed3d3fb9e396a Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -367,9 +367,8 @@ void StartApplicationDialog::updateState()
|
||||
d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(okEnabled);
|
||||
}
|
||||
|
||||
bool StartApplicationDialog::run(QWidget *parent, DebuggerRunParameters *rp, Kit **kit)
|
||||
void StartApplicationDialog::run(bool attachRemote)
|
||||
{
|
||||
const bool attachRemote = rp->startMode == AttachToRemoteServer;
|
||||
const QString settingsGroup = QLatin1String("DebugMode");
|
||||
const QString arrayName = QLatin1String("StartApplication");
|
||||
|
||||
@@ -389,7 +388,7 @@ bool StartApplicationDialog::run(QWidget *parent, DebuggerRunParameters *rp, Kit
|
||||
settings->endArray();
|
||||
settings->endGroup();
|
||||
|
||||
StartApplicationDialog dialog(parent);
|
||||
StartApplicationDialog dialog(ICore::dialogParent());
|
||||
dialog.setHistory(history);
|
||||
dialog.setParameters(history.back());
|
||||
if (!attachRemote) {
|
||||
@@ -401,11 +400,14 @@ bool StartApplicationDialog::run(QWidget *parent, DebuggerRunParameters *rp, Kit
|
||||
dialog.d->channelOverrideEdit->setVisible(false);
|
||||
}
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return false;
|
||||
return;
|
||||
|
||||
Kit *k = dialog.d->kitChooser->currentKit();
|
||||
IDevice::ConstPtr dev = DeviceKitInformation::device(k);
|
||||
|
||||
DebuggerRunTool *debugger = DebuggerRunTool::createFromKit(k);
|
||||
QTC_ASSERT(debugger, return);
|
||||
|
||||
const StartApplicationParameters newParameters = dialog.parameters();
|
||||
if (newParameters != history.back()) {
|
||||
history.append(newParameters);
|
||||
@@ -421,27 +423,39 @@ bool StartApplicationDialog::run(QWidget *parent, DebuggerRunParameters *rp, Kit
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
rp->inferior.executable = newParameters.runnable.executable;
|
||||
StandardRunnable inferior = newParameters.runnable;
|
||||
debugger->setUseTerminal(newParameters.runnable.runMode == ApplicationLauncher::Console);
|
||||
const QString inputAddress = dialog.d->channelOverrideEdit->text();
|
||||
if (!inputAddress.isEmpty())
|
||||
rp->remoteChannel = inputAddress;
|
||||
debugger->setRemoteChannel(inputAddress);
|
||||
else
|
||||
rp->remoteChannel = QString("%1:%2").arg(dev->sshParameters().host).arg(newParameters.serverPort);
|
||||
rp->displayName = newParameters.displayName();
|
||||
rp->inferior.workingDirectory = newParameters.runnable.workingDirectory;
|
||||
rp->useTerminal = newParameters.runnable.runMode == ApplicationLauncher::Console;
|
||||
if (!newParameters.runnable.commandLineArguments.isEmpty())
|
||||
rp->inferior.commandLineArguments = newParameters.runnable.commandLineArguments;
|
||||
rp->breakOnMain = newParameters.breakAtMain;
|
||||
rp->serverStartScript = newParameters.serverStartScript;
|
||||
rp->debugInfoLocation = newParameters.debugInfoLocation;
|
||||
debugger->setRemoteChannel(dev->sshParameters().host, newParameters.serverPort);
|
||||
debugger->setRunControlName(newParameters.displayName());
|
||||
debugger->setBreakOnMain(newParameters.breakAtMain);
|
||||
debugger->setServerStartScript(newParameters.serverStartScript);
|
||||
debugger->setDebugInfoLocation(newParameters.debugInfoLocation);
|
||||
debugger->setInferior(inferior);
|
||||
|
||||
bool isLocal = !dev || (dev->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
||||
if (!attachRemote)
|
||||
rp->startMode = isLocal ? StartExternal : StartRemoteProcess;
|
||||
if (kit)
|
||||
*kit = k;
|
||||
return true;
|
||||
debugger->setStartMode(isLocal ? StartExternal : StartRemoteProcess);
|
||||
|
||||
if (attachRemote) {
|
||||
debugger->setStartMode(AttachToRemoteServer);
|
||||
debugger->setCloseMode(KillAtClose);
|
||||
debugger->setUseContinueInsteadOfRun(true);
|
||||
}
|
||||
debugger->startRunControl();
|
||||
}
|
||||
|
||||
void StartApplicationDialog::attachToRemoteServer()
|
||||
{
|
||||
run(true);
|
||||
}
|
||||
|
||||
void StartApplicationDialog::startAndDebugApplication()
|
||||
{
|
||||
run(false);
|
||||
}
|
||||
|
||||
StartApplicationParameters StartApplicationDialog::parameters() const
|
||||
|
@@ -72,7 +72,8 @@ public:
|
||||
explicit StartApplicationDialog(QWidget *parent);
|
||||
~StartApplicationDialog();
|
||||
|
||||
static bool run(QWidget *parent, DebuggerRunParameters *rp, ProjectExplorer::Kit **kit);
|
||||
static void attachToRemoteServer();
|
||||
static void startAndDebugApplication();
|
||||
|
||||
private:
|
||||
void historyIndexChanged(int);
|
||||
@@ -81,6 +82,7 @@ private:
|
||||
void setParameters(const StartApplicationParameters &p);
|
||||
void setHistory(const QList<StartApplicationParameters> &l);
|
||||
void onChannelOverrideChanged(const QString &channel);
|
||||
static void run(bool);
|
||||
|
||||
StartApplicationDialogPrivate *d;
|
||||
};
|
||||
|
@@ -46,10 +46,7 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Core { class IOptionsPage; }
|
||||
|
||||
namespace Utils {
|
||||
class MacroExpander;
|
||||
class ProcessHandle;
|
||||
} // Utils
|
||||
namespace Utils { class MacroExpander; }
|
||||
|
||||
namespace Debugger {
|
||||
|
||||
|
@@ -733,10 +733,8 @@ public:
|
||||
void onModeChanged(Id mode);
|
||||
void updateDebugWithoutDeployMenu();
|
||||
|
||||
void startAndDebugApplication();
|
||||
void startRemoteCdbSession();
|
||||
void startRemoteServerAndAttachToProcess();
|
||||
void attachToRemoteServer();
|
||||
void attachToRunningApplication();
|
||||
void attachToUnstartedApplicationDialog();
|
||||
void attachToQmlPort();
|
||||
@@ -1499,7 +1497,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
||||
|
||||
act = m_startAndDebugApplicationAction = new QAction(this);
|
||||
act->setText(tr("Start and Debug External Application..."));
|
||||
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::startAndDebugApplication);
|
||||
connect(act, &QAction::triggered, this, &StartApplicationDialog::startAndDebugApplication);
|
||||
|
||||
act = m_attachToCoreAction = new QAction(this);
|
||||
act->setText(tr("Load Core File..."));
|
||||
@@ -1507,7 +1505,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
|
||||
|
||||
act = m_attachToRemoteServerAction = new QAction(this);
|
||||
act->setText(tr("Attach to Running Debug Server..."));
|
||||
connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::attachToRemoteServer);
|
||||
connect(act, &QAction::triggered, this, &StartApplicationDialog::attachToRemoteServer);
|
||||
|
||||
act = m_startRemoteServerAction = new QAction(this);
|
||||
act->setText(tr("Start Debug Server Attached to Process..."));
|
||||
@@ -1936,18 +1934,6 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project)
|
||||
setProxyAction(m_visibleStartAction, Id(Constants::DEBUG));
|
||||
}
|
||||
|
||||
void DebuggerPluginPrivate::startAndDebugApplication()
|
||||
{
|
||||
DebuggerRunParameters rp;
|
||||
Kit *kit;
|
||||
if (StartApplicationDialog::run(ICore::dialogParent(), &rp, &kit)) {
|
||||
auto debugger = DebuggerRunTool::createFromKit(kit);
|
||||
QTC_ASSERT(debugger, return);
|
||||
debugger->setRunParameters(rp);
|
||||
debugger->startRunControl();
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerPluginPrivate::attachCore()
|
||||
{
|
||||
AttachCoreDialog dlg(ICore::dialogParent());
|
||||
@@ -1971,19 +1957,16 @@ void DebuggerPluginPrivate::attachCore()
|
||||
setConfigValue("LastExternalStartScript", dlg.overrideStartScript());
|
||||
setConfigValue("LastForceLocalCoreFile", dlg.forcesLocalCoreFile());
|
||||
|
||||
QString display = dlg.useLocalCoreFile() ? dlg.localCoreFile() : dlg.remoteCoreFile();
|
||||
DebuggerRunParameters rp;
|
||||
rp.masterEngineType = DebuggerKitInformation::engineType(dlg.kit());
|
||||
rp.inferior.executable = dlg.localExecutableFile();
|
||||
rp.coreFile = dlg.localCoreFile();
|
||||
rp.displayName = tr("Core file \"%1\"").arg(display);
|
||||
rp.startMode = AttachCore;
|
||||
rp.closeMode = DetachAtClose;
|
||||
rp.overrideStartScript = dlg.overrideStartScript();
|
||||
|
||||
auto debugger = DebuggerRunTool::createFromKit(dlg.kit());
|
||||
QTC_ASSERT(debugger, return);
|
||||
debugger->setRunParameters(rp);
|
||||
debugger->setMasterEngineType(DebuggerKitInformation::engineType(dlg.kit()));
|
||||
debugger->setInferiorExecutable(dlg.localExecutableFile());
|
||||
debugger->setCoreFileName(dlg.localCoreFile());
|
||||
debugger->setRunControlName(tr("Core file \"%1\"")
|
||||
.arg(dlg.useLocalCoreFile() ? dlg.localCoreFile() : dlg.remoteCoreFile()));
|
||||
debugger->setStartMode(AttachCore);
|
||||
debugger->setCloseMode(DetachAtClose);
|
||||
debugger->setOverrideStartScript(dlg.overrideStartScript());
|
||||
debugger->startRunControl();
|
||||
}
|
||||
|
||||
@@ -2010,21 +1993,6 @@ void DebuggerPluginPrivate::startRemoteCdbSession()
|
||||
debugger->startRunControl();
|
||||
}
|
||||
|
||||
void DebuggerPluginPrivate::attachToRemoteServer()
|
||||
{
|
||||
DebuggerRunParameters rp;
|
||||
Kit *kit;
|
||||
rp.startMode = AttachToRemoteServer;
|
||||
rp.useContinueInsteadOfRun = true;
|
||||
if (StartApplicationDialog::run(ICore::dialogParent(), &rp, &kit)) {
|
||||
rp.closeMode = KillAtClose;
|
||||
auto debugger = DebuggerRunTool::createFromKit(kit);
|
||||
QTC_ASSERT(debugger, return);
|
||||
debugger->setRunParameters(rp);
|
||||
debugger->startRunControl();
|
||||
}
|
||||
}
|
||||
|
||||
void DebuggerPluginPrivate::startRemoteServerAndAttachToProcess()
|
||||
{
|
||||
auto kitChooser = new DebuggerKitChooser(DebuggerKitChooser::AnyDebugging);
|
||||
@@ -2135,22 +2103,20 @@ RunControl *DebuggerPluginPrivate::attachToRunningProcess(Kit *kit,
|
||||
|
||||
void DebuggerPlugin::attachExternalApplication(RunControl *rc)
|
||||
{
|
||||
DebuggerRunParameters rp;
|
||||
rp.attachPID = rc->applicationProcessHandle();
|
||||
rp.displayName = tr("Process %1").arg(rp.attachPID.pid());
|
||||
rp.startMode = AttachExternal;
|
||||
rp.closeMode = DetachAtClose;
|
||||
rp.toolChainAbi = rc->abi();
|
||||
rp.languages = CppLanguage;
|
||||
DebuggerRunTool *debugger;
|
||||
if (RunConfiguration *runConfig = rc->runConfiguration()) {
|
||||
debugger = DebuggerRunTool::createFromRunConfiguration(runConfig);
|
||||
} else {
|
||||
Kit *kit = guessKitFromAbis({rc->abi()});
|
||||
debugger = DebuggerRunTool::createFromKit(kit);
|
||||
QTC_ASSERT(debugger, return);
|
||||
}
|
||||
debugger->setRunParameters(rp);
|
||||
QTC_ASSERT(debugger, return);
|
||||
ProcessHandle pid = rc->applicationProcessHandle();
|
||||
debugger->setAttachPid(pid);
|
||||
debugger->setRunControlName(tr("Process %1").arg(pid.pid()));
|
||||
debugger->setStartMode(AttachExternal);
|
||||
debugger->setCloseMode(DetachAtClose);
|
||||
debugger->setToolChainAbi(rc->abi());
|
||||
debugger->startRunControl();
|
||||
}
|
||||
|
||||
|
@@ -256,6 +256,16 @@ void DebuggerRunTool::setUseCtrlCStub(bool on)
|
||||
m_runParameters.useCtrlCStub = on;
|
||||
}
|
||||
|
||||
void DebuggerRunTool::setBreakOnMain(bool on)
|
||||
{
|
||||
m_runParameters.breakOnMain = on;
|
||||
}
|
||||
|
||||
void DebuggerRunTool::setUseTerminal(bool on)
|
||||
{
|
||||
m_runParameters.useTerminal = on;
|
||||
}
|
||||
|
||||
void DebuggerRunTool::setCommandsAfterConnect(const QString &commands)
|
||||
{
|
||||
m_runParameters.commandsAfterConnect = commands;
|
||||
@@ -266,6 +276,16 @@ void DebuggerRunTool::setCommandsForReset(const QString &commands)
|
||||
m_runParameters.commandsForReset = commands;
|
||||
}
|
||||
|
||||
void DebuggerRunTool::setServerStartScript(const QString &serverStartScript)
|
||||
{
|
||||
m_runParameters.serverStartScript = serverStartScript;
|
||||
}
|
||||
|
||||
void DebuggerRunTool::setDebugInfoLocation(const QString &debugInfoLocation)
|
||||
{
|
||||
m_runParameters.debugInfoLocation = debugInfoLocation;
|
||||
}
|
||||
|
||||
void DebuggerRunTool::setQmlServer(const QUrl &qmlServer)
|
||||
{
|
||||
m_runParameters.qmlServer = qmlServer;
|
||||
@@ -291,6 +311,16 @@ void DebuggerRunTool::setTestCase(int testCase)
|
||||
m_runParameters.testCase = testCase;
|
||||
}
|
||||
|
||||
void DebuggerRunTool::setOverrideStartScript(const QString &script)
|
||||
{
|
||||
m_runParameters.overrideStartScript = script;
|
||||
}
|
||||
|
||||
void DebuggerRunTool::setToolChainAbi(const Abi &abi)
|
||||
{
|
||||
m_runParameters.toolChainAbi = abi;
|
||||
}
|
||||
|
||||
void DebuggerRunTool::setInferior(const Runnable &runnable)
|
||||
{
|
||||
QTC_ASSERT(runnable.is<StandardRunnable>(), reportFailure(); return);
|
||||
|
@@ -109,10 +109,15 @@ public:
|
||||
void setContinueAfterAttach(bool on);
|
||||
void setSkipExecutableValidation(bool on);
|
||||
void setUseCtrlCStub(bool on);
|
||||
void setBreakOnMain(bool on);
|
||||
void setUseTerminal(bool on);
|
||||
|
||||
void setCommandsAfterConnect(const QString &commands);
|
||||
void setCommandsForReset(const QString &commands);
|
||||
|
||||
void setServerStartScript(const QString &serverStartScript);
|
||||
void setDebugInfoLocation(const QString &debugInfoLocation);
|
||||
|
||||
void setQmlServer(const QUrl &qmlServer);
|
||||
|
||||
void setCoreFileName(const QString &core, bool isSnapshot = false);
|
||||
@@ -122,6 +127,8 @@ public:
|
||||
|
||||
void setNeedFixup(bool on);
|
||||
void setTestCase(int testCase);
|
||||
void setOverrideStartScript(const QString &script);
|
||||
void setToolChainAbi(const ProjectExplorer::Abi &abi);
|
||||
|
||||
signals:
|
||||
void aboutToNotifyInferiorSetupOk();
|
||||
|
Reference in New Issue
Block a user