OSDN Git Service

Introduced capabilities for OperateByInstruction and RunToLine
authorThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Fri, 1 Apr 2011 17:47:39 +0000 (19:47 +0200)
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Mon, 9 May 2011 11:13:14 +0000 (13:13 +0200)
The ScriptEngine does not support these actions, so make sure they are
disabled in the debugger menu.

Reviewed-by: hjk
Task-number: QTCREATORBUG-2749

src/plugins/debugger/cdb/cdbengine.cpp
src/plugins/debugger/debuggerconstants.h
src/plugins/debugger/debuggerplugin.cpp
src/plugins/debugger/gdb/gdbengine.cpp

index 572b3bf..53dcd16 100644 (file)
@@ -1073,7 +1073,9 @@ unsigned CdbEngine::debuggerCapabilities() const
            |ReloadModuleCapability
            |BreakOnThrowAndCatchCapability // Sort-of: Can break on throw().
            |BreakConditionCapability|TracePointCapability
-           |BreakModuleCapability;
+           |BreakModuleCapability
+           |OperateByInstructionCapability
+           |RunToLineCapability;
 }
 
 void CdbEngine::executeStep()
index c54a4d4..d72a805 100644 (file)
@@ -151,6 +151,8 @@ enum DebuggerCapabilities
     WatchpointByExpressionCapability = 0x20000,
     ShowModuleSymbolsCapability = 0x40000,
     CatchCapability = 0x80000, //!< fork, vfork, syscall
+    OperateByInstructionCapability = 0x100000,
+    RunToLineCapability = 0x200000,
     AllDebuggerCapabilities = 0xFFFFFFFF
 };
 
index a3f5038..7816bbe 100644 (file)
@@ -1704,19 +1704,20 @@ void DebuggerPluginPrivate::requestContextMenu(ITextEditor *editor,
     // Run to, jump to line below in stopped state.
     if (currentEngine()->state() == InferiorStopOk && contextUsable) {
         menu->addSeparator();
-        const QString runText = args.address
-            ? DebuggerEngine::tr("Run to Address 0x%1").arg(args.address, 0, 16)
-            : DebuggerEngine::tr("Run to Line %1").arg(args.lineNumber);
-        QAction *runToLineAction  = new QAction(runText, menu);
-        runToLineAction->setData(QVariant::fromValue(args));
-        connect(runToLineAction, SIGNAL(triggered()), SLOT(slotRunToLine()));
-        menu->addAction(runToLineAction);
+        if (currentEngine()->debuggerCapabilities() & RunToLineCapability) {
+            const QString runText = args.address
+                ? DebuggerEngine::tr("Run to Address 0x%1").arg(args.address, 0, 16)
+                : DebuggerEngine::tr("Run to Line %1").arg(args.lineNumber);
+            QAction *runToLineAction  = new QAction(runText, menu);
+            runToLineAction->setData(QVariant::fromValue(args));
+            connect(runToLineAction, SIGNAL(triggered()), SLOT(slotRunToLine()));
+            menu->addAction(runToLineAction);
+        }
         if (currentEngine()->debuggerCapabilities() & JumpToLineCapability) {
             const QString jumpText = args.address
                 ? DebuggerEngine::tr("Jump to Address 0x%1").arg(args.address, 0, 16)
                 : DebuggerEngine::tr("Jump to Line %1").arg(args.lineNumber);
             QAction *jumpToLineAction  = new QAction(jumpText, menu);
-            menu->addAction(runToLineAction);
             jumpToLineAction->setData(QVariant::fromValue(args));
             connect(jumpToLineAction, SIGNAL(triggered()), SLOT(slotJumpToLine()));
             menu->addAction(jumpToLineAction);
@@ -2057,7 +2058,9 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
     m_watchAction2->setEnabled(true);
     m_breakAction->setEnabled(true);
 
-    action(OperateByInstruction)->setEnabled(stopped || isCore);
+    const bool canOperateByInstruction = (caps & OperateByInstructionCapability)
+            && (stopped || isCore);
+    action(OperateByInstruction)->setEnabled(canOperateByInstruction);
 
     m_resetAction->setEnabled(state != DebuggerNotReady
                                       && state != DebuggerFinished);
@@ -2066,7 +2069,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
     m_nextAction->setEnabled(stopped || state == DebuggerNotReady);
 
     m_stepOutAction->setEnabled(stopped);
-    m_runToLineAction->setEnabled(stopped);
+    m_runToLineAction->setEnabled(stopped && (caps & RunToLineCapability));
     m_runToSelectedFunctionAction->setEnabled(stopped);
     m_returnFromFunctionAction->
         setEnabled(stopped && (caps & ReturnFromFunctionCapability));
index bc0fe65..8a2c359 100644 (file)
@@ -1890,7 +1890,9 @@ unsigned GdbEngine::debuggerCapabilities() const
         | WatchpointByExpressionCapability
         | AddWatcherCapability
         | ShowModuleSymbolsCapability
-        | CatchCapability;
+        | CatchCapability
+        | OperateByInstructionCapability
+        | RunToLineCapability;
 
     if (startParameters().startMode == AttachCore)
         return caps;