forked from qt-creator/qt-creator
Debugger: Move some commonly used flags to base DebuggerTool
Basically all derived tools will need access to the debugger aspect data. Fetch it once. Change-Id: I054e4255a036db258201a8a501af244206c06990 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -477,23 +477,47 @@ static bool isDebuggableScript(RunConfiguration *runConfig)
|
|||||||
return mainScript.endsWith(".py"); // Only Python for now.
|
return mainScript.endsWith(".py"); // Only Python for now.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DebuggerRunConfigurationAspect *debuggerAspect(const RunControl *runControl)
|
||||||
|
{
|
||||||
|
return runControl->runConfiguration()->extraAspect<DebuggerRunConfigurationAspect>();
|
||||||
|
}
|
||||||
|
|
||||||
/// DebuggerRunTool
|
/// DebuggerRunTool
|
||||||
|
|
||||||
|
DebuggerRunTool::DebuggerRunTool(RunControl *runControl)
|
||||||
|
: ToolRunner(runControl),
|
||||||
|
m_isCppDebugging(debuggerAspect(runControl)->useCppDebugger()),
|
||||||
|
m_isQmlDebugging(debuggerAspect(runControl)->useQmlDebugger())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
DebuggerRunTool::DebuggerRunTool(RunControl *runControl, const DebuggerStartParameters &sp, QString *errorMessage)
|
DebuggerRunTool::DebuggerRunTool(RunControl *runControl, const DebuggerStartParameters &sp, QString *errorMessage)
|
||||||
: DebuggerRunTool(runControl, DebuggerRunParameters(sp), errorMessage)
|
: DebuggerRunTool(runControl)
|
||||||
{}
|
{
|
||||||
|
setStartParameters(sp, errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
DebuggerRunTool::DebuggerRunTool(RunControl *runControl, const DebuggerRunParameters &rp, QString *errorMessage)
|
DebuggerRunTool::DebuggerRunTool(RunControl *runControl, const DebuggerRunParameters &rp, QString *errorMessage)
|
||||||
: ToolRunner(runControl)
|
: DebuggerRunTool(runControl)
|
||||||
|
{
|
||||||
|
setRunParameters(rp, errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerRunTool::setStartParameters(const DebuggerStartParameters &sp, QString *errorMessage)
|
||||||
|
{
|
||||||
|
setRunParameters(sp, errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DebuggerRunTool::setRunParameters(const DebuggerRunParameters &rp, QString *errorMessage)
|
||||||
{
|
{
|
||||||
DebuggerRunParameters m_rp = rp;
|
DebuggerRunParameters m_rp = rp;
|
||||||
|
|
||||||
runControl->setDisplayName(m_rp.displayName);
|
runControl()->setDisplayName(m_rp.displayName);
|
||||||
// QML and/or mixed are not prepared for it.
|
// QML and/or mixed are not prepared for it.
|
||||||
runControl->setSupportsReRunning(!(m_rp.languages & QmlLanguage));
|
runControl()->setSupportsReRunning(!(m_rp.languages & QmlLanguage));
|
||||||
|
|
||||||
runControl->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL_TOOLBAR);
|
runControl()->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL_TOOLBAR);
|
||||||
runControl->setPromptToStop([](bool *optionalPrompt) {
|
runControl()->setPromptToStop([](bool *optionalPrompt) {
|
||||||
return RunControl::showPromptToStopDialog(
|
return RunControl::showPromptToStopDialog(
|
||||||
DebuggerRunTool::tr("Close Debugging Session"),
|
DebuggerRunTool::tr("Close Debugging Session"),
|
||||||
DebuggerRunTool::tr("A debugging session is still in progress. "
|
DebuggerRunTool::tr("A debugging session is still in progress. "
|
||||||
@@ -503,7 +527,7 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, const DebuggerRunParame
|
|||||||
QString(), QString(), optionalPrompt);
|
QString(), QString(), optionalPrompt);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Internal::fixupParameters(m_rp, runControl, m_errors)) {
|
if (Internal::fixupParameters(m_rp, runControl(), m_errors)) {
|
||||||
m_engine = createEngine(m_rp.masterEngineType, m_rp, &m_errors);
|
m_engine = createEngine(m_rp.masterEngineType, m_rp, &m_errors);
|
||||||
if (!m_engine) {
|
if (!m_engine) {
|
||||||
QString msg = m_errors.join('\n');
|
QString msg = m_errors.join('\n');
|
||||||
@@ -515,7 +539,7 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl, const DebuggerRunParame
|
|||||||
|
|
||||||
m_engine->setRunTool(this);
|
m_engine->setRunTool(this);
|
||||||
|
|
||||||
connect(runControl, &RunControl::finished,
|
connect(runControl(), &RunControl::finished,
|
||||||
this, &DebuggerRunTool::handleFinished);
|
this, &DebuggerRunTool::handleFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,14 +41,21 @@ class DEBUGGER_EXPORT DebuggerRunTool : public ProjectExplorer::ToolRunner
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
DebuggerRunTool(ProjectExplorer::RunControl *runControl); // Use.
|
||||||
|
|
||||||
DebuggerRunTool(ProjectExplorer::RunControl *runControl,
|
DebuggerRunTool(ProjectExplorer::RunControl *runControl,
|
||||||
const DebuggerStartParameters &sp,
|
const DebuggerStartParameters &sp,
|
||||||
QString *errorMessage = nullptr); // Use.
|
QString *errorMessage = nullptr); // Use rarely.
|
||||||
DebuggerRunTool(ProjectExplorer::RunControl *runControl,
|
DebuggerRunTool(ProjectExplorer::RunControl *runControl,
|
||||||
const Internal::DebuggerRunParameters &rp,
|
const Internal::DebuggerRunParameters &rp,
|
||||||
QString *errorMessage = nullptr); // FIXME: Don't use.
|
QString *errorMessage = nullptr); // FIXME: Don't use.
|
||||||
~DebuggerRunTool();
|
~DebuggerRunTool();
|
||||||
|
|
||||||
|
void setStartParameters(const DebuggerStartParameters &sp,
|
||||||
|
QString *errorMessage = nullptr); // Use rarely.
|
||||||
|
void setRunParameters(const Internal::DebuggerRunParameters &rp,
|
||||||
|
QString *errorMessage = nullptr); // FIXME: Don't use.
|
||||||
|
|
||||||
Internal::DebuggerEngine *engine() const { return m_engine; }
|
Internal::DebuggerEngine *engine() const { return m_engine; }
|
||||||
|
|
||||||
void showMessage(const QString &msg, int channel = LogDebug, int timeout = -1);
|
void showMessage(const QString &msg, int channel = LogDebug, int timeout = -1);
|
||||||
@@ -71,6 +78,9 @@ public:
|
|||||||
|
|
||||||
DebuggerStartParameters &startParameters(); // Used in Boot2Qt.
|
DebuggerStartParameters &startParameters(); // Used in Boot2Qt.
|
||||||
|
|
||||||
|
bool isCppDebugging() const { return m_isCppDebugging; }
|
||||||
|
bool isQmlDebugging() const { return m_isQmlDebugging; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void stateChanged(Debugger::DebuggerState state);
|
void stateChanged(Debugger::DebuggerState state);
|
||||||
void aboutToNotifyInferiorSetupOk();
|
void aboutToNotifyInferiorSetupOk();
|
||||||
@@ -79,6 +89,8 @@ signals:
|
|||||||
private:
|
private:
|
||||||
Internal::DebuggerEngine *m_engine = nullptr; // Master engine
|
Internal::DebuggerEngine *m_engine = nullptr; // Master engine
|
||||||
QStringList m_errors;
|
QStringList m_errors;
|
||||||
|
const bool m_isCppDebugging;
|
||||||
|
const bool m_isQmlDebugging;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
@@ -27,10 +27,8 @@
|
|||||||
|
|
||||||
#include "remotelinuxrunconfiguration.h"
|
#include "remotelinuxrunconfiguration.h"
|
||||||
|
|
||||||
#include <debugger/debuggerrunconfigurationaspect.h>
|
|
||||||
#include <debugger/debuggerruncontrol.h>
|
#include <debugger/debuggerruncontrol.h>
|
||||||
#include <debugger/debuggerstartparameters.h>
|
#include <debugger/debuggerstartparameters.h>
|
||||||
#include <debugger/debuggerkitinformation.h>
|
|
||||||
|
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
@@ -56,14 +54,6 @@ namespace Internal {
|
|||||||
class LinuxDeviceDebugSupportPrivate
|
class LinuxDeviceDebugSupportPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LinuxDeviceDebugSupportPrivate(const RunConfiguration *runConfig)
|
|
||||||
: qmlDebugging(runConfig->extraAspect<DebuggerRunConfigurationAspect>()->useQmlDebugger()),
|
|
||||||
cppDebugging(runConfig->extraAspect<DebuggerRunConfigurationAspect>()->useCppDebugger())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool qmlDebugging;
|
|
||||||
bool cppDebugging;
|
|
||||||
QByteArray gdbserverOutput;
|
QByteArray gdbserverOutput;
|
||||||
Port gdbServerPort;
|
Port gdbServerPort;
|
||||||
Port qmlPort;
|
Port qmlPort;
|
||||||
@@ -77,7 +67,7 @@ LinuxDeviceDebugSupport::LinuxDeviceDebugSupport(RunControl *runControl,
|
|||||||
const Debugger::DebuggerStartParameters &sp,
|
const Debugger::DebuggerStartParameters &sp,
|
||||||
QString *errorMessage)
|
QString *errorMessage)
|
||||||
: DebuggerRunTool(runControl, sp, errorMessage),
|
: DebuggerRunTool(runControl, sp, errorMessage),
|
||||||
d(new LinuxDeviceDebugSupportPrivate(runControl->runConfiguration()))
|
d(new LinuxDeviceDebugSupportPrivate)
|
||||||
{
|
{
|
||||||
connect(this, &DebuggerRunTool::requestRemoteSetup,
|
connect(this, &DebuggerRunTool::requestRemoteSetup,
|
||||||
this, &LinuxDeviceDebugSupport::handleRemoteSetupRequested);
|
this, &LinuxDeviceDebugSupport::handleRemoteSetupRequested);
|
||||||
@@ -97,16 +87,6 @@ LinuxDeviceDebugSupport::~LinuxDeviceDebugSupport()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LinuxDeviceDebugSupport::isCppDebugging() const
|
|
||||||
{
|
|
||||||
return d->cppDebugging;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LinuxDeviceDebugSupport::isQmlDebugging() const
|
|
||||||
{
|
|
||||||
return d->qmlDebugging;
|
|
||||||
}
|
|
||||||
|
|
||||||
AbstractRemoteLinuxRunSupport *LinuxDeviceDebugSupport::targetRunner() const
|
AbstractRemoteLinuxRunSupport *LinuxDeviceDebugSupport::targetRunner() const
|
||||||
{
|
{
|
||||||
return qobject_cast<AbstractRemoteLinuxRunSupport *>(runControl()->targetRunner());
|
return qobject_cast<AbstractRemoteLinuxRunSupport *>(runControl()->targetRunner());
|
||||||
@@ -130,14 +110,14 @@ void LinuxDeviceDebugSupport::startExecution()
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(state() == AbstractRemoteLinuxRunSupport::GatheringResources, return);
|
QTC_ASSERT(state() == AbstractRemoteLinuxRunSupport::GatheringResources, return);
|
||||||
|
|
||||||
if (d->cppDebugging) {
|
if (isCppDebugging()) {
|
||||||
d->gdbServerPort = targetRunner()->findPort();
|
d->gdbServerPort = targetRunner()->findPort();
|
||||||
if (!d->gdbServerPort.isValid()) {
|
if (!d->gdbServerPort.isValid()) {
|
||||||
handleAdapterSetupFailed(tr("Not enough free ports on device for C++ debugging."));
|
handleAdapterSetupFailed(tr("Not enough free ports on device for C++ debugging."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (d->qmlDebugging) {
|
if (isQmlDebugging()) {
|
||||||
d->qmlPort = targetRunner()->findPort();
|
d->qmlPort = targetRunner()->findPort();
|
||||||
if (!d->qmlPort.isValid()) {
|
if (!d->qmlPort.isValid()) {
|
||||||
handleAdapterSetupFailed(tr("Not enough free ports on device for QML debugging."));
|
handleAdapterSetupFailed(tr("Not enough free ports on device for QML debugging."));
|
||||||
@@ -159,7 +139,7 @@ void LinuxDeviceDebugSupport::startExecution()
|
|||||||
this, &LinuxDeviceDebugSupport::handleProgressReport);
|
this, &LinuxDeviceDebugSupport::handleProgressReport);
|
||||||
connect(launcher, &ApplicationLauncher::reportError,
|
connect(launcher, &ApplicationLauncher::reportError,
|
||||||
this, &LinuxDeviceDebugSupport::handleAppRunnerError);
|
this, &LinuxDeviceDebugSupport::handleAppRunnerError);
|
||||||
if (d->qmlDebugging && !d->cppDebugging)
|
if (isQmlDebugging() && !isCppDebugging())
|
||||||
connect(launcher, &ApplicationLauncher::remoteProcessStarted,
|
connect(launcher, &ApplicationLauncher::remoteProcessStarted,
|
||||||
this, &LinuxDeviceDebugSupport::handleRemoteProcessStarted);
|
this, &LinuxDeviceDebugSupport::handleRemoteProcessStarted);
|
||||||
|
|
||||||
@@ -172,10 +152,10 @@ Runnable LinuxDeviceDebugSupport::realRunnable() const
|
|||||||
QStringList args = QtcProcess::splitArgs(r.commandLineArguments, OsTypeLinux);
|
QStringList args = QtcProcess::splitArgs(r.commandLineArguments, OsTypeLinux);
|
||||||
QString command;
|
QString command;
|
||||||
|
|
||||||
if (d->qmlDebugging)
|
if (isQmlDebugging())
|
||||||
args.prepend(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices, d->qmlPort));
|
args.prepend(QmlDebug::qmlDebugTcpArguments(QmlDebug::QmlDebuggerServices, d->qmlPort));
|
||||||
|
|
||||||
if (d->qmlDebugging && !d->cppDebugging) {
|
if (isQmlDebugging() && !isCppDebugging()) {
|
||||||
command = r.executable;
|
command = r.executable;
|
||||||
} else {
|
} else {
|
||||||
command = device()->debugServerPath();
|
command = device()->debugServerPath();
|
||||||
@@ -207,7 +187,7 @@ void LinuxDeviceDebugSupport::handleAppRunnerFinished(bool success)
|
|||||||
|
|
||||||
if (state() == AbstractRemoteLinuxRunSupport::Running) {
|
if (state() == AbstractRemoteLinuxRunSupport::Running) {
|
||||||
// The QML engine does not realize on its own that the application has finished.
|
// The QML engine does not realize on its own that the application has finished.
|
||||||
if (d->qmlDebugging && !d->cppDebugging)
|
if (isQmlDebugging() && !isCppDebugging())
|
||||||
quitDebugger();
|
quitDebugger();
|
||||||
else if (!success)
|
else if (!success)
|
||||||
notifyInferiorIll();
|
notifyInferiorIll();
|
||||||
@@ -240,7 +220,7 @@ void LinuxDeviceDebugSupport::handleRemoteErrorOutput(const QByteArray &output)
|
|||||||
QTC_ASSERT(state() != AbstractRemoteLinuxRunSupport::GatheringResources, return);
|
QTC_ASSERT(state() != AbstractRemoteLinuxRunSupport::GatheringResources, return);
|
||||||
|
|
||||||
showMessage(QString::fromUtf8(output), AppError);
|
showMessage(QString::fromUtf8(output), AppError);
|
||||||
if (state() == AbstractRemoteLinuxRunSupport::StartingRunner && d->cppDebugging) {
|
if (state() == AbstractRemoteLinuxRunSupport::StartingRunner && isCppDebugging()) {
|
||||||
d->gdbserverOutput += output;
|
d->gdbserverOutput += output;
|
||||||
if (d->gdbserverOutput.contains("Listening on port")) {
|
if (d->gdbserverOutput.contains("Listening on port")) {
|
||||||
handleAdapterSetupDone();
|
handleAdapterSetupDone();
|
||||||
@@ -275,7 +255,7 @@ void LinuxDeviceDebugSupport::handleAdapterSetupDone()
|
|||||||
|
|
||||||
void LinuxDeviceDebugSupport::handleRemoteProcessStarted()
|
void LinuxDeviceDebugSupport::handleRemoteProcessStarted()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(d->qmlDebugging && !d->cppDebugging, return);
|
QTC_ASSERT(isQmlDebugging() && !isCppDebugging(), return);
|
||||||
QTC_ASSERT(state() == AbstractRemoteLinuxRunSupport::StartingRunner, return);
|
QTC_ASSERT(state() == AbstractRemoteLinuxRunSupport::StartingRunner, return);
|
||||||
|
|
||||||
handleAdapterSetupDone();
|
handleAdapterSetupDone();
|
||||||
|
@@ -45,8 +45,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ProjectExplorer::Runnable realRunnable() const;
|
virtual ProjectExplorer::Runnable realRunnable() const;
|
||||||
bool isCppDebugging() const;
|
|
||||||
bool isQmlDebugging() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void startExecution();
|
void startExecution();
|
||||||
|
Reference in New Issue
Block a user