diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h index bfddd639bf05288f294b85b20aed06c68683f5d3..c9e419f2cc6b3babc776d8da007e768b7fc204b3 100644 --- a/src/plugins/debugger/debuggerconstants.h +++ b/src/plugins/debugger/debuggerconstants.h @@ -180,26 +180,6 @@ enum ModelRoles RequestActivationRole, RequestContextMenuRole, - // Running - RequestExecContinueRole, - RequestExecInterruptRole, - RequestExecResetRole, - RequestExecStepRole, - RequestExecStepOutRole, - RequestExecNextRole, - RequestExecRunToLineRole, - RequestExecRunToFunctionRole, - RequestExecReturnFromFunctionRole, - RequestExecJumpToLineRole, - RequestExecWatchRole, - RequestExecSnapshotRole, - RequestExecFrameDownRole, - RequestExecFrameUpRole, - RequestExecDetachRole, - RequestExecExitRole, - RequestOperatedByInstructionTriggeredRole, - RequestExecuteCommandRole, - // Locals and Watchers LocalsINameRole, LocalsEditTypeRole, // A QVariant::type describing the item diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 252b6edec09506789967d64584099adecd83d4ec..55301c5c7ca4dfb9ac086e2ec77f17635e3981b2 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -50,7 +50,6 @@ #include <coreplugin/icore.h> #include <coreplugin/ifile.h> -#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/progressmanager/progressmanager.h> #include <coreplugin/progressmanager/futureprogress.h> @@ -180,30 +179,6 @@ const char *DebuggerEngine::stateName(int s) } -////////////////////////////////////////////////////////////////////// -// -// CommandHandler -// -////////////////////////////////////////////////////////////////////// - -class CommandHandler : public QStandardItemModel -{ -public: - explicit CommandHandler(DebuggerEngine *engine) : m_engine(engine) {} - bool setData(const QModelIndex &index, const QVariant &value, int role); - QAbstractItemModel *model() { return this; } - -private: - QPointer<DebuggerEngine> m_engine; -}; - -bool CommandHandler::setData(const QModelIndex &, const QVariant &value, int role) -{ - QTC_ASSERT(m_engine, qDebug() << value << role; return false); - m_engine->handleCommand(role, value); - return true; -} - ////////////////////////////////////////////////////////////////////// // // DebuggerEnginePrivate @@ -223,7 +198,6 @@ public: m_state(DebuggerNotReady), m_lastGoodState(DebuggerNotReady), m_targetState(DebuggerNotReady), - m_commandHandler(engine), m_modulesHandler(), m_registerHandler(), m_sourceFilesHandler(), @@ -309,7 +283,6 @@ public: qint64 m_inferiorPid; - CommandHandler m_commandHandler; ModulesHandler m_modulesHandler; RegisterHandler m_registerHandler; SourceFilesHandler m_sourceFilesHandler; @@ -389,105 +362,6 @@ void DebuggerEnginePrivate::slotEditBreakpoint() BreakWindow::editBreakpoint(breakPointData, ICore::instance()->mainWindow()); } -void DebuggerEnginePrivate::handleContextMenuRequest(const QVariant ¶meters) -{ - const QList<QVariant> list = parameters.toList(); - QTC_ASSERT(list.size() == 3, qDebug() << list; return); - TextEditor::ITextEditor *editor = - (TextEditor::ITextEditor *)(list.at(0).value<quint64>()); - const int lineNumber = list.at(1).toInt(); - QMenu *menu = (QMenu *)(list.at(2).value<quint64>()); - - BreakpointData *data = 0; - QString fileName; - quint64 address = 0; - - if (editor->property("DisassemblerView").toBool()) { - fileName = editor->file()->fileName(); - QString line = editor->contents() - .section('\n', lineNumber - 1, lineNumber - 1); - BreakpointData needle; - address = DisassemblerViewAgent::addressFromDisassemblyLine(line); - needle.address = address; - needle.bpLineNumber = -1; - data = m_engine->breakHandler()->findSimilarBreakpoint(&needle); - } else { - fileName = editor->file()->fileName(); - data = m_engine->breakHandler()->findBreakpoint(fileName, lineNumber); - } - - QList<QVariant> args; - args.append(fileName); - args.append(lineNumber); - args.append(address); - - if (data) { - // existing breakpoint - const QString number = QString::fromAscii(data->bpNumber); - QAction *act; - if (number.isEmpty()) - act = new QAction(tr("Remove Breakpoint"), menu); - else - act = new QAction(tr("Remove Breakpoint %1").arg(number), menu); - act->setData(args); - connect(act, SIGNAL(triggered()), - SLOT(breakpointSetRemoveMarginActionTriggered())); - menu->addAction(act); - - QAction *act2; - if (data->enabled) - if (number.isEmpty()) - act2 = new QAction(tr("Disable Breakpoint"), menu); - else - act2 = new QAction(tr("Disable Breakpoint %1").arg(number), menu); - else - if (number.isEmpty()) - act2 = new QAction(tr("Enable Breakpoint"), menu); - else - act2 = new QAction(tr("Enable Breakpoint %1").arg(number), menu); - act2->setData(args); - connect(act2, SIGNAL(triggered()), - this, SLOT(breakpointEnableDisableMarginActionTriggered())); - menu->addAction(act2); - QAction *editAction; - if (number.isEmpty()) - editAction = new QAction(tr("Edit Breakpoint..."), menu); - else - editAction = new QAction(tr("Edit Breakpoint %1...").arg(number), menu); - connect(editAction, SIGNAL(triggered()), SLOT(slotEditBreakpoint())); - editAction->setData(qVariantFromValue(data)); - menu->addAction(editAction); - } else { - // non-existing - const QString text = address ? - tr("Set Breakpoint at 0x%1").arg(address, 0, 16) : - tr("Set Breakpoint at line %1").arg(lineNumber); - QAction *act = new QAction(text, menu); - act->setData(args); - connect(act, SIGNAL(triggered()), - SLOT(breakpointSetRemoveMarginActionTriggered())); - menu->addAction(act); - } - // Run to, jump to line below in stopped state. - if (state() == InferiorStopOk) { - menu->addSeparator(); - const QString runText = DebuggerEngine::tr("Run to Line %1"). - arg(lineNumber); - QAction *runToLineAction = new QAction(runText, menu); - runToLineAction->setData(args); - connect(runToLineAction, SIGNAL(triggered()), this, SLOT(slotRunToLine())); - menu->addAction(runToLineAction); - if (m_engine->debuggerCapabilities() & JumpToLineCapability) { - const QString jumpText = DebuggerEngine::tr("Jump to Line %1"). - arg(lineNumber); - QAction *jumpToLineAction = new QAction(jumpText, menu); - menu->addAction(runToLineAction); - jumpToLineAction->setData(args); - connect(jumpToLineAction, SIGNAL(triggered()), this, SLOT(slotJumpToLine())); - menu->addAction(jumpToLineAction); - } - } -} ////////////////////////////////////////////////////////////////////// // @@ -517,92 +391,6 @@ void DebuggerEngine::removeTooltip() hideDebuggerToolTip(); } -void DebuggerEngine::handleCommand(int role, const QVariant &value) -{ - removeTooltip(); - - switch (role) { - case RequestExecDetachRole: - detachDebugger(); - break; - - case RequestExecContinueRole: - continueInferior(); - break; - - case RequestExecInterruptRole: - requestInterruptInferior(); - break; - - case RequestExecResetRole: - notifyEngineIll(); // FIXME: check - break; - - case RequestExecStepRole: - executeStepX(); - break; - - case RequestExecStepOutRole: - executeStepOutX(); - break; - - case RequestExecNextRole: - executeStepNextX(); - break; - - case RequestExecRunToLineRole: - executeRunToLine(); - break; - - case RequestExecRunToFunctionRole: - executeRunToFunction(); - break; - - case RequestExecReturnFromFunctionRole: - executeReturnX(); - break; - - case RequestExecJumpToLineRole: - executeJumpToLine(); - break; - - case RequestExecWatchRole: - addToWatchWindow(); - break; - - case RequestExecExitRole: - d->queueShutdownInferior(); - break; - - case RequestActivationRole: - setActive(value.toBool()); - break; - - case RequestExecFrameDownRole: - frameDown(); - break; - - case RequestExecFrameUpRole: - frameUp(); - break; - - case RequestOperatedByInstructionTriggeredRole: - gotoLocation(stackHandler()->currentFrame(), true); - break; - - case RequestExecuteCommandRole: - executeDebuggerCommand(value.toString()); - break; - - case RequestContextMenuRole: { - QList<QVariant> list = value.toList(); - QTC_ASSERT(list.size() == 3, break); - d->handleContextMenuRequest(list); - break; - } - } -} - void DebuggerEngine::showModuleSymbols (const QString &moduleName, const Symbols &symbols) { @@ -734,14 +522,6 @@ QAbstractItemModel *DebuggerEngine::sourceFilesModel() const return model; } -QAbstractItemModel *DebuggerEngine::commandModel() const -{ - QAbstractItemModel *model = d->m_commandHandler.model(); - if (model->objectName().isEmpty()) // Make debugging easier. - model->setObjectName(objectName() + QLatin1String("CommandModel")); - return model; -} - void DebuggerEngine::fetchMemory(MemoryViewAgent *, QObject *, quint64 addr, quint64 length) { @@ -845,35 +625,6 @@ void DebuggerEngine::gotoLocation(const StackFrame &frame, bool setMarker) } } -void DebuggerEngine::executeStepX() -{ - resetLocation(); - if (theDebuggerBoolSetting(OperateByInstruction)) - executeStepI(); - else - executeStep(); -} - -void DebuggerEngine::executeStepOutX() -{ - resetLocation(); - executeStepOut(); -} - -void DebuggerEngine::executeStepNextX() -{ - resetLocation(); - if (theDebuggerBoolSetting(OperateByInstruction)) - executeNextI(); - else - executeNext(); -} - -void DebuggerEngine::executeReturnX() -{ - resetLocation(); - executeReturn(); -} void DebuggerEngine::executeRunToLine() { @@ -925,40 +676,11 @@ void DebuggerEngine::executeJumpToLine() executeJumpToLine(fileName, lineNumber); } -void DebuggerEngine::addToWatchWindow() -{ - // Requires a selection, but that's the only case we want anyway. - EditorManager *editorManager = EditorManager::instance(); - if (!editorManager) - return; - IEditor *editor = editorManager->currentEditor(); - if (!editor) - return; - ITextEditor *textEditor = qobject_cast<ITextEditor*>(editor); - if (!textEditor) - return; - QTextCursor tc; - QPlainTextEdit *ptEdit = qobject_cast<QPlainTextEdit*>(editor->widget()); - if (ptEdit) - tc = ptEdit->textCursor(); - QString exp; - if (tc.hasSelection()) { - exp = tc.selectedText(); - } else { - int line, column; - exp = cppExpressionAt(textEditor, tc.position(), &line, &column); - } - if (exp.isEmpty()) - return; - watchHandler()->watchExpression(exp); -} - // Called from RunControl. void DebuggerEngine::handleStartFailed() { showMessage("HANDLE RUNCONTROL START FAILED"); d->m_runControl = 0; - d->m_progress.setProgressValue(900); d->m_progress.reportCanceled(); d->m_progress.reportFinished(); @@ -973,7 +695,6 @@ void DebuggerEngine::handleFinished() stackHandler()->removeAll(); threadsHandler()->removeAll(); watchHandler()->cleanup(); - d->m_progress.setProgressValue(1000); d->m_progress.reportFinished(); } @@ -1586,11 +1307,13 @@ DebuggerRunControl *DebuggerEngine::runControl() const return d->m_runControl; } -void DebuggerEngine::setToolTipExpression(const QPoint &, TextEditor::ITextEditor *, int) +void DebuggerEngine::setToolTipExpression + (const QPoint &, TextEditor::ITextEditor *, int) { } -void DebuggerEngine::updateWatchData(const Internal::WatchData &, const Internal::WatchUpdateFlags &) +void DebuggerEngine::updateWatchData + (const Internal::WatchData &, const Internal::WatchUpdateFlags &) { } @@ -1678,7 +1401,8 @@ void DebuggerEngine::selectThread(int) { } -void DebuggerEngine::assignValueInDebugger(const Internal::WatchData *, const QString &, const QVariant &) +void DebuggerEngine::assignValueInDebugger + (const Internal::WatchData *, const QString &, const QVariant &) { } @@ -1686,6 +1410,11 @@ void DebuggerEngine::detachDebugger() { } +void DebuggerEngine::exitInferior() +{ + d->queueShutdownInferior(); +} + void DebuggerEngine::executeStep() { } diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index 7364abe1b185472d91fd2c9ed47e49032f1def49..6c6b93133ec5af7b6877a7ecc38fa772cacb68d4 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -55,9 +55,10 @@ class IOptionsPage; namespace Debugger { -class DebuggerRunControl; -class DebuggerPlugin; class DebuggerEnginePrivate; +class DebuggerPlugin; +class DebuggerPluginPrivate; +class DebuggerRunControl; class QmlCppEngine; class DEBUGGER_EXPORT DebuggerStartParameters @@ -136,8 +137,10 @@ struct WatchUpdateFlags WatchUpdateFlags() : tryIncremental(false) {} bool tryIncremental; }; + } // namespace Internal + // FIXME: DEBUGGER_EXPORT? class DEBUGGER_EXPORT DebuggerEngine : public QObject { @@ -148,7 +151,7 @@ public: virtual ~DebuggerEngine(); virtual void setToolTipExpression(const QPoint & mousePos, - TextEditor::ITextEditor * editor, int cursorPos); + TextEditor::ITextEditor *editor, int cursorPos); void initializeFromTemplate(DebuggerEngine *other); virtual void updateWatchData(const Internal::WatchData &data, @@ -185,7 +188,8 @@ public: virtual bool acceptsBreakpoint(const Internal::BreakpointData *); virtual void selectThread(int index); - virtual void assignValueInDebugger(const Internal::WatchData *w, const QString &expr, const QVariant &value); + virtual void assignValueInDebugger(const Internal::WatchData *data, + const QString &expr, const QVariant &value); virtual void removeTooltip(); // Convenience @@ -193,6 +197,7 @@ public: (int icon, const QString &title, const QString &text, int buttons = 0); protected: + friend class DebuggerPluginPrivate; virtual void detachDebugger(); virtual void executeStep(); virtual void executeStepOut() ; @@ -203,11 +208,11 @@ protected: virtual void continueInferior(); virtual void interruptInferior(); + virtual void exitInferior(); virtual void requestInterruptInferior(); virtual void executeRunToLine(const QString &fileName, int lineNumber); - virtual void executeRunToFunction(const QString &functionName); virtual void executeJumpToLine(const QString &fileName, int lineNumber); virtual void executeDebuggerCommand(const QString &command); @@ -228,7 +233,6 @@ public: Internal::SourceFilesHandler *sourceFilesHandler() const; Internal::BreakHandler *breakHandler() const; - virtual QAbstractItemModel *commandModel() const; virtual QAbstractItemModel *modulesModel() const; virtual QAbstractItemModel *registerModel() const; virtual QAbstractItemModel *stackModel() const; diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index dffc00cd5445cdfc320085dda70c60eed13bf1d1..771b0e5d06d63a888b5e2f71c72c4e6e3250ad48 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -48,11 +48,13 @@ #include "moduleswindow.h" #include "registerwindow.h" #include "snapshotwindow.h" +#include "stackhandler.h" #include "stackwindow.h" #include "sourcefileswindow.h" #include "threadswindow.h" #include "watchhandler.h" #include "watchwindow.h" +#include "watchutils.h" #include "snapshothandler.h" #include "threadshandler.h" @@ -105,6 +107,7 @@ #include <QtGui/QComboBox> #include <QtGui/QDockWidget> #include <QtGui/QFileDialog> +#include <QtGui/QMenu> #include <QtGui/QMessageBox> #include <QtGui/QToolButton> @@ -227,15 +230,18 @@ // EngineShutdownRequested + // + + // (calls *Engine->shutdownEngine()) <+-+-+-+-+-+-+-+-+-+-+-+-+-+' -// | | -// | | -// {notify- {notify- +// | | +// | | +// {notify- {notify- // Engine- Engine- -// ShutdownOk} ShutdownFailed} -// + + -// EngineShutdownOk EngineShutdownFailed +// ShutdownOk} ShutdownFailed} +// + + +// EngineShutdownOk EngineShutdownFailed // * * // DebuggerFinished +// + + /* Here is a matching graph as a GraphViz graph. View it using * \code grep "^sg1:" debuggerplugin.cpp | cut -c5- | dot -osg1.ps -Tps && gv sg1.ps @@ -794,14 +800,6 @@ static bool isDebuggable(Core::IEditor *editor) return true; } -static TextEditor::ITextEditor *currentTextEditor() -{ - EditorManager *editorManager = EditorManager::instance(); - if (!editorManager) - return 0; - Core::IEditor *editor = editorManager->currentEditor(); - return qobject_cast<ITextEditor*>(editor); -} /////////////////////////////////////////////////////////////////////// // @@ -851,7 +849,6 @@ public: explicit DebuggerPluginPrivate(DebuggerPlugin *plugin); bool initialize(const QStringList &arguments, QString *errorMessage); - void notifyCurrentEngine(int role, const QVariant &value = QVariant()); void connectEngine(DebuggerEngine *engine, bool notify = true); void disconnectEngine() { connectEngine(0); } DebuggerEngine *currentEngine() const { return m_currentEngine; } @@ -900,7 +897,6 @@ public slots: } } - void onAction(); void setSimpleDockWidgetArrangement(Debugger::DebuggerLanguages activeLanguages); void editorOpened(Core::IEditor *editor); @@ -968,6 +964,111 @@ public slots: void scriptExpressionEntered(const QString &expression); void coreShutdown(); +public slots: + void handleExecDetach() { currentEngine()->detachDebugger(); } + void handleExecContinue() { currentEngine()->continueInferior(); } + void handleExecInterrupt() { currentEngine()->requestInterruptInferior(); } + void handleExecReset() { currentEngine()->notifyEngineIll(); } // FIXME: Check. + + void handleExecStep() + { + resetLocation(); + if (theDebuggerBoolSetting(OperateByInstruction)) + currentEngine()->executeStepI(); + else + currentEngine()->executeStep(); + } + + void handleExecNext() + { + resetLocation(); + if (theDebuggerBoolSetting(OperateByInstruction)) + currentEngine()->executeNextI(); + else + currentEngine()->executeNext(); + } + + void handleExecStepOut() { resetLocation(); currentEngine()->executeStepOut(); } + void handleExecReturn() { resetLocation(); currentEngine()->executeReturn(); } + + void handleExecJumpToLine() + { + //removeTooltip(); + resetLocation(); + currentEngine()->executeJumpToLine(); // FIXME: move code from engine here. + } + + void handleExecRunToLine() + { + //removeTooltip(); + resetLocation(); + currentEngine()->executeRunToLine(); // FIXME: move code from engine here. + } + + void handleExecRunToFunction() + { + resetLocation(); + currentEngine()->executeRunToFunction(); // FIXME: move code from engine here. + } + + void handleAddToWatchWindow() + { + // Requires a selection, but that's the only case we want anyway. + EditorManager *editorManager = EditorManager::instance(); + if (!editorManager) + return; + IEditor *editor = editorManager->currentEditor(); + if (!editor) + return; + ITextEditor *textEditor = qobject_cast<ITextEditor*>(editor); + if (!textEditor) + return; + QTextCursor tc; + QPlainTextEdit *ptEdit = qobject_cast<QPlainTextEdit*>(editor->widget()); + if (ptEdit) + tc = ptEdit->textCursor(); + QString exp; + if (tc.hasSelection()) { + exp = tc.selectedText(); + } else { + int line, column; + exp = cppExpressionAt(textEditor, tc.position(), &line, &column); + } + if (exp.isEmpty()) + return; + currentEngine()->watchHandler()->watchExpression(exp); + } + + void handleExecExit() + { + currentEngine()->exitInferior(); + } + + void handleFrameDown() + { + currentEngine()->frameDown(); + } + + void handleFrameUp() + { + currentEngine()->frameUp(); + } + + void handleOperateByInstructionTriggered() + { + currentEngine()->gotoLocation( + currentEngine()->stackHandler()->currentFrame(), true); + } + + void resetLocation() + { + // FIXME: code should be moved here. + currentEngine()->resetLocation(); + //d->m_disassemblerViewAgent.resetLocation(); + //d->m_stackHandler.setCurrentIndex(-1); + //plugin()->resetLocation(); + } + public: DebuggerState m_state; DebuggerUISwitcher *m_uiSwitcher; @@ -1022,7 +1123,6 @@ public: QTreeView *m_returnWindow; QTreeView *m_localsWindow; QTreeView *m_watchersWindow; - QTreeView *m_commandWindow; QAbstractItemView *m_registerWindow; QAbstractItemView *m_modulesWindow; QAbstractItemView *m_snapshotWindow; @@ -1159,7 +1259,6 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er m_localsWindow->setObjectName(QLatin1String("CppDebugLocals")); m_watchersWindow = new WatchWindow(WatchWindow::WatchersType); m_watchersWindow->setObjectName(QLatin1String("CppDebugWatchers")); - m_commandWindow = new QTreeView; m_scriptConsoleWindow = new ScriptConsole; m_scriptConsoleWindow->setWindowTitle(tr("QML Script Console")); m_scriptConsoleWindow->setObjectName(QLatin1String("QMLScriptConsole")); @@ -1177,114 +1276,93 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er // Watchers connect(m_localsWindow->header(), SIGNAL(sectionResized(int,int,int)), - this, SLOT(updateWatchersHeader(int,int,int)), Qt::QueuedConnection); + SLOT(updateWatchersHeader(int,int,int)), Qt::QueuedConnection); + + QAction *act = 0; - m_actions.continueAction = new QAction(tr("Continue"), this); - m_actions.continueAction->setProperty(Role, RequestExecContinueRole); - m_actions.continueAction->setIcon(m_continueIcon); + act = m_actions.continueAction = new QAction(tr("Continue"), this); + act->setIcon(m_continueIcon); + connect(act, SIGNAL(triggered()), SLOT(handleExecContinue())); - m_actions.stopAction = new QAction(tr("Stop Debugger"), this); - m_actions.stopAction->setProperty(Role, RequestExecExitRole); - m_actions.stopAction->setIcon(m_stopIcon); + act = m_actions.stopAction = new QAction(tr("Stop Debugger"), this); + act->setIcon(m_stopIcon); + connect(act, SIGNAL(triggered()), SLOT(handleExecExit())); - m_actions.interruptAction = new QAction(tr("Interrupt"), this); - m_actions.interruptAction->setIcon(m_interruptIcon); - m_actions.interruptAction->setProperty(Role, RequestExecInterruptRole); + act = m_actions.interruptAction = new QAction(tr("Interrupt"), this); + act->setIcon(m_interruptIcon); + connect(act, SIGNAL(triggered()), SLOT(handleExecInterrupt())); - m_actions.undisturbableAction = new QAction(tr("Debugger is Busy"), this); // A "disabled pause" seems to be a good choice. - m_actions.undisturbableAction->setIcon(m_interruptIcon); - m_actions.undisturbableAction->setEnabled(false); + act = m_actions.undisturbableAction = new QAction(tr("Debugger is Busy"), this); + act->setIcon(m_interruptIcon); + act->setEnabled(false); - m_actions.resetAction = new QAction(tr("Abort Debugging"), this); - m_actions.resetAction->setProperty(Role, RequestExecResetRole); - m_actions.resetAction->setToolTip(tr("Aborts debugging and " + act = m_actions.resetAction = new QAction(tr("Abort Debugging"), this); + act->setToolTip(tr("Aborts debugging and " "resets the debugger to the initial state.")); + connect(act, SIGNAL(triggered()), SLOT(handleExecReset())); - m_actions.nextAction = new QAction(tr("Step Over"), this); - m_actions.nextAction->setProperty(Role, RequestExecNextRole); - m_actions.nextAction->setIcon( - QIcon(__(":/debugger/images/debugger_stepover_small.png"))); + act = m_actions.nextAction = new QAction(tr("Step Over"), this); + act->setIcon(QIcon(__(":/debugger/images/debugger_stepover_small.png"))); + connect(act, SIGNAL(triggered()), SLOT(handleExecNext())); - m_actions.stepAction = new QAction(tr("Step Into"), this); - m_actions.stepAction->setProperty(Role, RequestExecStepRole); - m_actions.stepAction->setIcon( - QIcon(__(":/debugger/images/debugger_stepinto_small.png"))); + act = m_actions.stepAction = new QAction(tr("Step Into"), this); + act->setIcon(QIcon(__(":/debugger/images/debugger_stepinto_small.png"))); + connect(act, SIGNAL(triggered()), SLOT(handleExecStep())); - m_actions.stepOutAction = new QAction(tr("Step Out"), this); - m_actions.stepOutAction->setProperty(Role, RequestExecStepOutRole); - m_actions.stepOutAction->setIcon( - QIcon(__(":/debugger/images/debugger_stepout_small.png"))); + act = m_actions.stepOutAction = new QAction(tr("Step Out"), this); + act->setIcon(QIcon(__(":/debugger/images/debugger_stepout_small.png"))); + connect(act, SIGNAL(triggered()), SLOT(handleExecStepOut())); - m_actions.runToLineAction = new QAction(tr("Run to Line"), this); - m_actions.runToLineAction->setProperty(Role, RequestExecRunToLineRole); + act = m_actions.runToLineAction = new QAction(tr("Run to Line"), this); + connect(act, SIGNAL(triggered()), SLOT(handleExecRunToLine())); - m_actions.runToFunctionAction = + act = m_actions.runToFunctionAction = new QAction(tr("Run to Outermost Function"), this); - m_actions.runToFunctionAction->setProperty(Role, RequestExecRunToFunctionRole); + connect(act, SIGNAL(triggered()), SLOT(handleExecRunToFunction())); - m_actions.returnFromFunctionAction = + act = m_actions.returnFromFunctionAction = new QAction(tr("Immediately Return From Inner Function"), this); - m_actions.returnFromFunctionAction->setProperty(Role, RequestExecReturnFromFunctionRole); + connect(act, SIGNAL(triggered()), SLOT(handleExecReturn())); - m_actions.jumpToLineAction = new QAction(tr("Jump to Line"), this); - m_actions.jumpToLineAction->setProperty(Role, RequestExecJumpToLineRole); + act = m_actions.jumpToLineAction = new QAction(tr("Jump to Line"), this); + connect(act, SIGNAL(triggered()), SLOT(handleExecJumpToLine())); - m_actions.breakAction = new QAction(tr("Toggle Breakpoint"), this); + act = m_actions.breakAction = new QAction(tr("Toggle Breakpoint"), this); - m_actions.watchAction1 = new QAction(tr("Add to Watch Window"), this); - m_actions.watchAction1->setProperty(Role, RequestExecWatchRole); - m_actions.watchAction2 = new QAction(tr("Add to Watch Window"), this); - m_actions.watchAction2->setProperty(Role, RequestExecWatchRole); + act = m_actions.watchAction1 = new QAction(tr("Add to Watch Window"), this); + connect(act, SIGNAL(triggered()), SLOT(handleAddToWatchWindow())); + + act = m_actions.watchAction2 = new QAction(tr("Add to Watch Window"), this); + connect(act, SIGNAL(triggered()), SLOT(handleAddToWatchWindow())); //m_actions.snapshotAction = new QAction(tr("Create Snapshot"), this); //m_actions.snapshotAction->setProperty(Role, RequestCreateSnapshotRole); //m_actions.snapshotAction->setIcon( // QIcon(__(":/debugger/images/debugger_snapshot_small.png"))); - m_actions.reverseDirectionAction = + act = m_actions.reverseDirectionAction = new QAction(tr("Reverse Direction"), this); - m_actions.reverseDirectionAction->setCheckable(true); - m_actions.reverseDirectionAction->setChecked(false); - m_actions.reverseDirectionAction->setIcon( - QIcon(__(":/debugger/images/debugger_reversemode_16.png"))); - m_actions.reverseDirectionAction->setIconVisibleInMenu(false); - - m_actions.frameDownAction = - new QAction(tr("Move to Called Frame"), this); - m_actions.frameDownAction->setProperty(Role, RequestExecFrameDownRole); - m_actions.frameUpAction = - new QAction(tr("Move to Calling Frame"), this); - m_actions.frameUpAction->setProperty(Role, RequestExecFrameUpRole); - - m_actions.reverseDirectionAction->setCheckable(false); - theDebuggerAction(OperateByInstruction)-> - setProperty(Role, RequestOperatedByInstructionTriggeredRole); - - connect(m_actions.continueAction, SIGNAL(triggered()), SLOT(onAction())); - connect(m_actions.nextAction, SIGNAL(triggered()), SLOT(onAction())); - connect(m_actions.stepAction, SIGNAL(triggered()), SLOT(onAction())); - connect(m_actions.stepOutAction, SIGNAL(triggered()), SLOT(onAction())); - connect(m_actions.runToLineAction, SIGNAL(triggered()), SLOT(onAction())); - connect(m_actions.runToFunctionAction, SIGNAL(triggered()), SLOT(onAction())); - connect(m_actions.jumpToLineAction, SIGNAL(triggered()), SLOT(onAction())); - connect(m_actions.returnFromFunctionAction, SIGNAL(triggered()), SLOT(onAction())); - connect(m_actions.watchAction1, SIGNAL(triggered()), SLOT(onAction())); - connect(m_actions.watchAction2, SIGNAL(triggered()), SLOT(onAction())); - //connect(m_actions.snapshotAction, SIGNAL(triggered()), SLOT(onAction())); - connect(m_actions.frameDownAction, SIGNAL(triggered()), SLOT(onAction())); - connect(m_actions.frameUpAction, SIGNAL(triggered()), SLOT(onAction())); - connect(m_actions.stopAction, SIGNAL(triggered()), SLOT(onAction())); - connect(m_actions.interruptAction, SIGNAL(triggered()), SLOT(onAction())); - connect(m_actions.resetAction, SIGNAL(triggered()), SLOT(onAction())); + act->setCheckable(true); + act->setChecked(false); + act->setCheckable(false); + act->setIcon(QIcon(__(":/debugger/images/debugger_reversemode_16.png"))); + act->setIconVisibleInMenu(false); + + act = m_actions.frameDownAction = new QAction(tr("Move to Called Frame"), this); + connect(act, SIGNAL(triggered()), SLOT(handleFrameDown())); + + act = m_actions.frameUpAction = new QAction(tr("Move to Calling Frame"), this); + connect(act, SIGNAL(triggered()), SLOT(handleFrameUp())); + + connect(theDebuggerAction(OperateByInstruction), SIGNAL(triggered()), + SLOT(handleOperateByInstructionTriggered())); + connect(&m_statusTimer, SIGNAL(timeout()), SLOT(clearStatusMessage())); connect(theDebuggerAction(ExecuteCommand), SIGNAL(triggered()), SLOT(executeDebuggerCommand())); - connect(theDebuggerAction(OperateByInstruction), SIGNAL(triggered()), - SLOT(onAction())); - m_plugin->readSettings(); // Cpp/Qml ui setup @@ -1397,8 +1475,8 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er m_detachAction = new QAction(this); m_detachAction->setText(tr("Detach Debugger")); - m_detachAction->setProperty(Role, RequestExecDetachRole); - connect(m_detachAction, SIGNAL(triggered()), SLOT(onAction())); + connect(m_detachAction, SIGNAL(triggered()), + SLOT(handleExecDetach())); Core::Command *cmd = 0; @@ -1723,14 +1801,6 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project) core->updateAdditionalContexts(m_anyContext, Context()); } -void DebuggerPluginPrivate::onAction() -{ - QAction *act = qobject_cast<QAction *>(sender()); - QTC_ASSERT(act, return); - const int role = act->property(Role).toInt(); - notifyCurrentEngine(role); -} - void DebuggerPluginPrivate::languagesChanged(const DebuggerLanguages &languages) { const bool debuggerIsCPP = (languages & CppLanguage); @@ -1778,13 +1848,6 @@ void DebuggerPluginPrivate::startExternalApplication() startDebugger(rc); } -void DebuggerPluginPrivate::notifyCurrentEngine(int role, const QVariant &value) -{ - QTC_ASSERT(m_commandWindow, return); - if (m_commandWindow->model()) - m_commandWindow->model()->setData(QModelIndex(), value, role); -} - void DebuggerPluginPrivate::attachExternalApplication() { AttachExternalDialog dlg(mainWindow()); @@ -2007,11 +2070,95 @@ void DebuggerPluginPrivate::requestContextMenu(TextEditor::ITextEditor *editor, if (!isDebuggable(editor)) return; - QList<QVariant> list; - list.append(quint64(editor)); - list.append(lineNumber); - list.append(quint64(menu)); - notifyCurrentEngine(RequestContextMenuRole, list); + BreakpointData *data = 0; + QString fileName; + quint64 address = 0; + + if (editor->property("DisassemblerView").toBool()) { + fileName = editor->file()->fileName(); + QString line = editor->contents() + .section('\n', lineNumber - 1, lineNumber - 1); + BreakpointData needle; + address = DisassemblerViewAgent::addressFromDisassemblyLine(line); + needle.address = address; + needle.bpLineNumber = -1; + data = m_breakHandler->findSimilarBreakpoint(&needle); + } else { + fileName = editor->file()->fileName(); + data = m_breakHandler->findBreakpoint(fileName, lineNumber); + } + + QList<QVariant> args; + args.append(fileName); + args.append(lineNumber); + args.append(address); + + if (data) { + // existing breakpoint + const QString number = QString::fromAscii(data->bpNumber); + QAction *act; + if (number.isEmpty()) + act = new QAction(tr("Remove Breakpoint"), menu); + else + act = new QAction(tr("Remove Breakpoint %1").arg(number), menu); + act->setData(args); + connect(act, SIGNAL(triggered()), + SLOT(breakpointSetRemoveMarginActionTriggered())); + menu->addAction(act); + + QAction *act2; + if (data->enabled) + if (number.isEmpty()) + act2 = new QAction(tr("Disable Breakpoint"), menu); + else + act2 = new QAction(tr("Disable Breakpoint %1").arg(number), menu); + else + if (number.isEmpty()) + act2 = new QAction(tr("Enable Breakpoint"), menu); + else + act2 = new QAction(tr("Enable Breakpoint %1").arg(number), menu); + act2->setData(args); + connect(act2, SIGNAL(triggered()), + this, SLOT(breakpointEnableDisableMarginActionTriggered())); + menu->addAction(act2); + QAction *editAction; + if (number.isEmpty()) + editAction = new QAction(tr("Edit Breakpoint..."), menu); + else + editAction = new QAction(tr("Edit Breakpoint %1...").arg(number), menu); + connect(editAction, SIGNAL(triggered()), SLOT(slotEditBreakpoint())); + editAction->setData(qVariantFromValue(data)); + menu->addAction(editAction); + } else { + // non-existing + const QString text = address ? + tr("Set Breakpoint at 0x%1").arg(address, 0, 16) : + tr("Set Breakpoint at line %1").arg(lineNumber); + QAction *act = new QAction(text, menu); + act->setData(args); + connect(act, SIGNAL(triggered()), + SLOT(breakpointSetRemoveMarginActionTriggered())); + menu->addAction(act); + } + // Run to, jump to line below in stopped state. + if (state() == InferiorStopOk) { + menu->addSeparator(); + const QString runText = + DebuggerEngine::tr("Run to Line %1").arg(lineNumber); + QAction *runToLineAction = new QAction(runText, menu); + runToLineAction->setData(args); + connect(runToLineAction, SIGNAL(triggered()), SLOT(slotRunToLine())); + menu->addAction(runToLineAction); + if (currentEngine()->debuggerCapabilities() & JumpToLineCapability) { + const QString jumpText = + DebuggerEngine::tr("Jump to Line %1").arg(lineNumber); + QAction *jumpToLineAction = new QAction(jumpText, menu); + menu->addAction(runToLineAction); + jumpToLineAction->setData(args); + connect(jumpToLineAction, SIGNAL(triggered()), SLOT(slotJumpToLine())); + menu->addAction(jumpToLineAction); + } + } } void DebuggerPluginPrivate::toggleBreakpoint() @@ -2101,9 +2248,8 @@ void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine, bool notify) m_currentEngine = engine; if (notify) - notifyCurrentEngine(RequestActivationRole, false); + engine->setActive(false); - m_commandWindow->setModel(engine->commandModel()); m_localsWindow->setModel(engine->localsModel()); m_modulesWindow->setModel(engine->modulesModel()); m_registerWindow->setModel(engine->registerModel()); @@ -2116,7 +2262,7 @@ void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine, bool notify) m_watchersWindow->setModel(engine->watchersModel()); if (notify) - notifyCurrentEngine(RequestActivationRole, true); + engine->setActive(true); } static void changeFontSize(QWidget *widget, qreal size) @@ -2542,7 +2688,7 @@ void DebuggerPluginPrivate::aboutToSaveSession() void DebuggerPluginPrivate::executeDebuggerCommand() { if (QAction *action = qobject_cast<QAction *>(sender())) - notifyCurrentEngine(RequestExecuteCommandRole, action->data().toString()); + currentEngine()->executeDebuggerCommand(action->data().toString()); } void DebuggerPluginPrivate::showStatusMessage(const QString &msg0, int timeout) @@ -2562,7 +2708,7 @@ void DebuggerPluginPrivate::showStatusMessage(const QString &msg0, int timeout) void DebuggerPluginPrivate::scriptExpressionEntered(const QString &expression) { - notifyCurrentEngine(RequestExecuteCommandRole, expression); + currentEngine()->executeDebuggerCommand(expression); } void DebuggerPluginPrivate::openMemoryEditor() @@ -2610,9 +2756,6 @@ DebuggerPlugin::~DebuggerPlugin() delete d->m_uiSwitcher; d->m_uiSwitcher = 0; - delete d->m_commandWindow; - d->m_commandWindow = 0; - delete d->m_snapshotHandler; d->m_snapshotHandler = 0; diff --git a/src/plugins/debugger/qml/qmlcppengine.cpp b/src/plugins/debugger/qml/qmlcppengine.cpp index 320e2a92bd219f64526734bae244e53b00200e2a..20b3901ea7f0191f736f2dabf8683e542f8283dd 100644 --- a/src/plugins/debugger/qml/qmlcppengine.cpp +++ b/src/plugins/debugger/qml/qmlcppengine.cpp @@ -254,11 +254,6 @@ void QmlCppEngine::assignValueInDebugger(const Internal::WatchData *w, const QSt d->m_activeEngine->assignValueInDebugger(w, expr, value); } -QAbstractItemModel *QmlCppEngine::commandModel() const -{ - return d->m_activeEngine->commandModel(); -} - QAbstractItemModel *QmlCppEngine::modulesModel() const { return d->m_cppEngine->modulesModel(); diff --git a/src/plugins/debugger/qml/qmlcppengine.h b/src/plugins/debugger/qml/qmlcppengine.h index 1245babb33f2fc204694187d94c96c41e91400da..a79593b119e647a6368447a8974788d70404f5df 100644 --- a/src/plugins/debugger/qml/qmlcppengine.h +++ b/src/plugins/debugger/qml/qmlcppengine.h @@ -59,7 +59,6 @@ public: virtual void assignValueInDebugger(const Internal::WatchData *w, const QString &expr, const QVariant &value); - QAbstractItemModel *commandModel() const; QAbstractItemModel *modulesModel() const; QAbstractItemModel *registerModel() const; QAbstractItemModel *stackModel() const; diff --git a/src/plugins/debugger/snapshotwindow.cpp b/src/plugins/debugger/snapshotwindow.cpp index 7fa7092117d2312edf9e8a47809da17bfdc6d8ac..5c86013f2ba689ac873ef93db9866901c18ddab9 100644 --- a/src/plugins/debugger/snapshotwindow.cpp +++ b/src/plugins/debugger/snapshotwindow.cpp @@ -83,7 +83,7 @@ SnapshotWindow::SnapshotWindow(SnapshotHandler *handler) } void SnapshotWindow::rowActivated(const QModelIndex &index) -{ +{ m_snapshotHandler->activateSnapshot(index.row()); }