Commit 244cdb78 authored by hjk's avatar hjk

Debugger: Split off runtime-only items from DebuggerStartParameters

Right now, DebuggerStartParameter is part of the debugger plugin
external interface. Better not make it fatter than necessary.

Change-Id: I3b9205089f971dd314ccba1335b5ca2d4d9fe7c6
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent 28d2b161
This diff is collapsed.
......@@ -73,7 +73,7 @@ public:
typedef QSharedPointer<CdbCommand> CdbCommandPtr;
typedef std::function<void(const CdbResponse &)> CommandHandler;
CdbEngine(const DebuggerStartParameters &sp);
CdbEngine(const DebuggerRunParameters &sp);
~CdbEngine();
// Factory function that returns 0 if the debug engine library cannot be found.
......@@ -187,7 +187,7 @@ private:
};
bool startConsole(const DebuggerStartParameters &sp, QString *errorMessage);
bool startConsole(const DebuggerRunParameters &sp, QString *errorMessage);
void init();
unsigned examineStopReason(const GdbMi &stopReason, QString *message,
QString *exceptionBoxMessage,
......@@ -196,7 +196,7 @@ private:
bool commandsPending() const;
void handleExtensionMessage(char t, int token, const QByteArray &what, const QByteArray &message);
bool doSetupEngine(QString *errorMessage);
bool launchCDB(const DebuggerStartParameters &sp, QString *errorMessage);
bool launchCDB(const DebuggerRunParameters &sp, QString *errorMessage);
void handleSessionAccessible(unsigned long cdbExState);
void handleSessionInaccessible(unsigned long cdbExState);
void handleSessionIdle(const QByteArray &message);
......
......@@ -358,9 +358,9 @@ void StartApplicationDialog::updateState()
d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(okEnabled);
}
bool StartApplicationDialog::run(QWidget *parent, DebuggerStartParameters *sp)
bool StartApplicationDialog::run(QWidget *parent, DebuggerRunParameters *rp)
{
const bool attachRemote = sp->startMode == AttachToRemoteServer;
const bool attachRemote = rp->startMode == AttachToRemoteServer;
const QString settingsGroup = QLatin1String("DebugMode");
const QString arrayName = QLatin1String("StartApplication");
......@@ -411,29 +411,29 @@ bool StartApplicationDialog::run(QWidget *parent, DebuggerStartParameters *sp)
Kit *kit = dialog.d->kitChooser->currentKit();
QTC_ASSERT(kit, return false);
bool res = DebuggerRunControlFactory::fillParametersFromKit(sp, kit);
bool res = fillParametersFromKit(rp, kit);
QTC_ASSERT(res, return false);
sp->executable = newParameters.localExecutable;
rp->executable = newParameters.localExecutable;
const QString inputAddress = dialog.d->serverAddressEdit->text();
if (!inputAddress.isEmpty())
sp->remoteChannel = inputAddress;
rp->remoteChannel = inputAddress;
else
sp->remoteChannel = sp->connParams.host;
sp->remoteChannel += QLatin1Char(':') + QString::number(newParameters.serverPort);
sp->displayName = newParameters.displayName();
sp->workingDirectory = newParameters.workingDirectory;
sp->useTerminal = newParameters.runInTerminal;
rp->remoteChannel = rp->connParams.host;
rp->remoteChannel += QLatin1Char(':') + QString::number(newParameters.serverPort);
rp->displayName = newParameters.displayName();
rp->workingDirectory = newParameters.workingDirectory;
rp->useTerminal = newParameters.runInTerminal;
if (!newParameters.processArgs.isEmpty())
sp->processArgs = newParameters.processArgs;
sp->breakOnMain = newParameters.breakAtMain;
sp->serverStartScript = newParameters.serverStartScript;
sp->debugInfoLocation = newParameters.debugInfoLocation;
rp->processArgs = newParameters.processArgs;
rp->breakOnMain = newParameters.breakAtMain;
rp->serverStartScript = newParameters.serverStartScript;
rp->debugInfoLocation = newParameters.debugInfoLocation;
IDevice::ConstPtr dev = DeviceKitInformation::device(kit);
bool isLocal = !dev || (dev->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
if (!attachRemote)
sp->startMode = isLocal ? StartExternal : StartRemoteProcess;
rp->startMode = isLocal ? StartExternal : StartRemoteProcess;
return true;
}
......
......@@ -50,13 +50,11 @@ namespace Core { class Id; }
namespace ProjectExplorer { class Kit; }
namespace Debugger {
class DebuggerStartParameters;
namespace Internal {
class AttachCoreDialogPrivate;
class AttachToQmlPortDialogPrivate;
class ProcessListFilterModel;
class DebuggerRunParameters;
class StartApplicationParameters;
class StartApplicationDialogPrivate;
class StartRemoteEngineDialogPrivate;
......@@ -87,7 +85,7 @@ public:
explicit StartApplicationDialog(QWidget *parent);
~StartApplicationDialog();
static bool run(QWidget *parent, DebuggerStartParameters *sp);
static bool run(QWidget *parent, DebuggerRunParameters *rp);
private slots:
void historyIndexChanged(int);
......
......@@ -94,7 +94,7 @@ enum { debug = 0 };
///////////////////////////////////////////////////////////////////////
//
// DebuggerStartParameters
// DebuggerRunParameters
//
///////////////////////////////////////////////////////////////////////
......@@ -109,7 +109,7 @@ QDebug operator<<(QDebug d, DebuggerState state)
return d << DebuggerEngine::stateName(state);
}
QDebug operator<<(QDebug str, const DebuggerStartParameters &sp)
QDebug operator<<(QDebug str, const DebuggerRunParameters &sp)
{
QDebug nospace = str.nospace();
nospace << "executable=" << sp.executable
......@@ -166,11 +166,11 @@ class DebuggerEnginePrivate : public QObject
Q_OBJECT
public:
DebuggerEnginePrivate(DebuggerEngine *engine, const DebuggerStartParameters &sp)
DebuggerEnginePrivate(DebuggerEngine *engine, const DebuggerRunParameters &sp)
: m_engine(engine),
m_masterEngine(0),
m_runControl(0),
m_startParameters(sp),
m_runParameters(sp),
m_state(DebuggerNotReady),
m_lastGoodState(DebuggerNotReady),
m_targetState(DebuggerNotReady),
......@@ -195,7 +195,7 @@ public:
Utils::globalMacroExpander()->registerFileVariables(PrefixDebugExecutable,
tr("Debugged executable"),
[this]() { return m_startParameters.executable; });
[this]() { return m_runParameters.executable; });
}
public slots:
......@@ -298,7 +298,7 @@ public:
DebuggerEngine *m_masterEngine; // Not owned
DebuggerRunControl *m_runControl; // Not owned.
DebuggerStartParameters m_startParameters;
DebuggerRunParameters m_runParameters;
// The current state.
DebuggerState m_state;
......@@ -342,7 +342,7 @@ public:
//
//////////////////////////////////////////////////////////////////////
DebuggerEngine::DebuggerEngine(const DebuggerStartParameters &startParameters)
DebuggerEngine::DebuggerEngine(const DebuggerRunParameters &startParameters)
: d(new DebuggerEnginePrivate(this, startParameters))
{}
......@@ -543,13 +543,13 @@ void DebuggerEngine::startDebugger(DebuggerRunControl *runControl)
d->m_runControl = runControl;
d->m_inferiorPid = d->m_startParameters.attachPID > 0
? d->m_startParameters.attachPID : 0;
d->m_inferiorPid = d->m_runParameters.attachPID > 0
? d->m_runParameters.attachPID : 0;
if (d->m_inferiorPid)
d->m_runControl->setApplicationProcessHandle(ProcessHandle(d->m_inferiorPid));
if (!d->m_startParameters.environment.size())
d->m_startParameters.environment = Utils::Environment();
if (!d->m_runParameters.environment.size())
d->m_runParameters.environment = Utils::Environment();
action(OperateByInstruction)->setEnabled(hasCapability(DisassemblerCapability));
......@@ -641,14 +641,14 @@ void DebuggerEngine::handleFinished()
watchHandler()->cleanup();
}
const DebuggerStartParameters &DebuggerEngine::startParameters() const
const DebuggerRunParameters &DebuggerEngine::runParameters() const
{
return d->m_startParameters;
return d->m_runParameters;
}
DebuggerStartParameters &DebuggerEngine::startParameters()
DebuggerRunParameters &DebuggerEngine::runParameters()
{
return d->m_startParameters;
return d->m_runParameters;
}
DebuggerState DebuggerEngine::state() const
......@@ -751,7 +751,7 @@ void DebuggerEnginePrivate::doSetupEngine()
{
m_engine->showMessage(_("CALL: SETUP ENGINE"));
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << m_engine << state());
m_engine->validateExecutable(&m_startParameters);
m_engine->validateExecutable(&m_runParameters);
m_engine->setupEngine();
}
......@@ -895,20 +895,20 @@ void DebuggerEngine::notifyEngineRemoteSetupFinished(const RemoteSetupResult &re
d->setRemoteSetupState(RemoteSetupSucceeded);
if (result.gdbServerPort != InvalidPid) {
QString &rc = d->m_startParameters.remoteChannel;
QString &rc = d->m_runParameters.remoteChannel;
const int sepIndex = rc.lastIndexOf(QLatin1Char(':'));
if (sepIndex != -1) {
rc.replace(sepIndex + 1, rc.count() - sepIndex - 1,
QString::number(result.gdbServerPort));
}
} else if (result.inferiorPid != InvalidPid && startParameters().startMode == AttachExternal) {
} else if (result.inferiorPid != InvalidPid && runParameters().startMode == AttachExternal) {
// e.g. iOS Simulator
startParameters().attachPID = result.inferiorPid;
runParameters().attachPID = result.inferiorPid;
}
if (result.qmlServerPort != InvalidPort) {
d->m_startParameters.qmlServerPort = result.qmlServerPort;
d->m_startParameters.processArgs.replace(_("%qml_port%"), QString::number(result.qmlServerPort));
d->m_runParameters.qmlServerPort = result.qmlServerPort;
d->m_runParameters.processArgs.replace(_("%qml_port%"), QString::number(result.qmlServerPort));
}
} else {
......@@ -1308,11 +1308,11 @@ DebuggerEngine *DebuggerEngine::masterEngine() const
QString DebuggerEngine::toFileInProject(const QUrl &fileUrl)
{
// make sure file finder is properly initialized
const DebuggerStartParameters &sp = startParameters();
d->m_fileFinder.setProjectDirectory(sp.projectSourceDirectory);
d->m_fileFinder.setProjectFiles(sp.projectSourceFiles);
d->m_fileFinder.setAdditionalSearchDirectories(sp.additionalSearchDirectories);
d->m_fileFinder.setSysroot(sp.sysRoot);
const DebuggerRunParameters &rp = runParameters();
d->m_fileFinder.setProjectDirectory(rp.projectSourceDirectory);
d->m_fileFinder.setProjectFiles(rp.projectSourceFiles);
d->m_fileFinder.setAdditionalSearchDirectories(rp.additionalSearchDirectories);
d->m_fileFinder.setSysroot(rp.sysRoot);
return d->m_fileFinder.findFile(fileUrl);
}
......@@ -1362,9 +1362,9 @@ void DebuggerEngine::notifyInferiorPid(qint64 pid)
d->m_inferiorPid = pid;
if (pid) {
showMessage(tr("Taking notice of pid %1").arg(pid));
if (d->m_startParameters.startMode == StartInternal
|| d->m_startParameters.startMode == StartExternal
|| d->m_startParameters.startMode == AttachExternal)
if (d->m_runParameters.startMode == StartInternal
|| d->m_runParameters.startMode == StartExternal
|| d->m_runParameters.startMode == AttachExternal)
QTimer::singleShot(0, d, SLOT(raiseApplication()));
}
}
......@@ -1793,7 +1793,7 @@ void DebuggerEngine::setStateDebugging(bool on)
d->m_isStateDebugging = on;
}
void DebuggerEngine::validateExecutable(DebuggerStartParameters *sp)
void DebuggerEngine::validateExecutable(DebuggerRunParameters *sp)
{
if (sp->skipExecutableValidation)
return;
......@@ -1980,6 +1980,17 @@ void DebuggerEngine::updateLocalsView(const GdbMi &all)
emit stackFrameCompleted();
}
DebuggerRunParameters::DebuggerRunParameters()
: cppEngineType(NoEngineType),
isSnapshot(false),
testCase(0)
{}
void DebuggerRunParameters::operator=(const DebuggerStartParameters &sp)
{
DebuggerStartParameters::operator=(sp);
}
} // namespace Internal
} // namespace Debugger
......
......@@ -33,6 +33,9 @@
#include "debugger_global.h"
#include "debuggerconstants.h"
#include "debuggerstartparameters.h"
#include <projectexplorer/devicesupport/idevice.h>
#include <QObject>
#include <QProcess>
......@@ -43,16 +46,13 @@ class QPoint;
class QAbstractItemModel;
QT_END_NAMESPACE
namespace TextEditor { class TextEditorWidget; }
namespace Core { class IOptionsPage; }
namespace Debugger {
class DebuggerRunControl;
class DebuggerStartParameters;
class RemoteSetupResult;
DEBUGGER_EXPORT QDebug operator<<(QDebug str, const DebuggerStartParameters &);
DEBUGGER_EXPORT QDebug operator<<(QDebug str, DebuggerState state);
namespace Internal {
......@@ -80,6 +80,34 @@ class MemoryViewSetupData;
class Terminal;
class ThreadId;
class DebuggerRunParameters : public DebuggerStartParameters
{
public:
DebuggerRunParameters();
void operator=(const DebuggerStartParameters &sp);
QString coreFile;
QString overrideStartScript; // Used in attach to core and remote debugging
QString startMessage; // First status message shown.
DebuggerEngineType cppEngineType;
QByteArray remoteSourcesDir;
QString remoteMountPoint;
QMap<QString, QString> sourcePathMap;
QString debugInfoLocation; // Gdb "set-debug-file-directory".
QStringList debugSourceLocation; // Gdb "directory"
QString serverStartScript;
QString localMountDir;
ProjectExplorer::IDevice::ConstPtr device;
bool isSnapshot; // Set if created internally.
// Used by AttachCrashedExternal.
QString crashParameter;
// For Debugger testing.
int testCase;
};
class Location
{
public:
......@@ -133,11 +161,11 @@ class DebuggerEngine : public QObject
Q_OBJECT
public:
explicit DebuggerEngine(const DebuggerStartParameters &sp);
explicit DebuggerEngine(const DebuggerRunParameters &sp);
virtual ~DebuggerEngine();
const DebuggerStartParameters &startParameters() const;
DebuggerStartParameters &startParameters();
const DebuggerRunParameters &runParameters() const;
DebuggerRunParameters &runParameters();
virtual bool setToolTipExpression(const Internal::DebuggerToolTipContext &);
......@@ -366,7 +394,7 @@ protected:
bool isStateDebugging() const;
void setStateDebugging(bool on);
static void validateExecutable(DebuggerStartParameters *sp);
static void validateExecutable(DebuggerRunParameters *sp);
virtual void setupSlaveInferior();
virtual void setupSlaveEngine();
......@@ -390,6 +418,16 @@ private:
DebuggerEnginePrivate *d;
};
DebuggerEngine *createEngine(DebuggerEngineType et, const DebuggerRunParameters &rp, QString *errorMessage);
bool fillParametersFromKit(DebuggerRunParameters *r, const ProjectExplorer::Kit *kit, QString *errorMessage = 0);
bool fillParametersFromLocalRunConfiguration(DebuggerRunParameters *rp,
const ProjectExplorer::RunConfiguration *runConfig, QString *errorMessage = 0);
DebuggerRunControl *createAndScheduleRun(const DebuggerRunParameters &rp);
} // namespace Internal
} // namespace Debugger
......
This diff is collapsed.
This diff is collapsed.
......@@ -41,11 +41,13 @@ namespace ProjectExplorer { class Kit; }
namespace Debugger {
class RemoteSetupResult;
namespace Internal { class DebuggerEngine; }
class DebuggerStartParameters;
namespace Internal {
class DebuggerEngine;
class DebuggerRunParameters;
}
class DEBUGGER_EXPORT DebuggerRunControl
: public ProjectExplorer::RunControl
{
......@@ -104,24 +106,15 @@ public:
bool canRun(ProjectExplorer::RunConfiguration *runConfig,
ProjectExplorer::RunMode mode) const;
static Internal::DebuggerEngine *createEngine(DebuggerEngineType et,
const DebuggerStartParameters &sp,
QString *errorMessage);
static bool fillParametersFromKit(DebuggerStartParameters *sp,
const ProjectExplorer::Kit *kit, QString *errorMessage = 0);
static bool fillParametersFromLocalRunConfiguration(DebuggerStartParameters *sp,
const ProjectExplorer::RunConfiguration *runConfig, QString *errorMessage = 0);
static DebuggerRunControl *createAndScheduleRun(const DebuggerStartParameters &sp);
static DebuggerRunControl *doCreate(const DebuggerStartParameters &sp, QString *errorMessage);
ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect(
ProjectExplorer::RunConfiguration *rc);
};
DEBUGGER_EXPORT DebuggerRunControl *createDebuggerRunControl(const DebuggerStartParameters &sp,
QString *errorMessage);
} // namespace Debugger
#endif // DEBUGGERRUNCONTROL_H
......@@ -29,7 +29,7 @@
****************************************************************************/
#include "debuggersourcepathmappingwidget.h"
#include "debuggerstartparameters.h"
#include "debuggerengine.h"
#include <coreplugin/variablechooser.h>
......@@ -438,7 +438,7 @@ static QString findQtInstallPath(const FileName &qmakePath)
/* Merge settings for an installed Qt (unless another setting
* is already in the map. */
DebuggerSourcePathMappingWidget::SourcePathMap
DebuggerSourcePathMappingWidget::mergePlatformQtPath(const DebuggerStartParameters &sp,
DebuggerSourcePathMappingWidget::mergePlatformQtPath(const DebuggerRunParameters &sp,
const SourcePathMap &in)
{
const FileName qmake = BuildableHelperLibrary::findSystemQt(sp.environment);
......
......@@ -46,11 +46,9 @@ QT_END_NAMESPACE
namespace Utils { class PathChooser; }
namespace Debugger {
class DebuggerStartParameters;
namespace Internal {
class DebuggerRunParameters;
class SourcePathMappingModel;
class DebuggerSourcePathMappingWidget : public QGroupBox
......@@ -67,7 +65,7 @@ public:
/* Merge settings for an installed Qt (unless another setting
* is already in the map. */
static SourcePathMap mergePlatformQtPath(const DebuggerStartParameters &sp,
static SourcePathMap mergePlatformQtPath(const DebuggerRunParameters &sp,
const SourcePathMap &in);
private slots:
......
......@@ -38,7 +38,6 @@
#include <utils/environment.h>
#include <projectexplorer/abi.h>
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <QMetaType>
#include <QVector>
......@@ -74,9 +73,7 @@ class DEBUGGER_EXPORT DebuggerStartParameters
public:
DebuggerStartParameters()
: masterEngineType(NoEngineType),
cppEngineType(NoEngineType),
runConfiguration(0),
isSnapshot(false),
attachPID(-1),
useTerminal(false),
breakOnMain(false),
......@@ -90,26 +87,19 @@ public:
startMode(NoStartMode),
closeMode(KillAtClose),
useCtrlCStub(false),
skipExecutableValidation(false),
testCase(0)
skipExecutableValidation(false)
{}
DebuggerEngineType masterEngineType;
DebuggerEngineType cppEngineType;
QString sysRoot;
QString deviceSymbolsRoot;
QString debuggerCommand;
ProjectExplorer::Abi toolChainAbi;
ProjectExplorer::IDevice::ConstPtr device;
QPointer<ProjectExplorer::RunConfiguration> runConfiguration;
QString platform;
QString executable;
QString displayName; // Used in the Snapshots view.
QString startMessage; // First status message shown.
QString coreFile;
QString overrideStartScript; // Used in attach to core and remote debugging
bool isSnapshot; // Set if created internally.
QString processArgs;
Utils::Environment environment;
QString workingDirectory;
......@@ -120,9 +110,6 @@ public:
bool multiProcess;
DebuggerLanguages languages;
// Used by AttachCrashedExternal.
QString crashParameter;
// Used by Qml debugging.
QString qmlServerAddress;
quint16 qmlServerPort;
......@@ -133,15 +120,8 @@ public:
// Used by remote debugging.
QString remoteChannel;
QString serverStartScript;
QString debugInfoLocation; // Gdb "set-debug-file-directory".
QStringList debugSourceLocation; // Gdb "directory"
QByteArray remoteSourcesDir;
QString remoteMountPoint;
QString localMountDir;
QSsh::SshConnectionParameters connParams;
bool remoteSetupNeeded;
QMap<QString, QString> sourcePathMap;
// Used by baremetal plugin
QByteArray commandsForReset; // commands used for resetting the inferior
......@@ -161,9 +141,6 @@ public:
// Used by Android to avoid false positives on warnOnRelease
bool skipExecutableValidation;
// For Debugger testing.
int testCase;
};
} // namespace Debugger
......
......@@ -47,7 +47,7 @@ namespace Internal {
//
///////////////////////////////////////////////////////////////////////
GdbAttachEngine::GdbAttachEngine(const DebuggerStartParameters &startParameters)
GdbAttachEngine::GdbAttachEngine(const DebuggerRunParameters &startParameters)
: GdbEngine(startParameters)
{
}
......@@ -57,10 +57,10 @@ void GdbAttachEngine::setupEngine()
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
showMessage(_("TRYING TO START ADAPTER"));
if (!startParameters().workingDirectory.isEmpty())
m_gdbProc->setWorkingDirectory(startParameters().workingDirectory);
if (startParameters().environment.size())
m_gdbProc->setEnvironment(startParameters().environment.toStringList());
if (!runParameters().workingDirectory.isEmpty())
m_gdbProc->setWorkingDirectory(runParameters().workingDirectory);
if (runParameters().environment.size())
m_gdbProc->setEnvironment(runParameters().environment.toStringList());
startGdb();
}
......@@ -76,7 +76,7 @@ void GdbAttachEngine::setupInferior()
void GdbAttachEngine::runEngine()
{
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
const qint64 pid = startParameters().attachPID;
const qint64 pid = runParameters().attachPID;
postCommand("attach " + QByteArray::number(pid), NoFlags,
[this](const DebuggerResponse &r) { handleAttach(r); });
showStatusMessage(tr("Attached to process %1.").arg(inferiorPid()));
......@@ -100,13 +100,13 @@ void GdbAttachEngine::handleAttach(const DebuggerResponse &response)
// InferiorStopOk, e.g. for "Attach to running application".
// The *stopped came in between sending the 'attach' and
// receiving its '^done'.
if (startParameters().continueAfterAttach)
if (runParameters().continueAfterAttach)
continueInferiorInternal();
}
break;
case ResultError:
if (response.data["msg"].data() == "ptrace: Operation not permitted.") {
QString msg = msgPtraceError(startParameters().startMode);
QString msg = msgPtraceError(runParameters().startMode);
showStatusMessage(tr("Failed to attach to application: %1").arg(msg));
Core::AsynchronousMessageBox::warning(tr("Debugger Error"), msg);
notifyEngineIll();
......@@ -122,7 +122,7 @@ void GdbAttachEngine::handleAttach(const DebuggerResponse &response)
void GdbAttachEngine::interruptInferior2()
{
interruptLocalInferior(startParameters().attachPID);
interruptLocalInferior(runParameters().attachPID);
}
void GdbAttachEngine::shutdownEngine()
......
......@@ -48,7 +48,7 @@ class GdbAttachEngine : public GdbEngine
Q_OBJECT
public:
explicit GdbAttachEngine(const DebuggerStartParameters &startParameters);