Debugger: Move run parameters from engine to tool runner

The parameters belong to the run control, they should not
be triplicated in case of a combined engine.

Change-Id: I4dd84220edbd7a44b902cc52627fe01d0568db75
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2017-05-05 14:45:36 +02:00
parent c9cd6b1223
commit 1f6764a54e
31 changed files with 286 additions and 261 deletions

View File

@@ -200,11 +200,11 @@ static inline bool validMode(DebuggerStartMode sm)
}
// Accessed by RunControlFactory
DebuggerEngine *createCdbEngine(const DebuggerRunParameters &rp, QStringList *errors)
DebuggerEngine *createCdbEngine(QStringList *errors, DebuggerStartMode sm)
{
if (HostOsInfo::isWindowsHost()) {
if (validMode(rp.startMode))
return new CdbEngine(rp);
if (validMode(sm))
return new CdbEngine();
errors->append(CdbEngine::tr("Internal error: Invalid start parameters passed for the CDB engine."));
} else {
errors->append(CdbEngine::tr("Unsupported CDB host system."));
@@ -222,8 +222,7 @@ void addCdbOptionPages(QList<Core::IOptionsPage *> *opts)
#define QT_CREATOR_CDB_EXT "qtcreatorcdbext"
CdbEngine::CdbEngine(const DebuggerRunParameters &sp) :
DebuggerEngine(sp),
CdbEngine::CdbEngine() :
m_tokenPrefix("<token>"),
m_effectiveStartMode(NoStartMode),
m_accessible(false),

View File

@@ -56,7 +56,7 @@ public:
typedef QSharedPointer<CdbCommand> CdbCommandPtr;
typedef std::function<void(const DebuggerResponse &)> CommandHandler;
CdbEngine(const DebuggerRunParameters &sp);
explicit CdbEngine();
~CdbEngine() override;
// Factory function that returns 0 if the debug engine library cannot be found.

View File

@@ -47,6 +47,9 @@ namespace CPlusPlus { class Snapshot; }
namespace Utils { class SavedAction; }
namespace Debugger {
class DebuggerRunTool;
namespace Internal {
class BreakHandler;
@@ -63,7 +66,7 @@ enum TestCases
};
// Some convenience.
void updateState(DebuggerEngine *engine);
void updateState(DebuggerRunTool *runTool);
void updateWatchersWindow(bool showWatch, bool showReturn);
const CPlusPlus::Snapshot &cppCodeModelSnapshot();
bool hasSnapshots();
@@ -73,9 +76,9 @@ void openTextEditor(const QString &titlePattern, const QString &contents);
void showMessage(const QString &msg, int channel, int timeout = -1);
bool isReverseDebugging();
void runControlStarted(DebuggerEngine *engine);
void runControlFinished(DebuggerEngine *engine);
void displayDebugger(DebuggerEngine *engine, bool updateEngine);
void runControlStarted(DebuggerRunTool *runTool);
void runControlFinished(DebuggerRunTool *runTool);
void displayDebugger(DebuggerRunTool *runTool, bool updateEngine);
void synchronizeBreakpoints();
void saveModeToRestore();

View File

@@ -89,9 +89,6 @@ using namespace Utils;
#include <valgrind/callgrind.h>
#endif
// VariableManager Prefix
const char PrefixDebugExecutable[] = "DebuggedExecutable";
namespace Debugger {
QDebug operator<<(QDebug d, DebuggerState state)
@@ -227,9 +224,8 @@ class DebuggerEnginePrivate : public QObject
Q_OBJECT
public:
DebuggerEnginePrivate(DebuggerEngine *engine, const DebuggerRunParameters &sp)
DebuggerEnginePrivate(DebuggerEngine *engine)
: m_engine(engine),
m_runParameters(sp),
m_modulesHandler(engine),
m_registerHandler(engine),
m_sourceFilesHandler(engine),
@@ -243,10 +239,6 @@ public:
this, &DebuggerEnginePrivate::resetLocation);
connect(action(IntelFlavor), &Utils::SavedAction::valueChanged,
this, &DebuggerEnginePrivate::reloadDisassembly);
Utils::globalMacroExpander()->registerFileVariables(PrefixDebugExecutable,
tr("Debugged executable"),
[this] { return m_runParameters.inferior.executable; });
}
void doSetupEngine();
@@ -350,8 +342,6 @@ public:
DebuggerEngine *m_masterEngine = nullptr; // Not owned
QPointer<DebuggerRunTool> m_runTool; // Not owned.
DebuggerRunParameters m_runParameters;
// The current state.
DebuggerState m_state = DebuggerNotReady;
@@ -397,9 +387,10 @@ public:
//
//////////////////////////////////////////////////////////////////////
DebuggerEngine::DebuggerEngine(const DebuggerRunParameters &startParameters)
: d(new DebuggerEnginePrivate(this, startParameters))
{}
DebuggerEngine::DebuggerEngine()
: d(new DebuggerEnginePrivate(this))
{
}
DebuggerEngine::~DebuggerEngine()
{
@@ -572,13 +563,13 @@ void DebuggerEngine::start()
fp->setKeepOnFinish(FutureProgress::HideOnFinish);
d->m_progress.reportStarted();
d->m_inferiorPid = d->m_runParameters.attachPID.isValid()
? d->m_runParameters.attachPID : ProcessHandle();
DebuggerRunParameters &rp = runParameters();
d->m_inferiorPid = rp.attachPID.isValid() ? rp.attachPID : ProcessHandle();
if (d->m_inferiorPid.isValid())
runControl()->setApplicationProcessHandle(d->m_inferiorPid);
if (isNativeMixedActive())
d->m_runParameters.inferior.environment.set("QV4_FORCE_INTERPRETER", "1");
rp.inferior.environment.set("QV4_FORCE_INTERPRETER", "1");
action(OperateByInstruction)->setEnabled(hasCapability(DisassemblerCapability));
@@ -669,12 +660,12 @@ void DebuggerEngine::handleFinished()
const DebuggerRunParameters &DebuggerEngine::runParameters() const
{
return d->m_runParameters;
return runTool()->runParameters();
}
DebuggerRunParameters &DebuggerEngine::runParameters()
{
return d->m_runParameters;
return runTool()->runParameters();
}
DebuggerState DebuggerEngine::state() const
@@ -774,7 +765,7 @@ void DebuggerEnginePrivate::doSetupEngine()
{
m_engine->showMessage("CALL: SETUP ENGINE");
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << m_engine << state());
m_engine->validateExecutable(&m_runParameters);
m_engine->validateExecutable();
m_engine->setupEngine();
}
@@ -805,7 +796,6 @@ void DebuggerEngine::notifyEngineSetupOk()
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << this << state());
setState(EngineSetupOk);
Internal::runControlStarted(this);
d->queueSetupInferior();
}
@@ -838,7 +828,7 @@ void DebuggerEngine::notifyInferiorSetupOk()
#ifdef WITH_BENCHMARK
CALLGRIND_START_INSTRUMENTATION;
#endif
runTool()->aboutToNotifyInferiorSetupOk();
runTool()->aboutToNotifyInferiorSetupOk(); // FIXME: Remove, only used for Android.
showMessage("NOTE: INFERIOR SETUP OK");
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << this << state());
setState(InferiorSetupOk);
@@ -905,21 +895,22 @@ void DebuggerEngine::setRemoteParameters(const RemoteSetupResult &result)
showMessage(QString("NOTE: REMOTE SETUP DONE: GDB SERVER PORT: %1 QML PORT %2")
.arg(result.gdbServerPort.number()).arg(result.qmlServerPort.number()));
DebuggerRunParameters &rp = runParameters();
if (result.gdbServerPort.isValid()) {
QString &rc = d->m_runParameters.remoteChannel;
QString &rc = rp.remoteChannel;
const int sepIndex = rc.lastIndexOf(':');
if (sepIndex != -1) {
rc.replace(sepIndex + 1, rc.count() - sepIndex - 1,
QString::number(result.gdbServerPort.number()));
}
} else if (result.inferiorPid != InvalidPid && runParameters().startMode == AttachExternal) {
} else if (result.inferiorPid != InvalidPid && rp.startMode == AttachExternal) {
// e.g. iOS Simulator
runParameters().attachPID = ProcessHandle(result.inferiorPid);
rp.attachPID = ProcessHandle(result.inferiorPid);
}
if (result.qmlServerPort.isValid()) {
d->m_runParameters.qmlServer.port = result.qmlServerPort;
d->m_runParameters.inferior.commandLineArguments.replace("%qml_port%",
rp.qmlServer.port = result.qmlServerPort;
rp.inferior.commandLineArguments.replace("%qml_port%",
QString::number(result.qmlServerPort.number()));
}
}
@@ -1298,7 +1289,8 @@ void DebuggerEngine::setState(DebuggerState state, bool forced)
}
if (state == InferiorUnrunnable || state == InferiorRunOk) {
if (isMasterEngine() && runTool())
// FIXME: Called again for combined engine.
if (isMasterEngine() && runTool() && !runTool()->runControl()->isRunning())
runTool()->reportStarted();
}
@@ -1325,8 +1317,7 @@ void DebuggerEngine::updateViews()
{
// The slave engines are not entitled to change the view. Their wishes
// should be coordinated by their master engine.
if (isMasterEngine())
Internal::updateState(this);
Internal::updateState(runTool());
}
bool DebuggerEngine::isSlaveEngine() const
@@ -1373,7 +1364,7 @@ void DebuggerEngine::removeBreakpointMarker(const Breakpoint &bp)
QString DebuggerEngine::expand(const QString &string) const
{
return d->m_runParameters.macroExpander->expand(string);
return runParameters().macroExpander->expand(string);
}
QString DebuggerEngine::nativeStartupCommands() const
@@ -1456,10 +1447,9 @@ void DebuggerEngine::notifyInferiorPid(const ProcessHandle &pid)
if (pid.isValid()) {
runControl()->setApplicationProcessHandle(pid);
showMessage(tr("Taking notice of pid %1").arg(pid.pid()));
if (d->m_runParameters.startMode == StartInternal
|| d->m_runParameters.startMode == StartExternal
|| d->m_runParameters.startMode == AttachExternal)
QTimer::singleShot(0, d, &DebuggerEnginePrivate::raiseApplication);
DebuggerStartMode sm = runParameters().startMode;
if (sm == StartInternal || sm == StartExternal || sm == AttachExternal)
QTimer::singleShot(0, d, &DebuggerEnginePrivate::raiseApplication);
}
}
@@ -1542,7 +1532,7 @@ RunControl *DebuggerEngine::runControl() const
DebuggerRunTool *DebuggerEngine::runTool() const
{
return d->m_masterEngine ? d->m_masterEngine->runTool() : d->m_runTool.data();
return d->m_runTool.data();
}
Terminal *DebuggerEngine::terminal() const
@@ -1919,8 +1909,9 @@ void DebuggerEngine::setStateDebugging(bool on)
d->m_isStateDebugging = on;
}
void DebuggerEngine::validateExecutable(DebuggerRunParameters *sp)
void DebuggerEngine::validateExecutable()
{
DebuggerRunParameters *sp = &runParameters();
if (sp->skipExecutableValidation)
return;
if (sp->languages == QmlLanguage)

View File

@@ -194,7 +194,7 @@ class DebuggerEngine : public QObject
Q_OBJECT
public:
explicit DebuggerEngine(const DebuggerRunParameters &sp);
explicit DebuggerEngine();
virtual ~DebuggerEngine();
const DebuggerRunParameters &runParameters() const;
@@ -320,12 +320,14 @@ public:
virtual void resetLocation();
virtual void gotoLocation(const Internal::Location &location);
Q_SLOT virtual void quitDebugger(); // called by DebuggerRunControl
virtual void exitDebugger(); // called by DebuggerRunControl
virtual void abortDebugger(); // called by DebuggerPlugin
virtual void updateViews();
void updateViews();
bool isSlaveEngine() const;
bool isMasterEngine() const;
DebuggerEngine *masterEngine() const;
virtual DebuggerEngine *activeEngine() { return this; }
virtual DebuggerEngine *cppEngine() { return 0; }
virtual bool canDisplayTooltip() const;
@@ -398,7 +400,6 @@ protected:
virtual void resetInferior() {}
virtual void detachDebugger();
virtual void exitDebugger();
virtual void executeStep();
virtual void executeStepOut();
virtual void executeNext();
@@ -436,7 +437,7 @@ protected:
bool isStateDebugging() const;
void setStateDebugging(bool on);
static void validateExecutable(DebuggerRunParameters *sp);
void validateExecutable();
virtual void setupSlaveInferior();
virtual void setupSlaveEngine();
@@ -478,7 +479,6 @@ private:
QPointer<DebuggerEngine> m_engine;
};
DebuggerEngine *createEngine(DebuggerEngineType et, const DebuggerRunParameters &rp, QStringList *errors);
ProjectExplorer::RunControl *createAndScheduleRun(const DebuggerRunParameters &rp, ProjectExplorer::Kit *kit);
} // namespace Internal

