debugger: work on action handling

This commit is contained in:
hjk
2010-06-22 17:18:29 +02:00
parent 0b55b71633
commit 817dbabd79
4 changed files with 73 additions and 61 deletions

View File

@@ -213,6 +213,7 @@ enum ModelRoles
LocalsPointerValueRole, // Pointer value (address) as quint64 LocalsPointerValueRole, // Pointer value (address) as quint64
LocalsIsWatchpointAtAddressRole, LocalsIsWatchpointAtAddressRole,
LocalsIsWatchpointAtPointerValueRole, LocalsIsWatchpointAtPointerValueRole,
RequestWatchPointRole,
RequestToggleWatchRole, RequestToggleWatchRole,
RequestClearCppCodeModelSnapshotRole, RequestClearCppCodeModelSnapshotRole,
RequestAssignValueRole, RequestAssignValueRole,

View File

@@ -45,6 +45,9 @@
#include "threadshandler.h" #include "threadshandler.h"
#include "watchhandler.h" #include "watchhandler.h"
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
#include <projectexplorer/debugginghelper.h> #include <projectexplorer/debugginghelper.h>
#include <projectexplorer/environment.h> #include <projectexplorer/environment.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
@@ -55,11 +58,11 @@
#include <qt4projectmanager/qt4projectmanagerconstants.h> #include <qt4projectmanager/qt4projectmanagerconstants.h>
#include <texteditor/itexteditor.h>
#include <utils/savedaction.h> #include <utils/savedaction.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <coreplugin/icore.h>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
@@ -69,14 +72,19 @@
#include <QtGui/QStandardItemModel> #include <QtGui/QStandardItemModel>
#include <QtGui/QAction> #include <QtGui/QAction>
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
#include <QtGui/QPlainTextEdit>
#include <QtGui/QPushButton> #include <QtGui/QPushButton>
#include <QtGui/QTextBlock>
#include <QtGui/QTextCursor>
#include <QtGui/QTextDocument> #include <QtGui/QTextDocument>
#include <QtGui/QTreeWidget> #include <QtGui/QTreeWidget>
using namespace ProjectExplorer; using namespace Core;
using namespace Debugger; using namespace Debugger;
using namespace Debugger::Internal; using namespace Debugger::Internal;
using namespace ProjectExplorer;
using namespace TextEditor;
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
@@ -239,12 +247,10 @@ public:
DebuggerEngine::DebuggerEngine(const DebuggerStartParameters &startParameters) DebuggerEngine::DebuggerEngine(const DebuggerStartParameters &startParameters)
: d(new DebuggerEnginePrivate(this, startParameters)) : d(new DebuggerEnginePrivate(this, startParameters))
{ {
//loadSessionData();
} }
DebuggerEngine::~DebuggerEngine() DebuggerEngine::~DebuggerEngine()
{ {
//saveSessionData();
} }
void DebuggerEngine::showStatusMessage(const QString &msg, int timeout) const void DebuggerEngine::showStatusMessage(const QString &msg, int timeout) const
@@ -298,13 +304,11 @@ void DebuggerEngine::handleCommand(int role, const QVariant &value)
break; break;
case RequestExecRunToLineRole: case RequestExecRunToLineRole:
//executeRunToLine(); executeRunToLine();
QTC_ASSERT(false, /* FIXME ABC */);
break; break;
case RequestExecRunToFunctionRole: case RequestExecRunToFunctionRole:
//executeRunToFunction(); executeRunToFunction();
QTC_ASSERT(false, /* FIXME ABC */);
break; break;
case RequestExecReturnFromFunctionRole: case RequestExecReturnFromFunctionRole:
@@ -312,8 +316,7 @@ void DebuggerEngine::handleCommand(int role, const QVariant &value)
break; break;
case RequestExecJumpToLineRole: case RequestExecJumpToLineRole:
//executeJumpToLine(); executeJumpToLine();
QTC_ASSERT(false, /* FIXME ABC */);
break; break;
case RequestExecWatchRole: case RequestExecWatchRole:
@@ -344,6 +347,12 @@ void DebuggerEngine::handleCommand(int role, const QVariant &value)
case RequestExecuteCommandRole: case RequestExecuteCommandRole:
executeDebuggerCommand(value.toString()); executeDebuggerCommand(value.toString());
break; break;
case RequestWatchPointRole:
//if (QAction *action = qobject_cast<QAction *>(sender()))
// watchPoint(action->data().toPoint());
QTC_ASSERT(false, /* FIXME ABC */);
break;
} }
} }
@@ -523,7 +532,6 @@ void DebuggerEngine::startDebugger(DebuggerRunControl *runControl)
theDebuggerAction(OperateByInstruction) theDebuggerAction(OperateByInstruction)
->setEnabled(engineCapabilities & DisassemblerCapability); ->setEnabled(engineCapabilities & DisassemblerCapability);
//loadSessionData();
startDebugger(); startDebugger();
} }
@@ -611,29 +619,30 @@ void DebuggerEngine::executeReturnX()
executeReturn(); executeReturn();
} }
void DebuggerEngine::executeWatchPointX() static TextEditor::ITextEditor *currentTextEditor()
{ {
if (QAction *action = qobject_cast<QAction *>(sender())) EditorManager *editorManager = EditorManager::instance();
watchPoint(action->data().toPoint()); if (!editorManager)
return 0;
Core::IEditor *editor = editorManager->currentEditor();
return qobject_cast<ITextEditor*>(editor);
} }
/* void DebuggerEngine::executeRunToLine()
void DebuggerManager::executeRunToLine()
{ {
ITextEditor *textEditor = d->m_plugin->currentTextEditor(); ITextEditor *textEditor = currentTextEditor();
QTC_ASSERT(textEditor, return); QTC_ASSERT(textEditor, return);
QString fileName = textEditor->file()->fileName(); QString fileName = textEditor->file()->fileName();
if (fileName.isEmpty())
return;
int lineNumber = textEditor->currentLine(); int lineNumber = textEditor->currentLine();
if (d->m_engine && !fileName.isEmpty()) { resetLocation();
STATE_DEBUG(fileName << lineNumber); executeRunToLine(fileName, lineNumber);
resetLocation();
d->m_engine->executeRunToLine(fileName, lineNumber);
}
} }
void DebuggerManager::executeRunToFunction() void DebuggerEngine::executeRunToFunction()
{ {
ITextEditor *textEditor = d->m_plugin->currentTextEditor(); ITextEditor *textEditor = currentTextEditor();
QTC_ASSERT(textEditor, return); QTC_ASSERT(textEditor, return);
QString fileName = textEditor->file()->fileName(); QString fileName = textEditor->file()->fileName();
QPlainTextEdit *ed = qobject_cast<QPlainTextEdit*>(textEditor->widget()); QPlainTextEdit *ed = qobject_cast<QPlainTextEdit*>(textEditor->widget());
@@ -657,26 +666,23 @@ void DebuggerManager::executeRunToFunction()
} }
} }
} }
STATE_DEBUG(functionName);
if (d->m_engine && !functionName.isEmpty()) { if (functionName.isEmpty())
resetLocation(); return;
d->m_engine->executeRunToFunction(functionName); resetLocation();
} executeRunToFunction(functionName);
} }
void DebuggerManager::executeJumpToLine() void DebuggerEngine::executeJumpToLine()
{ {
ITextEditor *textEditor = d->m_plugin->currentTextEditor(); ITextEditor *textEditor = currentTextEditor();
QTC_ASSERT(textEditor, return); QTC_ASSERT(textEditor, return);
QString fileName = textEditor->file()->fileName(); QString fileName = textEditor->file()->fileName();
int lineNumber = textEditor->currentLine(); int lineNumber = textEditor->currentLine();
if (d->m_engine && !fileName.isEmpty()) { if (fileName.isEmpty())
STATE_DEBUG(fileName << lineNumber); return;
d->m_engine->executeJumpToLine(fileName, lineNumber); executeJumpToLine(fileName, lineNumber);
}
} }
*/
// Called from RunControl. // Called from RunControl.
void DebuggerEngine::handleFinished() void DebuggerEngine::handleFinished()
@@ -907,7 +913,6 @@ void DebuggerEngine::startSuccessful()
void DebuggerEngine::notifyInferiorPid(qint64 pid) void DebuggerEngine::notifyInferiorPid(qint64 pid)
{ {
//STATE_DEBUG(d->m_inferiorPid << pid);
if (d->m_inferiorPid == pid) if (d->m_inferiorPid == pid)
return; return;
d->m_inferiorPid = pid; d->m_inferiorPid = pid;

View File

@@ -229,7 +229,6 @@ public:
void executeStepOutX(); void executeStepOutX();
void executeStepNextX(); void executeStepNextX();
void executeReturnX(); void executeReturnX();
void executeWatchPointX();
DebuggerState state() const; DebuggerState state() const;
@@ -259,6 +258,11 @@ public slots:
protected: protected:
void setState(DebuggerState state, bool forced = false); void setState(DebuggerState state, bool forced = false);
private:
void executeRunToLine();
void executeRunToFunction();
void executeJumpToLine();
DebuggerEnginePrivate *d; DebuggerEnginePrivate *d;
}; };

