From bcd279a198b09f62ed481324a3f879b58949f81d Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Thu, 2 Apr 2009 15:06:24 +0200 Subject: [PATCH] debugger: make maximal number of stack entries configurable --- src/libs/utils/savedaction.h | 2 ++ src/plugins/debugger/debuggeractions.cpp | 27 +++++++++------- src/plugins/debugger/debuggeractions.h | 3 ++ src/plugins/debugger/debuggerplugin.cpp | 2 ++ src/plugins/debugger/gdbengine.cpp | 28 ++++++++++++++--- src/plugins/debugger/gdbengine.h | 1 + src/plugins/debugger/gdboptionpage.ui | 40 ++++++++++++++++++++++-- src/plugins/debugger/stackhandler.cpp | 9 +++--- src/plugins/debugger/stackwindow.cpp | 4 ++- 9 files changed, 92 insertions(+), 24 deletions(-) diff --git a/src/libs/utils/savedaction.h b/src/libs/utils/savedaction.h index ab92a4ad80e..53eaa047c81 100644 --- a/src/libs/utils/savedaction.h +++ b/src/libs/utils/savedaction.h @@ -93,6 +93,8 @@ private: Q_SLOT void lineEditEditingFinished(); Q_SLOT void pathChooserEditingFinished(); Q_SLOT void actionTriggered(bool); + Q_SLOT void spinBoxValueChanged(int); + Q_SLOT void spinBoxValueChanged(QString); QVariant m_value; QVariant m_defaultValue; diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index f93819c6e9a..b8bc4dad5a1 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -250,16 +250,16 @@ DebuggerSettings *theDebuggerSettings() // Settings // item = new SavedAction(instance); - instance->insertItem(GdbLocation, item); item->setSettingsKey("DebugMode", "Location"); + instance->insertItem(GdbLocation, item); item = new SavedAction(instance); - instance->insertItem(GdbEnvironment, item); item->setSettingsKey("DebugMode", "Environment"); + instance->insertItem(GdbEnvironment, item); item = new SavedAction(instance); - instance->insertItem(GdbScriptFile, item); item->setSettingsKey("DebugMode", "ScriptFile"); + instance->insertItem(GdbScriptFile, item); item = new SavedAction(instance); item->setSettingsKey("DebugMode", "AutoQuit"); @@ -268,43 +268,48 @@ DebuggerSettings *theDebuggerSettings() instance->insertItem(AutoQuit, item); item = new SavedAction(instance); - instance->insertItem(UseToolTips, item); item->setSettingsKey("DebugMode", "UseToolTips"); item->setText(QObject::tr("Use tooltips when debugging")); item->setCheckable(true); + instance->insertItem(UseToolTips, item); item = new SavedAction(instance); - instance->insertItem(TerminalApplication, item); item->setDefaultValue("xterm"); item->setSettingsKey("DebugMode", "Terminal"); + instance->insertItem(TerminalApplication, item); item = new SavedAction(instance); - instance->insertItem(ListSourceFiles, item); item->setSettingsKey("DebugMode", "ListSourceFiles"); item->setText(QObject::tr("List source files")); item->setCheckable(true); + instance->insertItem(ListSourceFiles, item); item = new SavedAction(instance); - instance->insertItem(SkipKnownFrames, item); item->setSettingsKey("DebugMode", "SkipKnownFrames"); item->setText(QObject::tr("Skip known frames")); item->setCheckable(true); + instance->insertItem(SkipKnownFrames, item); item = new SavedAction(instance); - instance->insertItem(AllPluginBreakpoints, item); item->setSettingsKey("DebugMode", "AllPluginBreakpoints"); + instance->insertItem(AllPluginBreakpoints, item); item = new SavedAction(instance); - instance->insertItem(SelectedPluginBreakpoints, item); item->setSettingsKey("DebugMode", "SelectedPluginBreakpoints"); + instance->insertItem(SelectedPluginBreakpoints, item); item = new SavedAction(instance); - instance->insertItem(NoPluginBreakpoints, item); item->setSettingsKey("DebugMode", "NoPluginBreakpoints"); + instance->insertItem(NoPluginBreakpoints, item); item = new SavedAction(instance); - instance->insertItem(SelectedPluginBreakpointsPattern, item); item->setSettingsKey("DebugMode", "SelectedPluginBreakpointsPattern"); + instance->insertItem(SelectedPluginBreakpointsPattern, item); + + item = new SavedAction(instance); + item->setSettingsKey("DebugMode", "MaximalStackDepth"); + item->setDefaultValue(20); + instance->insertItem(MaximalStackDepth, item); return instance; } diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index 3972aafce2a..079a879bc79 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -76,6 +76,9 @@ enum DebuggerActionCode GdbEnvironment, GdbScriptFile, + // Stack + MaximalStackDepth, + // Watchers & Locals WatchExpression, WatchExpressionInWindow, diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 2ecd00ffc2a..fbe80e45882 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -297,6 +297,8 @@ QWidget *GdbOptionPage::createPage(QWidget *parent) m_ui.checkBoxSkipKnownFrames); m_group.insert(theDebuggerAction(UseToolTips), m_ui.checkBoxUseToolTips); + m_group.insert(theDebuggerAction(MaximalStackDepth), + m_ui.spinBoxMaximalStackDepth); m_ui.lineEditSelectedPluginBreakpointsPattern-> setEnabled(theDebuggerAction(SelectedPluginBreakpoints)->value().toBool()); diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index b53bee96073..e6717fcbc00 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -886,7 +886,7 @@ void GdbEngine::handleTargetCore(const GdbResultRecord &record) qq->stackHandler()->setCurrentIndex(0); updateLocals(); // Quick shot - sendSynchronizedCommand("-stack-list-frames", StackListFrames); + reloadStack(); if (supportsThreads()) sendSynchronizedCommand("-thread-list-ids", StackListThreads, 0); @@ -1303,6 +1303,13 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data) #endif } +void GdbEngine::reloadStack() +{ + QString cmd = "-stack-list-frames"; + if (int stackDepth = theDebuggerAction(MaximalStackDepth)->value().toInt()) + cmd += " 0 " + QString::number(stackDepth); + sendSynchronizedCommand(cmd, StackListFrames); +} void GdbEngine::handleAsyncOutput2(const GdbMi &data) { @@ -1315,7 +1322,7 @@ void GdbEngine::handleAsyncOutput2(const GdbMi &data) updateLocals(); // Quick shot int currentId = data.findChild("thread-id").data().toInt(); - sendSynchronizedCommand("-stack-list-frames", StackListFrames); + reloadStack(); if (supportsThreads()) sendSynchronizedCommand("-thread-list-ids", StackListThreads, currentId); @@ -1739,7 +1746,7 @@ void GdbEngine::handleAttach() qq->stackHandler()->setCurrentIndex(0); updateLocals(); // Quick shot - sendSynchronizedCommand("-stack-list-frames", StackListFrames); + reloadStack(); if (supportsThreads()) sendSynchronizedCommand("-thread-list-ids", StackListThreads, 0); @@ -2441,7 +2448,7 @@ void GdbEngine::handleStackSelectThread(const GdbResultRecord &record, int) Q_UNUSED(record); //qDebug("FIXME: StackHandler::handleOutput: SelectThread"); q->showStatusMessage(tr("Retrieving data for stack view..."), 3000); - sendCommand("-stack-list-frames", StackListFrames); + reloadStack(); } @@ -2458,7 +2465,8 @@ void GdbEngine::handleStackListFrames(const GdbResultRecord &record) int topFrame = -1; - for (int i = 0; i != stack.childCount(); ++i) { + int n = stack.childCount(); + for (int i = 0; i != n; ++i) { //qDebug() << "HANDLING FRAME: " << stack.childAt(i).toString(); const GdbMi frameMi = stack.childAt(i); StackFrame frame(i); @@ -2495,6 +2503,16 @@ void GdbEngine::handleStackListFrames(const GdbResultRecord &record) topFrame = i; } + if (n >= theDebuggerAction(MaximalStackDepth)->value().toInt()) { + StackFrame frame(n); + frame.file = "..."; + frame.function = "..."; + frame.from = "..."; + frame.line = 0; + frame.address = "..."; + stackFrames.append(frame); + } + qq->stackHandler()->setFrames(stackFrames); #if 0 diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index 49b823e957b..0ea15012e98 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -280,6 +280,7 @@ private: void handleStackListFrames(const GdbResultRecord &record); void handleStackSelectThread(const GdbResultRecord &record, int cookie); void handleStackListThreads(const GdbResultRecord &record, int cookie); + void reloadStack(); // diff --git a/src/plugins/debugger/gdboptionpage.ui b/src/plugins/debugger/gdboptionpage.ui index 5b690eeb6b0..c3994e7b8e9 100644 --- a/src/plugins/debugger/gdboptionpage.ui +++ b/src/plugins/debugger/gdboptionpage.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>410</width> - <height>435</height> + <width>429</width> + <height>452</height> </rect> </property> <property name="windowTitle"> @@ -182,6 +182,42 @@ you indent to use or the name of a terminal that will be searched in your PATH.< </property> </widget> </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLabel" name="labelMaximalStackDepth"> + <property name="text"> + <string>Maximal stack depth:</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBoxMaximalStackDepth"> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> + <property name="frame"> + <bool>false</bool> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="specialValueText"> + <string><unlimited></string> + </property> + <property name="maximum"> + <number>999</number> + </property> + <property name="singleStep"> + <number>5</number> + </property> + <property name="value"> + <number>10</number> + </property> + </widget> + </item> + </layout> + </item> </layout> </widget> </item> diff --git a/src/plugins/debugger/stackhandler.cpp b/src/plugins/debugger/stackhandler.cpp index a131bc00428..17c8168c7c3 100644 --- a/src/plugins/debugger/stackhandler.cpp +++ b/src/plugins/debugger/stackhandler.cpp @@ -37,11 +37,9 @@ using namespace Debugger::Internal; -StackFrame::StackFrame(int l) : - level(l), - line(0) -{ -} +StackFrame::StackFrame(int l) + : level(l), line(0) +{} bool StackFrame::isUsable() const { @@ -183,6 +181,7 @@ bool StackHandler::isDebuggingDumpers() const return false; } + //////////////////////////////////////////////////////////////////////// // // ThreadsHandler diff --git a/src/plugins/debugger/stackwindow.cpp b/src/plugins/debugger/stackwindow.cpp index f105f057f13..e0340ce0ae8 100644 --- a/src/plugins/debugger/stackwindow.cpp +++ b/src/plugins/debugger/stackwindow.cpp @@ -29,7 +29,7 @@ #include "stackwindow.h" -#include "stackhandler.h" +#include "debuggeractions.h" #include <utils/qtcassert.h> @@ -102,6 +102,8 @@ void StackWindow::contextMenuEvent(QContextMenuEvent *ev) menu.addSeparator(); menu.addAction(act1); menu.addAction(act2); + menu.addSeparator(); + menu.addAction(theDebuggerAction(SettingsDialog)); QAction *act = menu.exec(ev->globalPos()); -- GitLab