View File

@@ -492,7 +492,7 @@ QAction *addCheckableAction(QMenu *menu, const QString &display, bool on, bool c
class DummyEngine : public DebuggerEngine
{
public:
DummyEngine() : DebuggerEngine(DebuggerRunParameters()) {}
DummyEngine() {}
~DummyEngine() override {}
void setupEngine() override {}
@@ -647,7 +647,7 @@ public:
void extensionsInitialized();
void aboutToShutdown();
void connectEngine(DebuggerEngine *engine);
void connectEngine(DebuggerRunTool *runTool);
void disconnectEngine() { connectEngine(0); }
DebuggerEngine *dummyEngine();
@@ -671,8 +671,11 @@ public:
void selectThread(int index)
{
ThreadId id = m_currentEngine->threadsHandler()->threadAt(index);
m_currentEngine->selectThread(id);
QTC_ASSERT(m_currentRunTool, return);
DebuggerEngine *engine = m_currentRunTool->activeEngine();
QTC_ASSERT(engine, return);
ThreadId id = engine->threadsHandler()->threadAt(index);
engine->selectThread(id);
}
void breakpointSetMarginActionTriggered(bool isMessageOnly, const ContextData &data)
@@ -715,14 +718,14 @@ public:
{
showMessage(QLatin1String("ATTEMPT SYNC"), LogDebug);
for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) {
if (DebuggerEngine *engine = m_snapshotHandler->at(i))
if (DebuggerEngine *engine = m_snapshotHandler->at(i)->engine())
engine->attemptBreakpointSynchronization();
}
}
void reloadSourceFiles() { if (m_currentEngine) m_currentEngine->reloadSourceFiles(); }
void reloadRegisters() { if (m_currentEngine) m_currentEngine->reloadRegisters(); }
void reloadModules() { if (m_currentEngine) m_currentEngine->reloadModules(); }
void reloadSourceFiles() { if (m_currentRunTool) m_currentRunTool->engine()->reloadSourceFiles(); }
void reloadRegisters() { if (m_currentRunTool) m_currentRunTool->engine()->reloadRegisters(); }
void reloadModules() { if (m_currentRunTool) m_currentRunTool->engine()->reloadModules(); }
void editorOpened(IEditor *editor);
void updateBreakMenuItem(IEditor *editor);
@@ -752,11 +755,11 @@ public:
void enableReverseDebuggingTriggered(const QVariant &value);
void showStatusMessage(const QString &msg, int timeout = -1);
void runControlStarted(DebuggerEngine *engine);
void runControlFinished(DebuggerEngine *engine);
void runControlStarted(DebuggerRunTool *runTool);
void runControlFinished(DebuggerRunTool *runTool);
void remoteCommand(const QStringList &options);
void displayDebugger(DebuggerEngine *engine, bool updateEngine = true);
void displayDebugger(DebuggerRunTool *runTool, bool updateEngine = true);
void dumpLog();
void cleanupViews();
@@ -764,7 +767,7 @@ public:
void fontSettingsChanged(const FontSettings &settings);
void updateState(DebuggerEngine *engine);
void updateState(DebuggerRunTool *runTool);
void onCurrentProjectChanged(Project *project);
void sessionLoaded();
@@ -929,7 +932,9 @@ public:
void handleExecExit()
{
currentEngine()->exitDebugger();
QTC_ASSERT(dd->m_currentRunTool, return);
return dd->m_currentRunTool->runControl()->initiateStop();
//currentEngine()->exitDebugger();
}
void handleFrameDown()
@@ -1060,7 +1065,8 @@ public:
SnapshotHandler *m_snapshotHandler = 0;
bool m_shuttingDown = false;
QPointer<DebuggerEngine> m_currentEngine;
QPointer<DebuggerEngine> m_previouslyActiveEngine;
QPointer<DebuggerRunTool> m_currentRunTool;
DebuggerSettings *m_debuggerSettings = 0;
QStringList m_arguments;
DebuggerToolTipManager m_toolTipManager;
@@ -1912,12 +1918,12 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project)
}
for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) {
// Run controls might be deleted during exit.
if (DebuggerEngine *engine = m_snapshotHandler->at(i)) {
if (RunControl *runControl = engine->runControl()) {
if (DebuggerRunTool *runTool = m_snapshotHandler->at(i)) {
if (RunControl *runControl = runTool->runControl()) {
RunConfiguration *rc = runControl->runConfiguration();
if (rc == activeRc) {
m_snapshotHandler->setCurrentIndex(i);
updateState(engine);
updateState(runTool);
return;
}
}
@@ -2143,7 +2149,7 @@ void DebuggerPlugin::getEnginesState(QByteArray *json) const
QVariantMap states;
for (int i = 0; i < dd->m_snapshotHandler->size(); ++i) {
const DebuggerEngine *engine = dd->m_snapshotHandler->at(i);
const DebuggerEngine *engine = dd->m_snapshotHandler->at(i)->engine();
states[QString::number(i)] = QVariantMap({
{"current", dd->m_snapshotHandler->currentIndex() == i},
{"pid", engine->inferiorPid()},
@@ -2401,30 +2407,35 @@ void DebuggerPluginPrivate::requestMark(TextEditorWidget *widget, int lineNumber
}
// If updateEngine is set, the engine will update its threads/modules and so forth.
void DebuggerPluginPrivate::displayDebugger(DebuggerEngine *engine, bool updateEngine)
void DebuggerPluginPrivate::displayDebugger(DebuggerRunTool *runTool, bool updateEngine)
{
QTC_ASSERT(runTool, return);
DebuggerEngine *engine = runTool ? runTool->engine() : dummyEngine();
QTC_ASSERT(engine, return);
disconnectEngine();
connectEngine(engine);
connectEngine(runTool);
if (updateEngine)
engine->updateAll();
engine->updateViews();
}
void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine)
void DebuggerPluginPrivate::connectEngine(DebuggerRunTool *runTool)
{
if (!engine)
engine = dummyEngine();
if (m_currentEngine == engine)
return;
if (m_shuttingDown)
return;
if (m_currentEngine)
m_currentEngine->resetLocation();
m_currentEngine = engine;
m_currentRunTool = runTool;
DebuggerEngine *engine = currentEngine();
QTC_ASSERT(engine, return);
if (m_previouslyActiveEngine == engine)
return;
if (m_previouslyActiveEngine)
m_previouslyActiveEngine->resetLocation();
m_previouslyActiveEngine = engine;
m_localsView->setModel(engine->watchModel());
m_modulesView->setModel(engine->modulesModel());
@@ -2560,10 +2571,12 @@ void DebuggerPluginPrivate::setInitialState()
m_threadLabel->setEnabled(false);
}
void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
void DebuggerPluginPrivate::updateState(DebuggerRunTool *runTool)
{
if (m_shuttingDown)
return;
QTC_ASSERT(runTool, return);
DebuggerEngine *engine = runTool->engine();
QTC_ASSERT(engine, return);
QTC_ASSERT(m_watchersView->model(), return);
QTC_ASSERT(m_returnView->model(), return);
@@ -2657,7 +2670,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_threadBox->setEnabled(state == InferiorStopOk || state == InferiorUnrunnable);
m_threadLabel->setEnabled(m_threadBox->isEnabled());
const bool isCore = engine->runParameters().startMode == AttachCore;
const bool isCore = runTool->runParameters().startMode == AttachCore;
const bool stopped = state == InferiorStopOk;
const bool detachable = stopped && !isCore;
m_detachAction->setEnabled(detachable);
@@ -2712,7 +2725,7 @@ void DebuggerPluginPrivate::updateDebugActions()
if (m_shuttingDown)
return;
//if we're currently debugging the actions are controlled by engine
if (m_currentEngine && m_currentEngine->state() != DebuggerNotReady)
if (m_currentRunTool && m_currentRunTool->engine()->state() != DebuggerNotReady)
return;
QString whyNot;
@@ -2941,27 +2954,27 @@ static QString formatStartParameters(DebuggerRunParameters &sp)
return rc;
}
void DebuggerPluginPrivate::runControlStarted(DebuggerEngine *engine)
void DebuggerPluginPrivate::runControlStarted(DebuggerRunTool *runTool)
{
activateDebugMode();
const QString message = tr("Starting debugger \"%1\" for ABI \"%2\"...")
.arg(engine->objectName())
.arg(engine->runParameters().toolChainAbi.toString());
.arg(runTool->objectName())
.arg(runTool->runParameters().toolChainAbi.toString());
showStatusMessage(message);
showMessage(formatStartParameters(engine->runParameters()), LogDebug);
showMessage(formatStartParameters(runTool->runParameters()), LogDebug);
showMessage(m_debuggerSettings->dump(), LogDebug);
m_snapshotHandler->appendSnapshot(engine);
connectEngine(engine);
m_snapshotHandler->appendSnapshot(runTool);
connectEngine(runTool);
}
void DebuggerPluginPrivate::runControlFinished(DebuggerEngine *engine)
void DebuggerPluginPrivate::runControlFinished(DebuggerRunTool *runTool)
{
if (engine)
engine->handleFinished();
if (runTool && runTool->engine())
runTool->engine()->handleFinished();
if (m_shuttingDown)
return;
showStatusMessage(tr("Debugger finished."));
m_snapshotHandler->removeSnapshot(engine);
m_snapshotHandler->removeSnapshot(runTool);
if (m_snapshotHandler->size() == 0) {
// Last engine quits.
disconnectEngine();
@@ -3031,7 +3044,9 @@ void DebuggerPluginPrivate::extensionsInitialized()
DebuggerEngine *currentEngine()
{
return dd->m_currentEngine;
QTC_ASSERT(dd->m_currentRunTool, return dd->dummyEngine());
DebuggerEngine *engine = dd->m_currentRunTool->activeEngine();
return engine ? engine : dd->dummyEngine();
}
SavedAction *action(int code)
@@ -3139,9 +3154,9 @@ void DebuggerPluginPrivate::aboutToShutdown()
m_mode = 0;
}
void updateState(DebuggerEngine *engine)
void updateState(DebuggerRunTool *runTool)
{
dd->updateState(engine);
dd->updateState(runTool);
}
void updateWatchersWindow(bool showWatch, bool showReturn)
@@ -3179,19 +3194,19 @@ void showMessage(const QString &msg, int channel, int timeout)
dd->showMessage(msg, channel, timeout);
}
void runControlStarted(DebuggerEngine *engine)
void runControlStarted(DebuggerRunTool *runTool)
{
dd->runControlStarted(engine);
dd->runControlStarted(runTool);
}
void runControlFinished(DebuggerEngine *engine)
void runControlFinished(DebuggerRunTool *runTool)
{
dd->runControlFinished(engine);
dd->runControlFinished(runTool);
}
void displayDebugger(DebuggerEngine *engine, bool updateEngine)
void displayDebugger(DebuggerRunTool *runTool, bool updateEngine)
{
dd->displayDebugger(engine, updateEngine);
dd->displayDebugger(runTool, updateEngine);
}
void synchronizeBreakpoints()
@@ -3354,8 +3369,8 @@ void DebuggerPluginPrivate::updateUiForTarget(Target *target)
void DebuggerPluginPrivate::updateActiveLanguages()
{
QTC_ASSERT(dd->m_currentEngine, return);
const DebuggerLanguages languages = dd->m_currentEngine->runParameters().languages;
QTC_ASSERT(dd->m_currentRunTool, return);
const DebuggerLanguages languages = dd->m_currentRunTool->runParameters().languages;
// Id perspective = (languages & QmlLanguage) && !(languages & CppLanguage)
// ? QmlPerspectiveId : CppPerspectiveId;
// m_mainWindow->restorePerspective(perspective);
@@ -3676,13 +3691,14 @@ void DebuggerUnitTests::testStateMachine()
rp.testCase = TestNoBoundsOfCurrentFunction;
auto runControl = new RunControl(rc, ProjectExplorer::Constants::DEBUG_RUN_MODE);
(void) new DebuggerRunTool(runControl, rp);
ProjectExplorerPlugin::startRunControl(runControl);
auto runTool = new DebuggerRunTool(runControl, rp);
connect(runControl, &RunControl::finished, this, [this] {
connect(runTool, &DebuggerRunTool::stopped, this, [this] {
QTestEventLoop::instance().exitLoop();
});
ProjectExplorerPlugin::startRunControl(runControl);
QTestEventLoop::instance().enterLoop(5);
}

View File

@@ -73,15 +73,15 @@ enum { debug = 0 };
namespace Debugger {
namespace Internal {
DebuggerEngine *createCdbEngine(const DebuggerRunParameters &rp, QStringList *error);
const auto DebugRunMode = ProjectExplorer::Constants::DEBUG_RUN_MODE;
const auto DebugRunModeWithBreakOnMain = ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN;
DebuggerEngine *createGdbEngine(const DebuggerRunParameters &rp);
DebuggerEngine *createPdbEngine(const DebuggerRunParameters &rp);
DebuggerEngine *createQmlEngine(const DebuggerRunParameters &rp);
DebuggerEngine *createQmlCppEngine(const DebuggerRunParameters &rp, QStringList *error);
DebuggerEngine *createLldbEngine(const DebuggerRunParameters &rp);
DebuggerEngine *createCdbEngine(QStringList *error, DebuggerStartMode sm);
DebuggerEngine *createGdbEngine(bool useTerminal, DebuggerStartMode sm);
DebuggerEngine *createPdbEngine();
DebuggerEngine *createQmlEngine(bool useTerminal);
DebuggerEngine *createQmlCppEngine(DebuggerEngine *cppEngine, bool useTerminal);
DebuggerEngine *createLldbEngine();
} // namespace Internal
@@ -154,6 +154,7 @@ void DebuggerRunTool::start()
}
appendMessage(tr("Debugging starts") + QLatin1Char('\n'), NormalMessageFormat);
Internal::runControlStarted(this);
engine->start();
}
@@ -175,7 +176,7 @@ void DebuggerRunTool::notifyEngineRemoteSetupFinished(const RemoteSetupResult &r
void DebuggerRunTool::stop()
{
m_engine->quitDebugger();
m_engine->exitDebugger();
}
void DebuggerRunTool::onTargetFailure()
@@ -190,12 +191,19 @@ void DebuggerRunTool::onTargetFailure()
void DebuggerRunTool::debuggingFinished()
{
Internal::runControlFinished(this);
appendMessage(tr("Debugging has finished"), NormalMessageFormat);
reportStopped();
}
DebuggerStartParameters &DebuggerRunTool::startParameters()
DebuggerRunParameters &DebuggerRunTool::runParameters()
{
return m_engine->runParameters();
return m_runParameters;
}
const DebuggerRunParameters &DebuggerRunTool::runParameters() const
{
return m_runParameters;
}
int DebuggerRunTool::portsUsedByDebugger() const
@@ -232,35 +240,46 @@ void DebuggerRunTool::abortDebugger()
namespace Internal {
// Re-used for Combined C++/QML engine.
DebuggerEngine *createEngine(DebuggerEngineType et, const DebuggerRunParameters &rp, QStringList *errors)
DebuggerEngine *createEngine(DebuggerEngineType cppEngineType,
DebuggerEngineType et,
DebuggerStartMode sm,
bool useTerminal,
QStringList *errors)
{
DebuggerEngine *engine = nullptr;
switch (et) {
case GdbEngineType:
engine = createGdbEngine(rp);
engine = createGdbEngine(useTerminal, sm);
break;
case CdbEngineType:
engine = createCdbEngine(rp, errors);
engine = createCdbEngine(errors, sm);
break;
case PdbEngineType:
engine = createPdbEngine(rp);
engine = createPdbEngine();
break;
case QmlEngineType:
engine = createQmlEngine(rp);
engine = createQmlEngine(useTerminal);
break;
case LldbEngineType:
engine = createLldbEngine(rp);
engine = createLldbEngine();
break;
case QmlCppEngineType:
engine = createQmlCppEngine(rp, errors);
case QmlCppEngineType: {
DebuggerEngine *cppEngine = createEngine(cppEngineType, cppEngineType, sm, useTerminal, errors);
if (cppEngine) {
engine = createQmlCppEngine(cppEngine, useTerminal);
} else {
errors->append(DebuggerPlugin::tr("The slave debugging engine required for combined "
"QML/C++-Debugging could not be created: %1"));
}
break;
}
default:
errors->append(DebuggerPlugin::tr("Unknown debugger type \"%1\"")
.arg(engineTypeName(et)));
}
if (!engine)
errors->append(DebuggerPlugin::tr("Unable to create a debugger engine of the type \"%1\"").
arg(engineTypeName(rp.masterEngineType)));
arg(engineTypeName(et)));
return engine;
}
@@ -518,11 +537,10 @@ void DebuggerRunTool::setRunParameters(const DebuggerRunParameters &rp, QString
return;
}
DebuggerRunParameters m_rp = rp;
m_runParameters = rp;
runControl()->setDisplayName(m_rp.displayName);
// QML and/or mixed are not prepared for it.
runControl()->setSupportsReRunning(!(m_rp.languages & QmlLanguage));
runControl()->setSupportsReRunning(!(rp.languages & QmlLanguage));
runControl()->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL_TOOLBAR);
runControl()->setPromptToStop([](bool *optionalPrompt) {
@@ -535,25 +553,40 @@ void DebuggerRunTool::setRunParameters(const DebuggerRunParameters &rp, QString
QString(), QString(), optionalPrompt);
});
if (Internal::fixupParameters(m_rp, runControl(), m_errors)) {
m_engine = createEngine(m_rp.masterEngineType, m_rp, &m_errors);
if (Internal::fixupParameters(m_runParameters, runControl(), m_errors)) {
m_engine = createEngine(m_runParameters.cppEngineType,
m_runParameters.masterEngineType,
m_runParameters.startMode,
m_runParameters.useTerminal,
&m_errors);
if (!m_engine) {
QString msg = m_errors.join('\n');
if (errorMessage)
*errorMessage = msg;
return;
}
Utils::globalMacroExpander()->registerFileVariables(
"DebuggedExecutable", tr("Debugged executable"),
[this] { return m_runParameters.inferior.executable; }
);
}
runControl()->setDisplayName(m_runParameters.displayName);
m_engine->setRunTool(this);
}
DebuggerEngine *DebuggerRunTool::activeEngine() const
{
return m_engine ? m_engine->activeEngine() : nullptr;
}
void DebuggerRunTool::appendSolibSearchPath(const QString &str)
{
QString path = str;
DebuggerStartParameters &sp = startParameters();
path.replace("%{sysroot}", sp.sysRoot);
sp.solibSearchPath.append(path);
path.replace("%{sysroot}", m_runParameters.sysRoot);
m_runParameters.solibSearchPath.append(path);
}
DebuggerRunTool::~DebuggerRunTool()
@@ -567,12 +600,6 @@ DebuggerRunTool::~DebuggerRunTool()
}
}
void DebuggerRunTool::onFinished()
{
appendMessage(tr("Debugging has finished"), NormalMessageFormat);
runControlFinished(m_engine);
}
void DebuggerRunTool::showMessage(const QString &msg, int channel, int timeout)
{
if (channel == ConsoleOutput)
@@ -783,7 +810,7 @@ void GdbServerRunner::start()
m_gdbServer.start(r, device());
}
void GdbServerRunner::onFinished()
void GdbServerRunner::stop()
{
m_gdbServer.stop();
}

View File

@@ -58,12 +58,12 @@ public:
QString *errorMessage = nullptr); // FIXME: Don't use.
Internal::DebuggerEngine *engine() const { return m_engine; }
Internal::DebuggerEngine *activeEngine() const;
void showMessage(const QString &msg, int channel = LogDebug, int timeout = -1);
void start() override;
void stop() override;
void onFinished() override;
void startFailed();
void onTargetFailure();
@@ -75,7 +75,8 @@ public:
void abortDebugger();
void debuggingFinished();
DebuggerStartParameters &startParameters(); // Used in Boot2Qt.
Internal::DebuggerRunParameters &runParameters();
const Internal::DebuggerRunParameters &runParameters() const;
bool isCppDebugging() const { return m_isCppDebugging; }
bool isQmlDebugging() const { return m_isQmlDebugging; }
@@ -91,6 +92,7 @@ signals:
private:
Internal::DebuggerEngine *m_engine = nullptr; // Master engine
Internal::DebuggerRunParameters m_runParameters;
QStringList m_errors;
const bool m_isCppDebugging;
const bool m_isQmlDebugging;
@@ -132,7 +134,7 @@ public:
private:
void start() override;
void onFinished() override;
void stop() override;
ProjectExplorer::ApplicationLauncher m_gdbServer;
};

View File

@@ -35,8 +35,8 @@
namespace Debugger {
namespace Internal {
GdbAttachEngine::GdbAttachEngine(const DebuggerRunParameters &startParameters)
: GdbEngine(startParameters)
GdbAttachEngine::GdbAttachEngine(bool useTerminal)
: GdbEngine(useTerminal)
{
}

View File

@@ -41,7 +41,7 @@ class GdbAttachEngine : public GdbEngine
Q_OBJECT
public:
explicit GdbAttachEngine(const DebuggerRunParameters &runParameters);
explicit GdbAttachEngine(bool useTerminal);
private:
void setupEngine() override;

View File

@@ -54,9 +54,8 @@ namespace Internal {
//
///////////////////////////////////////////////////////////////////////
GdbCoreEngine::GdbCoreEngine(const DebuggerRunParameters &startParameters)
: GdbEngine(startParameters),
m_coreUnpackProcess(0)
GdbCoreEngine::GdbCoreEngine(bool useTerminal)
: GdbEngine(useTerminal)
{}
GdbCoreEngine::~GdbCoreEngine()

View File

@@ -37,7 +37,7 @@ class GdbCoreEngine : public GdbEngine
Q_OBJECT
public:
explicit GdbCoreEngine(const DebuggerRunParameters &runParameters);
explicit GdbCoreEngine(bool useTerminal);
~GdbCoreEngine() override;
struct CoreInfo
@@ -70,7 +70,7 @@ private:
QString m_executable;
QString m_coreName;
QString m_tempCoreName;
QProcess *m_coreUnpackProcess;
QProcess *m_coreUnpackProcess = nullptr;
QFile m_tempCoreFile;
};

View File

@@ -204,8 +204,7 @@ private:
//
///////////////////////////////////////////////////////////////////////
GdbEngine::GdbEngine(const DebuggerRunParameters &startParameters)
: DebuggerEngine(startParameters)
GdbEngine::GdbEngine(bool useTerminal)
{
setObjectName("GdbEngine");
@@ -222,7 +221,7 @@ GdbEngine::GdbEngine(const DebuggerRunParameters &startParameters)
m_pendingBreakpointRequests = 0;
m_commandsDoneCallback = 0;
m_stackNeeded = false;
m_terminalTrap = startParameters.useTerminal;
m_terminalTrap = useTerminal;
m_systemDumpersLoaded = false;
m_rerunPending = false;
m_inUpdateLocals = false;
@@ -4355,20 +4354,20 @@ void GdbEngine::debugLastCommand()
// Factory
//
DebuggerEngine *createGdbEngine(const DebuggerRunParameters &rp)
DebuggerEngine *createGdbEngine(bool useTerminal, DebuggerStartMode sm)
{
switch (rp.startMode) {
switch (sm) {
case AttachCore:
return new GdbCoreEngine(rp);
return new GdbCoreEngine(useTerminal);
case StartRemoteProcess:
case AttachToRemoteServer:
return new GdbRemoteServerEngine(rp);
return new GdbRemoteServerEngine(useTerminal);
case AttachExternal:
return new GdbAttachEngine(rp);
return new GdbAttachEngine(useTerminal);
default:
if (rp.useTerminal)
return new GdbTermEngine(rp);
return new GdbPlainEngine(rp);
if (useTerminal)
return new GdbTermEngine(useTerminal);
return new GdbPlainEngine(useTerminal);
}
}

View File

@@ -66,7 +66,7 @@ class GdbEngine : public DebuggerEngine
Q_OBJECT
public:
explicit GdbEngine(const DebuggerRunParameters &runParameters);
explicit GdbEngine(bool useTerminal);
~GdbEngine() override;
private: ////////// General Interface //////////

View File

@@ -40,8 +40,8 @@ namespace Internal {
#define CB(callback) [this](const DebuggerResponse &r) { callback(r); }
GdbPlainEngine::GdbPlainEngine(const DebuggerRunParameters &startParameters)
: GdbEngine(startParameters)
GdbPlainEngine::GdbPlainEngine(bool useTerminal)
: GdbEngine(useTerminal)
{
// Output
connect(&m_outputCollector, &OutputCollector::byteDelivery,

View File

@@ -37,7 +37,7 @@ class GdbPlainEngine : public GdbEngine
Q_OBJECT
public:
explicit GdbPlainEngine(const DebuggerRunParameters &runParameters);
explicit GdbPlainEngine(bool useTerminal);
private:
void handleExecRun(const DebuggerResponse &response);

View File

@@ -54,12 +54,9 @@ namespace Internal {
//
///////////////////////////////////////////////////////////////////////
GdbRemoteServerEngine::GdbRemoteServerEngine(const DebuggerRunParameters &runParameters)
: GdbEngine(runParameters), m_startAttempted(false)
GdbRemoteServerEngine::GdbRemoteServerEngine(bool useTerminal)
: GdbEngine(useTerminal)
{
if (HostOsInfo::isWindowsHost())
m_gdbProc.setUseCtrlCStub(runParameters.useCtrlCStub); // This is only set for QNX
connect(&m_uploadProc, &QProcess::errorOccurred, this, &GdbRemoteServerEngine::uploadProcError);
connect(&m_uploadProc, &QProcess::readyReadStandardOutput,
this, &GdbRemoteServerEngine::readUploadStandardOutput);
@@ -71,6 +68,9 @@ GdbRemoteServerEngine::GdbRemoteServerEngine(const DebuggerRunParameters &runPar
void GdbRemoteServerEngine::setupEngine()
{
if (HostOsInfo::isWindowsHost())
m_gdbProc.setUseCtrlCStub(runParameters().useCtrlCStub); // This is only set for QNX
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
showMessage("TRYING TO START ADAPTER");
QString serverStartScript = runParameters().serverStartScript;
@@ -170,8 +170,7 @@ void GdbRemoteServerEngine::setupInferior()
//const QByteArray sysroot = sp.sysroot.toLocal8Bit();
//const QByteArray remoteArch = sp.remoteArchitecture.toLatin1();
const QString args = isMasterEngine() ? runParameters().inferior.commandLineArguments
: masterEngine()->runParameters().inferior.commandLineArguments;
const QString args = runParameters().inferior.commandLineArguments;
// if (!remoteArch.isEmpty())
// postCommand("set architecture " + remoteArch);

View File

@@ -35,7 +35,7 @@ class GdbRemoteServerEngine : public GdbEngine
Q_OBJECT
public:
explicit GdbRemoteServerEngine(const DebuggerRunParameters &runParameters);
explicit GdbRemoteServerEngine(bool useTerminal);
private:
void setupEngine() override;
@@ -65,7 +65,7 @@ private:
void handleExecRun(const DebuggerResponse &response);
QProcess m_uploadProc;
bool m_startAttempted;
bool m_startAttempted = false;
};
} // namespace Internal

View File

@@ -46,8 +46,8 @@ namespace Internal {
//
///////////////////////////////////////////////////////////////////////
GdbTermEngine::GdbTermEngine(const DebuggerRunParameters &startParameters)
: GdbEngine(startParameters)
GdbTermEngine::GdbTermEngine(bool useTerminal)
: GdbEngine(useTerminal)
{
if (HostOsInfo::isWindowsHost()) {
// Windows up to xp needs a workaround for attaching to freshly started processes. see proc_stub_win

View File

@@ -43,7 +43,7 @@ class GdbTermEngine : public GdbEngine
Q_OBJECT
public:
explicit GdbTermEngine(const DebuggerRunParameters &runParameters);
explicit GdbTermEngine(bool useTerminal);
~GdbTermEngine() override;
private:

View File

@@ -81,11 +81,9 @@ static int &currentToken()
//
///////////////////////////////////////////////////////////////////////
LldbEngine::LldbEngine(const DebuggerRunParameters &startParameters)
: DebuggerEngine(startParameters), m_continueAtNextSpontaneousStop(false)
LldbEngine::LldbEngine()
{
m_lastAgentId = 0;
setObjectName(QLatin1String("LldbEngine"));
setObjectName("LldbEngine");
connect(action(AutoDerefPointers), &SavedAction::valueChanged,
this, &LldbEngine::updateLocals);
@@ -1116,9 +1114,9 @@ bool LldbEngine::hasCapability(unsigned cap) const
return false;
}
DebuggerEngine *createLldbEngine(const DebuggerRunParameters &startParameters)
DebuggerEngine *createLldbEngine()
{
return new LldbEngine(startParameters);
return new LldbEngine;
}
void LldbEngine::notifyEngineRemoteSetupFinished(const RemoteSetupResult &result)

View File

@@ -58,7 +58,7 @@ class LldbEngine : public DebuggerEngine
Q_OBJECT
public:
explicit LldbEngine(const DebuggerRunParameters &runParameters);
LldbEngine();
~LldbEngine() override;
signals:
@@ -152,8 +152,8 @@ private:
Utils::QtcProcess m_lldbProc;
// FIXME: Make generic.
int m_lastAgentId;
int m_continueAtNextSpontaneousStop;
int m_lastAgentId = 0;
int m_continueAtNextSpontaneousStop = false;
QMap<QPointer<DisassemblerAgent>, int> m_disassemblerAgents;
QHash<int, DebuggerCommand> m_commandForToken;

View File

@@ -63,10 +63,9 @@ using namespace Core;
namespace Debugger {
namespace Internal {
PdbEngine::PdbEngine(const DebuggerRunParameters &startParameters)
: DebuggerEngine(startParameters)
PdbEngine::PdbEngine()
{
setObjectName(QLatin1String("PdbEngine"));
setObjectName("PdbEngine");
}
void PdbEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages languages)
@@ -579,9 +578,9 @@ bool PdbEngine::hasCapability(unsigned cap) const
| ShowModuleSymbolsCapability);
}
DebuggerEngine *createPdbEngine(const DebuggerRunParameters &startParameters)
DebuggerEngine *createPdbEngine()
{
return new PdbEngine(startParameters);
return new PdbEngine;
}
} // namespace Internal

View File

@@ -44,7 +44,7 @@ class PdbEngine : public DebuggerEngine
Q_OBJECT
public:
explicit PdbEngine(const DebuggerRunParameters &runParameters);
PdbEngine();
private:
// DebuggerEngine implementation

View File

@@ -26,6 +26,7 @@
#include "qmlcppengine.h"
#include "qmlengine.h"
#include <debugger/debuggercore.h>
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggertooltipmanager.h>
#include <debugger/debuggerstartparameters.h>
@@ -48,13 +49,9 @@ enum { debug = 0 };
#define CHECK_STATE(s) do { checkState(s, __FILE__, __LINE__); } while (0)
DebuggerEngine *createQmlCppEngine(const DebuggerRunParameters &sp, QStringList *errors)
DebuggerEngine *createQmlCppEngine(DebuggerEngine *cppEngine, bool useTerminal)
{
QmlCppEngine *newEngine = new QmlCppEngine(sp, errors);
if (newEngine->cppEngine())
return newEngine;
delete newEngine;
return 0;
return new QmlCppEngine(cppEngine, useTerminal);
}
@@ -64,19 +61,12 @@ DebuggerEngine *createQmlCppEngine(const DebuggerRunParameters &sp, QStringList
//
////////////////////////////////////////////////////////////////////////
QmlCppEngine::QmlCppEngine(const DebuggerRunParameters &rp, QStringList *errors)
: DebuggerEngine(rp)
QmlCppEngine::QmlCppEngine(DebuggerEngine *cppEngine, bool useTerminal)
{
setObjectName(QLatin1String("QmlCppEngine"));
m_qmlEngine = new QmlEngine(rp, this);
QStringList innerErrors;
m_cppEngine = createEngine(rp.cppEngineType, rp, &innerErrors);
if (!m_cppEngine) {
errors->append(tr("The slave debugging engine required for combined "
"QML/C++-Debugging could not be created: %1")
.arg(innerErrors.join(QLatin1Char('\n'))));
return;
}
setObjectName("QmlCppEngine");
m_qmlEngine = new QmlEngine(useTerminal);
m_qmlEngine->setMasterEngine(this);
m_cppEngine = cppEngine;
m_cppEngine->setMasterEngine(this);
setActiveEngine(m_cppEngine);
}
@@ -770,6 +760,13 @@ DebuggerEngine *QmlCppEngine::qmlEngine() const
return m_qmlEngine;
}
void QmlCppEngine::setRunTool(DebuggerRunTool *runTool)
{
DebuggerEngine::setRunTool(runTool);
m_qmlEngine->setRunTool(runTool);
m_cppEngine->setRunTool(runTool);
}
void QmlCppEngine::setActiveEngine(DebuggerEngine *engine)
{
m_activeEngine = engine;

View File

@@ -37,7 +37,7 @@ class QmlCppEngine : public DebuggerEngine
Q_OBJECT
public:
QmlCppEngine(const DebuggerRunParameters &sp, QStringList *errors);
QmlCppEngine(DebuggerEngine *cppEngine, bool useTerminal);
~QmlCppEngine() override;
bool canDisplayTooltip() const override;
@@ -80,6 +80,8 @@ public:
DebuggerEngine *cppEngine() override { return m_cppEngine; }
DebuggerEngine *qmlEngine() const;
DebuggerEngine *activeEngine() override { return m_activeEngine; }
void setRunTool(DebuggerRunTool *runTool) override;
void notifyEngineRemoteSetupFinished(const RemoteSetupResult &result) override;
void resetLocation() override;

View File

@@ -257,15 +257,11 @@ static void updateDocument(IDocument *document, const QTextDocument *textDocumen
//
///////////////////////////////////////////////////////////////////////
QmlEngine::QmlEngine(const DebuggerRunParameters &startParameters, DebuggerEngine *masterEngine)
: DebuggerEngine(startParameters),
d(new QmlEnginePrivate(this, new QmlDebugConnection(this)))
QmlEngine::QmlEngine(bool useTerminal)
: d(new QmlEnginePrivate(this, new QmlDebugConnection(this)))
{
setObjectName("QmlEngine");
if (masterEngine)
setMasterEngine(masterEngine);
connect(stackHandler(), &StackHandler::stackChanged,
this, &QmlEngine::updateCurrentContext);
connect(stackHandler(), &StackHandler::currentIndexChanged,
@@ -276,7 +272,7 @@ QmlEngine::QmlEngine(const DebuggerRunParameters &startParameters, DebuggerEngin
connect(&d->applicationLauncher, &ApplicationLauncher::processExited,
this, &QmlEngine::disconnected);
connect(&d->applicationLauncher, &ApplicationLauncher::appendMessage,
this, &QmlEngine::appendMessage);
this, &QmlEngine::appMessage);
connect(&d->applicationLauncher, &ApplicationLauncher::processStarted,
this, &QmlEngine::handleLauncherStarted);
@@ -296,7 +292,7 @@ QmlEngine::QmlEngine(const DebuggerRunParameters &startParameters, DebuggerEngin
this, [this] { tryToConnect(); });
// we won't get any debug output
if (startParameters.useTerminal) {
if (useTerminal) {
d->noDebugOutputTimer.setInterval(0);
d->retryOnConnectFail = true;
d->automaticConnect = true;
@@ -380,7 +376,7 @@ void QmlEngine::handleLauncherStarted()
d->noDebugOutputTimer.start();
}
void QmlEngine::appendMessage(const QString &msg, Utils::OutputFormat /* format */)
void QmlEngine::appMessage(const QString &msg, Utils::OutputFormat /* format */)
{
showMessage(msg, AppOutput); // FIXME: Redirect to RunControl
}
@@ -576,10 +572,10 @@ void QmlEngine::startApplicationLauncher()
{
if (!d->applicationLauncher.isRunning()) {
StandardRunnable runnable = runParameters().inferior;
appendMessage(tr("Starting %1 %2").arg(
QDir::toNativeSeparators(runnable.executable),
runnable.commandLineArguments) + '\n',
Utils::NormalMessageFormat);
runTool()->appendMessage(tr("Starting %1 %2").arg(
QDir::toNativeSeparators(runnable.executable),
runnable.commandLineArguments),
Utils::NormalMessageFormat);
d->applicationLauncher.start(runnable);
}
}
@@ -2579,9 +2575,9 @@ void QmlEnginePrivate::flushSendBuffer()
sendBuffer.clear();
}
DebuggerEngine *createQmlEngine(const DebuggerRunParameters &sp)
DebuggerEngine *createQmlEngine(bool useTerminal)
{
return new QmlEngine(sp);
return new QmlEngine(useTerminal);
}
} // Internal

View File

@@ -43,8 +43,7 @@ class QmlEngine : public DebuggerEngine
Q_OBJECT
public:
explicit QmlEngine(const DebuggerRunParameters &runParameters,
DebuggerEngine *masterEngine = nullptr);
explicit QmlEngine(bool useTerminal);
~QmlEngine() override;
void setRunTool(DebuggerRunTool *runTool) override;
@@ -66,7 +65,7 @@ private:
void connectionEstablished();
void connectionStartupFailed();
void appStartupFailed(const QString &errorMessage);
void appendMessage(const QString &msg, Utils::OutputFormat);
void appMessage(const QString &msg, Utils::OutputFormat);
void notifyEngineRemoteServerRunning(const QString &, int pid) override;
void notifyEngineRemoteSetupFinished(const RemoteSetupResult &result) override;

View File

@@ -28,12 +28,10 @@
#include "debuggerinternalconstants.h"
#include "debuggericons.h"
#include "debuggercore.h"
#include "debuggerengine.h"
#include "debuggerstartparameters.h"
#include "debuggerruncontrol.h"
#include <utils/qtcassert.h>
#include <QIcon>
#include <QDebug>
#include <QFile>
@@ -126,8 +124,8 @@ SnapshotHandler::SnapshotHandler()
SnapshotHandler::~SnapshotHandler()
{
for (int i = m_snapshots.size(); --i >= 0; ) {
if (DebuggerEngine *engine = at(i)) {
const DebuggerRunParameters &rp = engine->runParameters();
if (DebuggerRunTool *runTool = at(i)) {
const DebuggerRunParameters &rp = runTool->runParameters();
if (rp.isSnapshot && !rp.coreFile.isEmpty())
QFile::remove(rp.coreFile);
}
@@ -150,15 +148,15 @@ QVariant SnapshotHandler::data(const QModelIndex &index, int role) const
if (!index.isValid() || index.row() >= m_snapshots.size())
return QVariant();
const DebuggerEngine *engine = at(index.row());
const DebuggerRunTool *runTool = at(index.row());
if (role == SnapshotCapabilityRole)
return engine && engine->hasCapability(SnapshotCapability);
return runTool && runTool->activeEngine()->hasCapability(SnapshotCapability);
if (!engine)
if (!runTool)
return QLatin1String("<finished>");
const DebuggerRunParameters &rp = engine->runParameters();
const DebuggerRunParameters &rp = runTool->runParameters();
switch (role) {
case Qt::DisplayRole:
@@ -215,22 +213,22 @@ void SnapshotHandler::activateSnapshot(int index)
void SnapshotHandler::createSnapshot(int index)
{
DebuggerEngine *engine = at(index);
QTC_ASSERT(engine, return);
engine->createSnapshot();
DebuggerRunTool *runTool = at(index);
QTC_ASSERT(runTool, return);
runTool->engine()->createSnapshot();
}
void SnapshotHandler::removeSnapshot(int index)
{
DebuggerEngine *engine = at(index);
//qDebug() << "REMOVING " << engine;
QTC_ASSERT(engine, return);
DebuggerRunTool *runTool = at(index);
//qDebug() << "REMOVING " << runTool;
QTC_ASSERT(runTool, return);
#if 0
// See http://sourceware.org/bugzilla/show_bug.cgi?id=11241.
setState(EngineSetupRequested);
postCommand("set stack-cache off");
#endif
//QString fileName = engine->startParameters().coreFile;
//QString fileName = runTool->startParameters().coreFile;
//if (!fileName.isEmpty())
// QFile::remove(fileName);
beginResetModel();
@@ -239,7 +237,7 @@ void SnapshotHandler::removeSnapshot(int index)
m_currentIndex = -1;
else if (index < m_currentIndex)
--m_currentIndex;
//engine->quitDebugger();
//runTool->quitDebugger();
endResetModel();
}
@@ -252,18 +250,18 @@ void SnapshotHandler::removeAll()
endResetModel();
}
void SnapshotHandler::appendSnapshot(DebuggerEngine *engine)
void SnapshotHandler::appendSnapshot(DebuggerRunTool *runTool)
{
beginResetModel();
m_snapshots.append(engine);
m_snapshots.append(runTool);
m_currentIndex = size() - 1;
endResetModel();
}
void SnapshotHandler::removeSnapshot(DebuggerEngine *engine)
void SnapshotHandler::removeSnapshot(DebuggerRunTool *runTool)
{
// Could be that the run controls died before it was appended.
int index = m_snapshots.indexOf(engine);
int index = m_snapshots.indexOf(runTool);
if (index != -1)
removeSnapshot(index);
}
@@ -275,7 +273,7 @@ void SnapshotHandler::setCurrentIndex(int index)
endResetModel();
}
DebuggerEngine *SnapshotHandler::at(int i) const
DebuggerRunTool *SnapshotHandler::at(int i) const
{
return m_snapshots.at(i).data();
}

View File

@@ -29,9 +29,10 @@
#include <QPointer>
namespace Debugger {
namespace Internal {
class DebuggerEngine;
class DebuggerRunTool;
namespace Internal {
class SnapshotHandler : public QAbstractTableModel
{
@@ -45,11 +46,11 @@ public:
void removeAll();
QAbstractItemModel *model() { return this; }
int currentIndex() const { return m_currentIndex; }
void appendSnapshot(DebuggerEngine *engine);
void removeSnapshot(DebuggerEngine *engine);
void appendSnapshot(DebuggerRunTool *runTool);
void removeSnapshot(DebuggerRunTool *runTool);
void setCurrentIndex(int index);
int size() const { return m_snapshots.size(); }
DebuggerEngine *at(int index) const;
DebuggerRunTool *at(int index) const;
void createSnapshot(int index);
void activateSnapshot(int index);
@@ -64,7 +65,7 @@ private:
Qt::ItemFlags flags(const QModelIndex &index) const;
int m_currentIndex;
QList< QPointer<DebuggerEngine> > m_snapshots;
QList< QPointer<DebuggerRunTool> > m_snapshots;
};
} // namespace Internal

View File

@@ -29,7 +29,7 @@
#include "debuggeractions.h"
#include "debuggerinternalconstants.h"
#include "debuggercore.h"
#include "debuggerengine.h"
#include "debuggerruncontrol.h"
#include <utils/qtcassert.h>
#include <utils/savedaction.h>