diff --git a/src/plugins/debugger/breakwindow.cpp b/src/plugins/debugger/breakwindow.cpp index 46dc6faac71442e094afbb66593e4123ab4be9e2..b0edd855459329dff239e5680bcb6e0f5392b3e6 100644 --- a/src/plugins/debugger/breakwindow.cpp +++ b/src/plugins/debugger/breakwindow.cpp @@ -30,6 +30,7 @@ #include "breakwindow.h" #include "debuggeractions.h" +#include "debuggermanager.h" #include "ui_breakcondition.h" #include "ui_breakbyfunction.h" @@ -179,6 +180,7 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev) editConditionAction->setEnabled(si.size() > 0); QAction *synchronizeAction = new QAction(tr("Synchronize breakpoints"), &menu); + synchronizeAction->setEnabled(Debugger::DebuggerManager::instance()->debuggerActionsEnabled()); QModelIndex idx0 = (si.size() ? si.front() : QModelIndex()); QModelIndex idx2 = idx0.sibling(idx0.row(), 2); diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index a90d143f9dd88a198f0820412ee101a74e47df70..7d96912c8a87308cdee5b2c44f71806e97d1977a 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -1684,11 +1684,51 @@ void DebuggerManager::setState(DebuggerState state) d->m_actions.runToFunctionAction->setEnabled(stopped); d->m_actions.jumpToLineAction->setEnabled(stopped); d->m_actions.nextAction->setEnabled(stopped); + + const bool actionsEnabled = debuggerActionsEnabled(); + theDebuggerAction(RecheckDebuggingHelpers)->setEnabled(actionsEnabled); + theDebuggerAction(AutoDerefPointers)->setEnabled(actionsEnabled && d->m_engine->isGdbEngine()); + theDebuggerAction(ExpandStack)->setEnabled(actionsEnabled); + theDebuggerAction(ExecuteCommand)->setEnabled(d->m_state != DebuggerNotReady); + emit stateChanged(d->m_state); const bool notbusy = state == InferiorStopped || state == DebuggerNotReady || state == InferiorUnrunnable; setBusyCursor(!notbusy); + +} + +bool DebuggerManager::debuggerActionsEnabled() const +{ + if (!d->m_engine) + return false; + switch (state()) { + case InferiorPrepared: + case InferiorStarting: + case InferiorRunningRequested: + case InferiorRunning: + case InferiorUnrunnable: + case InferiorStopping: + case InferiorStopped: + return true; + case DebuggerNotReady: + case EngineStarting: + case AdapterStarting: + case AdapterStarted: + case AdapterStartFailed: + case InferiorPreparing: + case InferiorPreparationFailed: + case InferiorStartFailed: + case InferiorStopFailed: + case InferiorShuttingDown: + case InferiorShutDown: + case InferiorShutdownFailed: + case AdapterShuttingDown: + case AdapterShutdownFailed: + break; + } + return false; } QDebug operator<<(QDebug d, DebuggerState state) diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index 7579ebd722771b39b70f8f4c472802264a863d37..ee7f439ba984e2114e1fd5575b6083c72d30fb90 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -175,6 +175,8 @@ public: void showMessageBox(int icon, const QString &title, const QString &text); + bool debuggerActionsEnabled() const; + static DebuggerManager *instance(); public slots: diff --git a/src/plugins/debugger/moduleswindow.cpp b/src/plugins/debugger/moduleswindow.cpp index f5d48db088290a26c2e0c849519277c9a6286aac..6d46dda03c50eae2437782acd868dab2f39402a7 100644 --- a/src/plugins/debugger/moduleswindow.cpp +++ b/src/plugins/debugger/moduleswindow.cpp @@ -105,11 +105,15 @@ void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev) if (index.isValid()) name = model()->data(index).toString(); + QMenu menu; + const bool enabled = Debugger::DebuggerManager::instance()->debuggerActionsEnabled(); QAction *act0 = new QAction(tr("Update module list"), &menu); - QAction *act3 = new QAction(tr("Show source files for module \"%1\"").arg(name), - &menu); + act0->setEnabled(enabled); + QAction *act3 = new QAction(tr("Show source files for module \"%1\"").arg(name), &menu); + act3->setEnabled(enabled); QAction *act4 = new QAction(tr("Load symbols for all modules"), &menu); + act4->setEnabled(enabled); QAction *act5 = 0; QAction *act6 = 0; QAction *act7 = 0; diff --git a/src/plugins/debugger/registerwindow.cpp b/src/plugins/debugger/registerwindow.cpp index 3bc52f294567c15000ee3a3177948468bf8fac9c..ddaedbd808c381b62946eeb3e28bd24b2b29d582 100644 --- a/src/plugins/debugger/registerwindow.cpp +++ b/src/plugins/debugger/registerwindow.cpp @@ -177,6 +177,7 @@ void RegisterWindow::contextMenuEvent(QContextMenuEvent *ev) } else { actShowMemory->setText(tr("Open memory editor at %1").arg(address)); } + actShowMemory->setEnabled(m_manager->debuggerActionsEnabled()); menu.addSeparator(); int base = model()->data(QModelIndex(), RegisterNumberBaseRole).toInt(); diff --git a/src/plugins/debugger/sourcefileswindow.cpp b/src/plugins/debugger/sourcefileswindow.cpp index 5a9f5b5151d7acd493ba3b614cd3cc47dc801feb..52341c6285297c96df2a8041d9c4fd9cb8455136 100644 --- a/src/plugins/debugger/sourcefileswindow.cpp +++ b/src/plugins/debugger/sourcefileswindow.cpp @@ -29,6 +29,7 @@ #include "sourcefileswindow.h" #include "debuggeractions.h" +#include "debuggermanager.h" #include <QtCore/QDebug> #include <QtCore/QFileInfo> @@ -199,6 +200,7 @@ void SourceFilesWindow::contextMenuEvent(QContextMenuEvent *ev) QMenu menu; QAction *act1 = new QAction(tr("Reload data"), &menu); + act1->setEnabled(Debugger::DebuggerManager::instance()->debuggerActionsEnabled()); //act1->setCheckable(true); QAction *act2 = 0; if (name.isEmpty()) { diff --git a/src/plugins/debugger/stackhandler.cpp b/src/plugins/debugger/stackhandler.cpp index a12367df9a4c2ad6a3abf194a8fb2330b661c434..2d9cbea92d7073b1a015bb819115945a63ff4e19 100644 --- a/src/plugins/debugger/stackhandler.cpp +++ b/src/plugins/debugger/stackhandler.cpp @@ -240,6 +240,7 @@ bool StackHandler::isDebuggingDebuggingHelpers() const ThreadData::ThreadData(int threadId) : id(threadId), + address(0), line(-1) { } diff --git a/src/plugins/debugger/stackwindow.cpp b/src/plugins/debugger/stackwindow.cpp index d854a5edaf6067d26700764e804a3c2882e9102b..910f69ea35c23a7932f010b66ec72fa860a47134 100644 --- a/src/plugins/debugger/stackwindow.cpp +++ b/src/plugins/debugger/stackwindow.cpp @@ -102,7 +102,7 @@ void StackWindow::contextMenuEvent(QContextMenuEvent *ev) actShowMemory->setEnabled(false); } else { actShowMemory->setText(tr("Open memory editor at %1").arg(address)); - } + } QAction *actShowDisassembler = menu.addAction(QString()); if (address.isEmpty()) { @@ -113,8 +113,9 @@ void StackWindow::contextMenuEvent(QContextMenuEvent *ev) } menu.addSeparator(); - +#if 0 // @TODO: not implemented menu.addAction(theDebuggerAction(UseToolTipsInStackView)); +#endif menu.addAction(theDebuggerAction(UseAddressInStackView)); QAction *actAdjust = menu.addAction(tr("Adjust column widths to contents")); diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index f40bb93085dcf57d4e4ffd45a4e232f479513338..db3f33057b7d0911e9d5650339a8d7d590d063ee 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -245,16 +245,15 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) } QMenu menu; - //QAction *actWatchExpressionInWindow - // = theDebuggerAction(WatchExpressionInWindow); - //menu.addAction(actWatchExpressionInWindow); QAction *actInsertNewWatchItem = menu.addAction(tr("Insert new watch item")); QAction *actSelectWidgetToWatch = menu.addAction(tr("Select widget to watch")); const QString address = model()->data(mi0, AddressRole).toString(); QAction *actWatchKnownMemory = 0; - QAction *actWatchUnknownMemory = new QAction(tr("Open memory editor..."), &menu);; + QAction *actWatchUnknownMemory = new QAction(tr("Open memory editor..."), &menu); + actWatchUnknownMemory->setEnabled(m_manager->debuggerActionsEnabled()); + if (!address.isEmpty()) actWatchKnownMemory = new QAction(tr("Open memory editor at %1").arg(address), &menu); menu.addSeparator(); @@ -270,6 +269,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) menu.addAction(actWatchKnownMemory); menu.addAction(actWatchUnknownMemory); menu.addSeparator(); + menu.addAction(theDebuggerAction(RecheckDebuggingHelpers)); menu.addAction(theDebuggerAction(UseDebuggingHelpers)); @@ -277,8 +277,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev) menu.addAction(theDebuggerAction(UseToolTipsInLocalsView)); menu.addAction(theDebuggerAction(AutoDerefPointers)); - theDebuggerAction(AutoDerefPointers)-> - setEnabled(m_manager->currentEngine()->isGdbEngine()); + QAction *actAdjustColumnWidths = menu.addAction(tr("Adjust column widths to contents")); QAction *actAlwaysAdjustColumnWidth =