View File

@@ -293,6 +293,8 @@ static QToolButton *toolButton(QAction *action)
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
static const char *Role = "ROLE";
// FIXME: Outdated? // FIXME: Outdated?
// The createCdbEngine function takes a list of options pages it can add to. // The createCdbEngine function takes a list of options pages it can add to.
// This allows for having a "enabled" toggle on the page independently // This allows for having a "enabled" toggle on the page independently
@@ -851,7 +853,6 @@ public slots:
void sessionLoaded(); void sessionLoaded();
void aboutToUnloadSession(); void aboutToUnloadSession();
void aboutToSaveSession(); void aboutToSaveSession();
void watchPoint() { QTC_ASSERT(false, /**/); } // FIXME
void executeDebuggerCommand(); void executeDebuggerCommand();
@@ -1044,59 +1045,59 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er
QIcon continueIcon = QIcon(":/debugger/images/debugger_continue_small.png"); QIcon continueIcon = QIcon(":/debugger/images/debugger_continue_small.png");
continueIcon.addFile(":/debugger/images/debugger_continue.png"); continueIcon.addFile(":/debugger/images/debugger_continue.png");
m_actions.continueAction->setIcon(continueIcon); m_actions.continueAction->setIcon(continueIcon);
m_actions.continueAction->setData(RequestExecContinueRole); m_actions.continueAction->setProperty(Role, RequestExecContinueRole);
m_actions.stopAction = new QAction(tr("Interrupt"), this); m_actions.stopAction = new QAction(tr("Interrupt"), this);
m_actions.stopAction->setIcon(m_interruptIcon); m_actions.stopAction->setIcon(m_interruptIcon);
m_actions.stopAction->setData(RequestExecInterruptRole); m_actions.stopAction->setProperty(Role, RequestExecInterruptRole);
m_actions.resetAction = new QAction(tr("Abort Debugging"), this); m_actions.resetAction = new QAction(tr("Abort Debugging"), this);
m_actions.resetAction->setData(RequestExecResetRole); m_actions.resetAction->setProperty(Role, RequestExecResetRole);
m_actions.resetAction->setToolTip(tr("Aborts debugging and " m_actions.resetAction->setToolTip(tr("Aborts debugging and "
"resets the debugger to the initial state.")); "resets the debugger to the initial state."));
m_actions.nextAction = new QAction(tr("Step Over"), this); m_actions.nextAction = new QAction(tr("Step Over"), this);
m_actions.nextAction->setData(RequestExecNextRole); m_actions.nextAction->setProperty(Role, RequestExecNextRole);
m_actions.nextAction->setIcon( m_actions.nextAction->setIcon(
QIcon(":/debugger/images/debugger_stepover_small.png")); QIcon(":/debugger/images/debugger_stepover_small.png"));
m_actions.stepAction = new QAction(tr("Step Into"), this); m_actions.stepAction = new QAction(tr("Step Into"), this);
m_actions.stepAction->setData(RequestExecStepRole); m_actions.stepAction->setProperty(Role, RequestExecStepRole);
m_actions.stepAction->setIcon( m_actions.stepAction->setIcon(
QIcon(":/debugger/images/debugger_stepinto_small.png")); QIcon(":/debugger/images/debugger_stepinto_small.png"));
m_actions.stepOutAction = new QAction(tr("Step Out"), this); m_actions.stepOutAction = new QAction(tr("Step Out"), this);
m_actions.stepOutAction->setData(RequestExecStepOutRole); m_actions.stepOutAction->setProperty(Role, RequestExecStepOutRole);
m_actions.stepOutAction->setIcon( m_actions.stepOutAction->setIcon(
QIcon(":/debugger/images/debugger_stepout_small.png")); QIcon(":/debugger/images/debugger_stepout_small.png"));
m_actions.runToLineAction1 = new QAction(tr("Run to Line"), this); m_actions.runToLineAction1 = new QAction(tr("Run to Line"), this);
m_actions.runToLineAction1->setData(RequestExecRunToLineRole); m_actions.runToLineAction1->setProperty(Role, RequestExecRunToLineRole);
m_actions.runToLineAction2 = new QAction(tr("Run to Line"), this); m_actions.runToLineAction2 = new QAction(tr("Run to Line"), this);
m_actions.runToLineAction2->setData(RequestExecRunToLineRole); m_actions.runToLineAction2->setProperty(Role, RequestExecRunToLineRole);
m_actions.runToFunctionAction = m_actions.runToFunctionAction =
new QAction(tr("Run to Outermost Function"), this); new QAction(tr("Run to Outermost Function"), this);
m_actions.runToFunctionAction->setData(RequestExecRunToFunctionRole); m_actions.runToFunctionAction->setProperty(Role, RequestExecRunToFunctionRole);
m_actions.returnFromFunctionAction = m_actions.returnFromFunctionAction =
new QAction(tr("Immediately Return From Inner Function"), this); new QAction(tr("Immediately Return From Inner Function"), this);
m_actions.returnFromFunctionAction->setData(RequestExecReturnFromFunctionRole); m_actions.returnFromFunctionAction->setProperty(Role, RequestExecReturnFromFunctionRole);
m_actions.jumpToLineAction1 = new QAction(tr("Jump to Line"), this); m_actions.jumpToLineAction1 = new QAction(tr("Jump to Line"), this);
m_actions.jumpToLineAction1->setData(RequestExecJumpToLineRole); m_actions.jumpToLineAction1->setProperty(Role, RequestExecJumpToLineRole);
m_actions.jumpToLineAction2 = new QAction(tr("Jump to Line"), this); m_actions.jumpToLineAction2 = new QAction(tr("Jump to Line"), this);
m_actions.jumpToLineAction1->setData(RequestExecJumpToLineRole); m_actions.jumpToLineAction1->setProperty(Role, RequestExecJumpToLineRole);
m_actions.breakAction = new QAction(tr("Toggle Breakpoint"), this); m_actions.breakAction = new QAction(tr("Toggle Breakpoint"), this);
m_actions.watchAction1 = new QAction(tr("Add to Watch Window"), this); m_actions.watchAction1 = new QAction(tr("Add to Watch Window"), this);
m_actions.watchAction1->setData(RequestExecWatchRole); m_actions.watchAction1->setProperty(Role, RequestExecWatchRole);
m_actions.watchAction2 = new QAction(tr("Add to Watch Window"), this); m_actions.watchAction2 = new QAction(tr("Add to Watch Window"), this);
m_actions.watchAction2->setData(RequestExecWatchRole); m_actions.watchAction2->setProperty(Role, RequestExecWatchRole);
m_actions.snapshotAction = new QAction(tr("Snapshot"), this); m_actions.snapshotAction = new QAction(tr("Snapshot"), this);
m_actions.snapshotAction->setData(RequestExecSnapshotRole); m_actions.snapshotAction->setProperty(Role, RequestExecSnapshotRole);
m_actions.snapshotAction->setIcon( m_actions.snapshotAction->setIcon(
QIcon(":/debugger/images/debugger_snapshot_small.png")); QIcon(":/debugger/images/debugger_snapshot_small.png"));
@@ -1110,14 +1111,15 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er
m_actions.frameDownAction = m_actions.frameDownAction =
new QAction(tr("Move to Called Frame"), this); new QAction(tr("Move to Called Frame"), this);
m_actions.frameDownAction->setData(RequestExecFrameDownRole); m_actions.frameDownAction->setProperty(Role, RequestExecFrameDownRole);
m_actions.frameUpAction = m_actions.frameUpAction =
new QAction(tr("Move to Calling Frame"), this); new QAction(tr("Move to Calling Frame"), this);
m_actions.frameUpAction->setData(RequestExecFrameUpRole); m_actions.frameUpAction->setProperty(Role, RequestExecFrameUpRole);
m_actions.reverseDirectionAction->setCheckable(false); m_actions.reverseDirectionAction->setCheckable(false);
theDebuggerAction(OperateByInstruction)-> theDebuggerAction(OperateByInstruction)->
setData(RequestOperatedByInstructionTriggeredRole); setProperty(Role, RequestOperatedByInstructionTriggeredRole);
theDebuggerAction(WatchPoint)->setProperty(Role, RequestWatchPointRole);
connect(m_actions.continueAction, SIGNAL(triggered()), SLOT(onAction())); connect(m_actions.continueAction, SIGNAL(triggered()), SLOT(onAction()));
connect(m_actions.nextAction, SIGNAL(triggered()), SLOT(onAction())); connect(m_actions.nextAction, SIGNAL(triggered()), SLOT(onAction()));
@@ -1138,7 +1140,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er
connect(m_actions.resetAction, SIGNAL(triggered()), SLOT(onAction())); connect(m_actions.resetAction, SIGNAL(triggered()), SLOT(onAction()));
connect(&m_statusTimer, SIGNAL(timeout()), SLOT(clearStatusMessage())); connect(&m_statusTimer, SIGNAL(timeout()), SLOT(clearStatusMessage()));
connect(theDebuggerAction(WatchPoint), SIGNAL(triggered()), SLOT(watchPoint())); connect(theDebuggerAction(WatchPoint), SIGNAL(triggered()), SLOT(onAction()));
connect(theDebuggerAction(ExecuteCommand), SIGNAL(triggered()), connect(theDebuggerAction(ExecuteCommand), SIGNAL(triggered()),
SLOT(executeDebuggerCommand())); SLOT(executeDebuggerCommand()));
@@ -1251,7 +1253,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er
m_detachAction = new QAction(this); m_detachAction = new QAction(this);
m_detachAction->setText(tr("Detach Debugger")); m_detachAction->setText(tr("Detach Debugger"));
m_detachAction->setData(RequestExecDetachRole); m_detachAction->setProperty(Role, RequestExecDetachRole);
connect(m_detachAction, SIGNAL(triggered()), SLOT(onAction())); connect(m_detachAction, SIGNAL(triggered()), SLOT(onAction()));
Core::Command *cmd = 0; Core::Command *cmd = 0;
@@ -1544,7 +1546,7 @@ void DebuggerPluginPrivate::onAction()
{ {
QAction *act = qobject_cast<QAction *>(sender()); QAction *act = qobject_cast<QAction *>(sender());
QTC_ASSERT(act, return); QTC_ASSERT(act, return);
const int role = act->data().toInt(); const int role = act->property(Role).toInt();
notifyCurrentEngine(role); notifyCurrentEngine(role);
} }