summaryrefslogtreecommitdiff
path: root/src/plugins/debugger
diff options
context:
space:
mode:
authordt <qtc-committer@nokia.com>2009-03-25 15:28:39 +0100
committerdt <qtc-committer@nokia.com>2009-03-25 15:28:39 +0100
commit3e992d5d32267d338ab40cac20facb41f5fbcff2 (patch)
tree72c44323daf414acfc6d495dc04c7596d45f4452 /src/plugins/debugger
parente21a74cb35e37c178e4ad02bea0fab269dbf76cf (diff)
parent573b33d79e36dc2da8446661c5682b12cc712425 (diff)
downloadqt-creator-3e992d5d32267d338ab40cac20facb41f5fbcff2.tar.gz
Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline
Diffstat (limited to 'src/plugins/debugger')
-rw-r--r--src/plugins/debugger/breakwindow.cpp1
-rw-r--r--src/plugins/debugger/cdb/cdb.pri8
-rw-r--r--src/plugins/debugger/cdb/cdbdebugengine.cpp26
-rw-r--r--src/plugins/debugger/cdb/cdbdebugengine.h1
-rw-r--r--src/plugins/debugger/cdb/cdbdebugeventcallback.cpp4
-rw-r--r--src/plugins/debugger/debugger.pro2
-rw-r--r--src/plugins/debugger/debuggeractions.cpp93
-rw-r--r--src/plugins/debugger/debuggeractions.h16
-rw-r--r--src/plugins/debugger/debuggerconstants.h2
-rw-r--r--src/plugins/debugger/debuggermanager.cpp48
-rw-r--r--src/plugins/debugger/debuggermanager.h2
-rw-r--r--src/plugins/debugger/debuggeroutputwindow.cpp5
-rw-r--r--src/plugins/debugger/debuggerplugin.cpp4
-rw-r--r--src/plugins/debugger/gdbengine.cpp292
-rw-r--r--src/plugins/debugger/gdbengine.h2
-rw-r--r--src/plugins/debugger/registerhandler.cpp4
-rw-r--r--src/plugins/debugger/registerwindow.cpp70
-rw-r--r--src/plugins/debugger/sourcefileswindow.cpp25
-rw-r--r--src/plugins/debugger/watchhandler.cpp48
-rw-r--r--src/plugins/debugger/watchhandler.h6
-rw-r--r--src/plugins/debugger/watchutils.cpp303
-rw-r--r--src/plugins/debugger/watchutils.h70
-rw-r--r--src/plugins/debugger/watchwindow.cpp31
-rw-r--r--src/plugins/debugger/watchwindow.h12
24 files changed, 654 insertions, 421 deletions
diff --git a/src/plugins/debugger/breakwindow.cpp b/src/plugins/debugger/breakwindow.cpp
index 92fe3c7cb1..308d565a3e 100644
--- a/src/plugins/debugger/breakwindow.cpp
+++ b/src/plugins/debugger/breakwindow.cpp
@@ -101,6 +101,7 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
menu.addAction(act1);
menu.addAction(act2);
menu.addAction(act4);
+ menu.addSeparator();
menu.addAction(theDebuggerAction(SettingsDialog));
QAction *act = menu.exec(ev->globalPos());
diff --git a/src/plugins/debugger/cdb/cdb.pri b/src/plugins/debugger/cdb/cdb.pri
index 527cd0be29..27186577c3 100644
--- a/src/plugins/debugger/cdb/cdb.pri
+++ b/src/plugins/debugger/cdb/cdb.pri
@@ -1,5 +1,8 @@
+# Detect presence of "Debugging Tools For Windows"
+# in case VS compilers are used.
+
win32 {
-# ---- Detect Debugging Tools For Windows
+contains(QMAKE_CXX, cl) {
CDB_PATH="$$(ProgramFiles)/Debugging Tools For Windows/sdk"
@@ -26,6 +29,7 @@ SOURCES += \
$$PWD/cdbdebugeventcallback.cpp \
$$PWD/cdbdebugoutput.cpp
} else {
- error("Debugging Tools for Windows could not be found in $$CDB_PATH")
+ message("Debugging Tools for Windows could not be found in $$CDB_PATH")
+}
}
}
diff --git a/src/plugins/debugger/cdb/cdbdebugengine.cpp b/src/plugins/debugger/cdb/cdbdebugengine.cpp
index efaa12d2b9..af9da55976 100644
--- a/src/plugins/debugger/cdb/cdbdebugengine.cpp
+++ b/src/plugins/debugger/cdb/cdbdebugengine.cpp
@@ -360,6 +360,16 @@ bool CdbDebugEngine::startDebuggerWithExecutable(DebuggerStartMode sm, QString *
return true;
}
+void CdbDebugEngine::processTerminated(unsigned long exitCode)
+{
+ if (debugCDB)
+ qDebug() << Q_FUNC_INFO << exitCode;
+
+ m_d->setDebuggeeHandles(0, 0);
+ m_d->m_debuggerManagerAccess->notifyInferiorExited();
+ m_d->m_debuggerManager->exitDebugger();
+}
+
void CdbDebugEngine::exitDebugger()
{
if (debugCDB)
@@ -380,7 +390,9 @@ void CdbDebugEngine::exitDebugger()
break;
case StartExternal:
case StartInternal:
+ // Terminate and waitr for stop events.
hr = m_d->m_pDebugClient->TerminateCurrentProcess();
+ QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
if (debugCDB)
qDebug() << Q_FUNC_INFO << "terminated" << msgDebugEngineComResult(hr);
@@ -469,7 +481,7 @@ bool CdbDebugEnginePrivate::updateLocals(int frameIndex,
value = QLatin1String("<unknown>");
}
WatchData wd;
- wd.iname = QLatin1String("local");
+ wd.iname = QLatin1String("local.") + name;
wd.name = name;
wd.value = value;
wd.type = type;
@@ -592,6 +604,7 @@ void CdbDebugEngine::continueInferior()
m_d->m_debuggerManager->resetLocation();
ULONG executionStatus;
+ m_d->m_debuggerManagerAccess->notifyInferiorRunningRequested();
HRESULT hr = m_d->m_pDebugControl->GetExecutionStatus(&executionStatus);
if (SUCCEEDED(hr) && executionStatus != DEBUG_STATUS_GO) {
hr = m_d->m_pDebugControl->SetExecutionStatus(DEBUG_STATUS_GO);
@@ -654,8 +667,10 @@ void CdbDebugEngine::activateFrame(int frameIndex)
if (debugCDB)
qDebug() << Q_FUNC_INFO << frameIndex;
- if (m_d->m_debuggerManager->status() != DebuggerInferiorStopped)
+ if (m_d->m_debuggerManager->status() != DebuggerInferiorStopped) {
+ qWarning("WARNING %s: invoked while debuggee is running\n", Q_FUNC_INFO);
return;
+ }
QString errorMessage;
bool success = false;
@@ -793,7 +808,7 @@ void CdbDebugEngine::timerEvent(QTimerEvent* te)
const HRESULT hr = m_d->m_pDebugControl->WaitForEvent(0, 1);
if (debugCDB)
if (debugCDB > 1 || hr != S_FALSE)
- qDebug() << Q_FUNC_INFO << "WaitForEvent" << msgDebugEngineComResult(hr);
+ qDebug() << Q_FUNC_INFO << "WaitForEvent" << m_d->m_debuggerManager->status() << msgDebugEngineComResult(hr);
switch (hr) {
case S_OK:
@@ -974,9 +989,10 @@ void CdbDebugEnginePrivate::updateStackTrace()
}
}
-void CdbDebugEnginePrivate::handleDebugOutput(const char* szOutputString)
+void CdbDebugEnginePrivate::handleDebugOutput(const char *szOutputString)
{
- qDebug() << Q_FUNC_INFO << szOutputString;
+ if (debugCDB && strstr(szOutputString, "ModLoad:") == 0)
+ qDebug() << Q_FUNC_INFO << szOutputString;
m_debuggerManagerAccess->showApplicationOutput(QString::fromLocal8Bit(szOutputString));
}
diff --git a/src/plugins/debugger/cdb/cdbdebugengine.h b/src/plugins/debugger/cdb/cdbdebugengine.h
index 59ebeed571..0662a8350a 100644
--- a/src/plugins/debugger/cdb/cdbdebugengine.h
+++ b/src/plugins/debugger/cdb/cdbdebugengine.h
@@ -104,6 +104,7 @@ private:
bool startDebuggerWithExecutable(DebuggerStartMode sm, QString *errorMessage);
void startWatchTimer();
void killWatchTimer();
+ void processTerminated(unsigned long exitCode);
CdbDebugEnginePrivate *m_d;
diff --git a/src/plugins/debugger/cdb/cdbdebugeventcallback.cpp b/src/plugins/debugger/cdb/cdbdebugeventcallback.cpp
index c0f6cd80a4..ee8120f3e5 100644
--- a/src/plugins/debugger/cdb/cdbdebugeventcallback.cpp
+++ b/src/plugins/debugger/cdb/cdbdebugeventcallback.cpp
@@ -192,9 +192,7 @@ STDMETHODIMP CdbDebugEventCallback::ExitProcess(
{
if (debugCDB)
qDebug() << Q_FUNC_INFO << ExitCode;
-
- m_pEngine->m_d->setDebuggeeHandles(0, 0);
- m_pEngine->m_d->m_debuggerManagerAccess->notifyInferiorExited();
+ m_pEngine->processTerminated(ExitCode);
return S_OK;
}
diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro
index c86d379301..f6388fa835 100644
--- a/src/plugins/debugger/debugger.pro
+++ b/src/plugins/debugger/debugger.pro
@@ -26,6 +26,7 @@ HEADERS += \
debuggerrunner.h \
disassemblerhandler.h \
disassemblerwindow.h \
+ watchutils.h \
gdbengine.h \
gdbmi.h \
idebuggerengine.h \
@@ -56,6 +57,7 @@ SOURCES += \
debuggerrunner.cpp \
disassemblerhandler.cpp \
disassemblerwindow.cpp \
+ watchutils.cpp \
gdbengine.cpp \
gdbmi.cpp \
moduleshandler.cpp \
diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp
index f7edac224f..0a281d4fbc 100644
--- a/src/plugins/debugger/debuggeractions.cpp
+++ b/src/plugins/debugger/debuggeractions.cpp
@@ -34,7 +34,9 @@
#include <QtCore/QDebug>
#include <QtCore/QSettings>
+
#include <QtGui/QAction>
+#include <QtGui/QActionGroup>
#include <QtGui/QAbstractButton>
#include <QtGui/QRadioButton>
#include <QtGui/QCheckBox>
@@ -253,8 +255,15 @@ void DebuggerAction::pathChooserEditingFinished()
void DebuggerAction::actionTriggered(bool)
{
- if (this->isCheckable())
- setValue(this->isChecked());
+ //qDebug() << "TRIGGERING" << this << actionGroup();
+ if (isCheckable())
+ setValue(isChecked());
+ if (actionGroup() && actionGroup()->isExclusive()) {
+ // FIXME: should be taken care of more directly
+ foreach (QAction *act, actionGroup()->actions())
+ if (DebuggerAction *dact = qobject_cast<DebuggerAction *>(act))
+ dact->setValue(bool(act == this));
+ }
}
void DebuggerAction::trigger(const QVariant &data)
@@ -331,6 +340,9 @@ DebuggerSettings *theDebuggerSettings()
DebuggerAction *item = 0;
+ //
+ // View
+ //
item = new DebuggerAction(instance);
instance->insertItem(AdjustColumnWidths, item);
item->setText(QObject::tr("Adjust column widths to contents"));
@@ -340,6 +352,9 @@ DebuggerSettings *theDebuggerSettings()
item->setText(QObject::tr("Always adjust column widths to contents"));
item->setCheckable(true);
+ //
+ // Locals & Watchers
+ //
item = new DebuggerAction(instance);
instance->insertItem(WatchExpression, item);
item->setTextPattern(QObject::tr("Watch expression \"%1\""));
@@ -356,6 +371,14 @@ DebuggerSettings *theDebuggerSettings()
item = new DebuggerAction(instance);
instance->insertItem(AssignValue, item);
+ item = new DebuggerAction(instance);
+ instance->insertItem(ExpandItem, item);
+ item->setText(QObject::tr("Expand item"));
+
+ item = new DebuggerAction(instance);
+ instance->insertItem(CollapseItem, item);
+ item->setText(QObject::tr("Collapse item"));
+
//
// Dumpers
//
@@ -369,21 +392,69 @@ DebuggerSettings *theDebuggerSettings()
item->setCheckable(true);
item = new DebuggerAction(instance);
- instance->insertItem(RecheckDumpers, item);
item->setText(QObject::tr("Recheck custom dumper availability"));
+ instance->insertItem(RecheckDumpers, item);
//
// Breakpoints
//
item = new DebuggerAction(instance);
- instance->insertItem(SynchronizeBreakpoints, item);
item->setText(QObject::tr("Syncronize breakpoints"));
+ instance->insertItem(SynchronizeBreakpoints, item);
//
+ // Registers
+ //
+
+ QActionGroup *registerFormatGroup = new QActionGroup(instance);
+ registerFormatGroup->setExclusive(true);
+
item = new DebuggerAction(instance);
- instance->insertItem(AutoQuit, item);
- item->setText(QObject::tr("Automatically quit debugger"));
+ item->setText(QObject::tr("Hexadecimal"));
+ item->setCheckable(true);
+ item->setSettingsKey("DebugMode", "FormatHexadecimal");
+ item->setChecked(true);
+ instance->insertItem(FormatHexadecimal, item);
+ registerFormatGroup->addAction(item);
+
+ item = new DebuggerAction(instance);
+ item->setText(QObject::tr("Decimal"));
+ item->setCheckable(true);
+ item->setSettingsKey("DebugMode", "FormatDecimal");
+ instance->insertItem(FormatDecimal, item);
+ registerFormatGroup->addAction(item);
+
+ item = new DebuggerAction(instance);
+ item->setText(QObject::tr("Octal"));
item->setCheckable(true);
+ item->setSettingsKey("DebugMode", "FormatOctal");
+ instance->insertItem(FormatOctal, item);
+ registerFormatGroup->addAction(item);
+
+ item = new DebuggerAction(instance);
+ item->setText(QObject::tr("Binary"));
+ item->setCheckable(true);
+ item->setSettingsKey("DebugMode", "FormatBinary");
+ instance->insertItem(FormatBinary, item);
+ registerFormatGroup->addAction(item);
+
+ item = new DebuggerAction(instance);
+ item->setText(QObject::tr("Raw"));
+ item->setCheckable(true);
+ item->setSettingsKey("DebugMode", "FormatRaw");
+ instance->insertItem(FormatRaw, item);
+ registerFormatGroup->addAction(item);
+
+ item = new DebuggerAction(instance);
+ item->setText(QObject::tr("Natural"));
+ item->setCheckable(true);
+ item->setSettingsKey("DebugMode", "FormatNatural");
+ instance->insertItem(FormatNatural, item);
+ registerFormatGroup->addAction(item);
+
+ //
+ // Misc
+ //
item = new DebuggerAction(instance);
instance->insertItem(SkipKnownFrames, item);
@@ -417,12 +488,10 @@ DebuggerSettings *theDebuggerSettings()
item->setSettingsKey("DebugMode", "ScriptFile");
item = new DebuggerAction(instance);
- instance->insertItem(GdbAutoQuit, item);
item->setSettingsKey("DebugMode", "AutoQuit");
-
- item = new DebuggerAction(instance);
- instance->insertItem(GdbAutoRun, item);
- item->setSettingsKey("DebugMode", "AutoRun");
+ item->setText(QObject::tr("Automatically quit debugger"));
+ item->setCheckable(true);
+ instance->insertItem(AutoQuit, item);
item = new DebuggerAction(instance);
instance->insertItem(UseToolTips, item);
@@ -450,7 +519,7 @@ DebuggerSettings *theDebuggerSettings()
item->setSettingsKey("DebugMode", "PrebuiltDumpersLocation");
item = new DebuggerAction(instance);
- instance->insertItem(Terminal, item);
+ instance->insertItem(TerminalApplication, item);
item->setDefaultValue("xterm");
item->setSettingsKey("DebugMode", "Terminal");
diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h
index 47ccfa9638..75029ab952 100644
--- a/src/plugins/debugger/debuggeractions.h
+++ b/src/plugins/debugger/debuggeractions.h
@@ -134,16 +134,14 @@ enum DebuggerActionCode
SettingsDialog,
AdjustColumnWidths,
AlwaysAdjustColumnWidths,
-
+ AutoQuit,
+ TerminalApplication,
LockView,
// Gdb
GdbLocation,
GdbEnvironment,
GdbScriptFile,
- GdbAutoRun,
- GdbAutoQuit,
- Terminal,
// Watchers & Locals
WatchExpression,
@@ -152,6 +150,8 @@ enum DebuggerActionCode
WatchModelUpdate,
UseToolTips,
AssignValue,
+ ExpandItem,
+ CollapseItem,
RecheckDumpers,
UsePrebuiltDumpers,
@@ -173,7 +173,13 @@ enum DebuggerActionCode
NoPluginBreakpoints,
SelectedPluginBreakpointsPattern,
- AutoQuit,
+ // Registers
+ FormatHexadecimal,
+ FormatDecimal,
+ FormatOctal,
+ FormatBinary,
+ FormatRaw,
+ FormatNatural,
};
// singleton access
diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h
index c1369aa329..a17d1bb060 100644
--- a/src/plugins/debugger/debuggerconstants.h
+++ b/src/plugins/debugger/debuggerconstants.h
@@ -51,8 +51,6 @@ const char * const M_DEBUG_VIEWS = "Debugger.Menu.View.Debug";
const char * const C_GDBDEBUGGER = "Gdb Debugger";
const char * const GDBRUNNING = "Gdb.Running";
-const char * const PROPERTY_REGISTER_FORMAT = "Debugger.Property.RegisterFormat";
-
namespace Internal {
enum { debug = 0 };
}
diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp
index 5b7bb4be8e..561397ed36 100644
--- a/src/plugins/debugger/debuggermanager.cpp
+++ b/src/plugins/debugger/debuggermanager.cpp
@@ -88,6 +88,25 @@ using namespace Debugger::Constants;
static const QString tooltipIName = "tooltip";
+static const char *stateName(int s)
+{
+ switch (s) {
+ case DebuggerProcessNotReady:
+ return "DebuggerProcessNotReady";
+ case DebuggerProcessStartingUp:
+ return "DebuggerProcessStartingUp";
+ case DebuggerInferiorRunningRequested:
+ return "DebuggerInferiorRunningRequested";
+ case DebuggerInferiorRunning:
+ return "DebuggerInferiorRunning";
+ case DebuggerInferiorStopRequested:
+ return "DebuggerInferiorStopRequested";
+ case DebuggerInferiorStopped:
+ return "DebuggerInferiorStopped";
+ }
+ return "<unknown>";
+}
+
///////////////////////////////////////////////////////////////////////
//
// BreakByFunctionDialog
@@ -251,18 +270,10 @@ void DebuggerManager::init()
// Locals
QTreeView *localsView = qobject_cast<QTreeView *>(m_localsWindow);
localsView->setModel(m_watchHandler->model());
- connect(localsView, SIGNAL(requestExpandChildren(QModelIndex)),
- this, SLOT(expandChildren(QModelIndex)));
- connect(localsView, SIGNAL(requestCollapseChildren(QModelIndex)),
- this, SLOT(collapseChildren(QModelIndex)));
// Watchers
QTreeView *watchersView = qobject_cast<QTreeView *>(m_watchersWindow);
watchersView->setModel(m_watchHandler->model());
- connect(watchersView, SIGNAL(requestExpandChildren(QModelIndex)),
- this, SLOT(expandChildren(QModelIndex)));
- connect(watchersView, SIGNAL(requestCollapseChildren(QModelIndex)),
- this, SLOT(collapseChildren(QModelIndex)));
connect(m_watchHandler, SIGNAL(sessionValueRequested(QString,QVariant*)),
this, SIGNAL(sessionValueRequested(QString,QVariant*)));
connect(m_watchHandler, SIGNAL(setSessionValueRequested(QString,QVariant)),
@@ -718,18 +729,6 @@ void DebuggerManager::updateWatchModel()
m_engine->updateWatchModel();
}
-void DebuggerManager::expandChildren(const QModelIndex &idx)
-{
- QTC_ASSERT(m_watchHandler, return);
- m_watchHandler->expandChildren(idx);
-}
-
-void DebuggerManager::collapseChildren(const QModelIndex &idx)
-{
- QTC_ASSERT(m_watchHandler, return);
- m_watchHandler->collapseChildren(idx);
-}
-
QVariant DebuggerManager::sessionValue(const QString &name)
{
// this is answered by the plugin
@@ -1153,13 +1152,16 @@ static bool isAllowedTransition(int from, int to)
void DebuggerManager::setStatus(int status)
{
if (Debugger::Constants::Internal::debug)
- qDebug() << Q_FUNC_INFO << "STATUS CHANGE: from" << m_status << "to" << status;
+ qDebug() << Q_FUNC_INFO << "STATUS CHANGE: from" << stateName(m_status) << "to" << stateName(status);
if (status == m_status)
return;
- if (!isAllowedTransition(m_status, status))
- qDebug() << "UNEXPECTED TRANSITION: " << m_status << status;
+ if (!isAllowedTransition(m_status, status)) {
+ const QString msg = QString::fromLatin1("%1: UNEXPECTED TRANSITION: %2 -> %3").
+ arg(QLatin1String(Q_FUNC_INFO), QLatin1String(stateName(m_status)), QLatin1String(stateName(status)));
+ qWarning("%s", qPrintable(msg));
+ }
m_status = status;
diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h
index 77e629e38e..414ef42963 100644
--- a/src/plugins/debugger/debuggermanager.h
+++ b/src/plugins/debugger/debuggermanager.h
@@ -231,8 +231,6 @@ public slots:
void addToWatchWindow();
void updateWatchModel();
- void expandChildren(const QModelIndex &idx);
- void collapseChildren(const QModelIndex &idx);
void sessionLoaded();
void aboutToSaveSession();
diff --git a/src/plugins/debugger/debuggeroutputwindow.cpp b/src/plugins/debugger/debuggeroutputwindow.cpp
index 74d8e8bb5e..3779921535 100644
--- a/src/plugins/debugger/debuggeroutputwindow.cpp
+++ b/src/plugins/debugger/debuggeroutputwindow.cpp
@@ -28,6 +28,7 @@
**************************************************************************/
#include "debuggeroutputwindow.h"
+#include "debuggeractions.h"
#include <QtCore/QDebug>
@@ -51,7 +52,7 @@ using namespace Find;
#endif // GDBDEBUGGERLEAN
-using Debugger::Internal::DebuggerOutputWindow;
+using namespace Debugger::Internal;
/////////////////////////////////////////////////////////////////////
//
@@ -83,6 +84,8 @@ public:
menu->addAction(m_clearContentsAction);
//menu->addAction(m_saveContentsAction);
addContextActions(menu);
+ menu->addSeparator();
+ menu->addAction(theDebuggerAction(SettingsDialog));
menu->exec(ev->globalPos());
delete menu;
}
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index 2a66c1422e..cc3c0f01d7 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -278,7 +278,7 @@ QWidget *GdbOptionPage::createPage(QWidget *parent)
->connectWidget(m_ui.scriptFileChooser);
theDebuggerAction(GdbEnvironment)
->connectWidget(m_ui.environmentEdit);
- theDebuggerAction(Terminal)
+ theDebuggerAction(TerminalApplication)
->connectWidget(m_ui.terminalChooser);
theDebuggerAction(AllPluginBreakpoints)
@@ -319,7 +319,7 @@ void GdbOptionPage::apply()
theDebuggerAction(GdbLocation)->apply(s);
theDebuggerAction(GdbScriptFile)->apply(s);
theDebuggerAction(GdbEnvironment)->apply(s);
- theDebuggerAction(Terminal)->apply(s);
+ theDebuggerAction(TerminalApplication)->apply(s);
theDebuggerAction(AllPluginBreakpoints)->apply(s);
theDebuggerAction(SelectedPluginBreakpoints)->apply(s);
diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp
index 535276b326..b85b74e6c5 100644
--- a/src/plugins/debugger/gdbengine.cpp
+++ b/src/plugins/debugger/gdbengine.cpp
@@ -29,6 +29,7 @@
#include "gdbengine.h"
+#include "watchutils.h"
#include "debuggeractions.h"
#include "debuggerconstants.h"
#include "debuggermanager.h"
@@ -152,88 +153,12 @@ enum GdbCommandType
WatchDumpCustomEditValue,
};
-QString dotEscape(QString str)
-{
- str.replace(' ', '.');
- str.replace('\\', '.');
- str.replace('/', '.');
- return str;
-}
-
-QString currentTime()
-{
- return QTime::currentTime().toString("hh:mm:ss.zzz");
-}
-
static int &currentToken()
{
static int token = 0;
return token;
}
-static bool isSkippableFunction(const QString &funcName, const QString &fileName)
-{
- if (fileName.endsWith("kernel/qobject.cpp"))
- return true;
- if (fileName.endsWith("kernel/moc_qobject.cpp"))
- return true;
- if (fileName.endsWith("kernel/qmetaobject.cpp"))
- return true;
- if (fileName.endsWith(".moc"))
- return true;
-
- if (funcName.endsWith("::qt_metacall"))
- return true;
-
- return false;
-}
-
-static bool isLeavableFunction(const QString &funcName, const QString &fileName)
-{
- if (funcName.endsWith("QObjectPrivate::setCurrentSender"))
- return true;
- if (fileName.endsWith("kernel/qmetaobject.cpp")
- && funcName.endsWith("QMetaObject::methodOffset"))
- return true;
- if (fileName.endsWith("kernel/qobject.h"))
- return true;
- if (fileName.endsWith("kernel/qobject.cpp")
- && funcName.endsWith("QObjectConnectionListVector::at"))
- return true;
- if (fileName.endsWith("kernel/qobject.cpp")
- && funcName.endsWith("~QObject"))
- return true;
- if (fileName.endsWith("thread/qmutex.cpp"))
- return true;
- if (fileName.endsWith("thread/qthread.cpp"))
- return true;
- if (fileName.endsWith("thread/qthread_unix.cpp"))
- return true;
- if (fileName.endsWith("thread/qmutex.h"))
- return true;
- if (fileName.contains("thread/qbasicatomic"))
- return true;
- if (fileName.contains("thread/qorderedmutexlocker_p"))
- return true;
- if (fileName.contains("arch/qatomic"))
- return true;
- if (fileName.endsWith("tools/qvector.h"))
- return true;
- if (fileName.endsWith("tools/qlist.h"))
- return true;
- if (fileName.endsWith("tools/qhash.h"))
- return true;
- if (fileName.endsWith("tools/qmap.h"))
- return true;
- if (fileName.endsWith("tools/qstring.h"))
- return true;
- if (fileName.endsWith("global/qglobal.h"))
- return true;
-
- return false;
-}
-
-
///////////////////////////////////////////////////////////////////////
//
// GdbEngine
@@ -291,6 +216,19 @@ void GdbEngine::initializeConnections()
this, SLOT(setDebugDumpers(bool)));
connect(theDebuggerAction(RecheckDumpers), SIGNAL(triggered()),
this, SLOT(recheckCustomDumperAvailability()));
+
+ connect(theDebuggerAction(FormatHexadecimal), SIGNAL(triggered()),
+ this, SLOT(reloadRegisters()));
+ connect(theDebuggerAction(FormatDecimal), SIGNAL(triggered()),
+ this, SLOT(reloadRegisters()));
+ connect(theDebuggerAction(FormatOctal), SIGNAL(triggered()),
+ this, SLOT(reloadRegisters()));
+ connect(theDebuggerAction(FormatBinary), SIGNAL(triggered()),
+ this, SLOT(reloadRegisters()));
+ connect(theDebuggerAction(FormatRaw), SIGNAL(triggered()),
+ this, SLOT(reloadRegisters()));
+ connect(theDebuggerAction(FormatNatural), SIGNAL(triggered()),
+ this, SLOT(reloadRegisters()));
}
void GdbEngine::initializeVariables()
@@ -351,12 +289,6 @@ void GdbEngine::gdbProcError(QProcess::ProcessError error)
q->exitDebugger();
}
-static inline bool isNameChar(char c)
-{
- // could be 'stopped' or 'shlibs-added'
- return (c >= 'a' && c <= 'z') || c == '-';
-}
-
#if 0
static void dump(const char *first, const char *middle, const QString & to)
{
@@ -497,7 +429,7 @@ void GdbEngine::handleResponse(const QByteArray &buff)
// On Windows, the contents seem to depend on the debugger
// version and/or OS version used.
if (data.startsWith("warning:"))
- qq->showApplicationOutput(data);
+ qq->showApplicationOutput(data.mid(9)); // cut "warning: "
break;
}
@@ -1562,7 +1494,6 @@ int GdbEngine::currentFrame() const
return qq->stackHandler()->currentIndex();
}
-
bool GdbEngine::startDebugger()
{
debugMessage(theDebuggerSettings()->dump());
@@ -2656,7 +2587,19 @@ void GdbEngine::handleStackListThreads(const GdbResultRecord &record, int id)
void GdbEngine::reloadRegisters()
{
- QString format = qq->registerHandler()->model()->property(PROPERTY_REGISTER_FORMAT).toString();
+ QString format;
+ if (theDebuggerAction(FormatHexadecimal)->isChecked())
+ format = "x";
+ else if (theDebuggerAction(FormatDecimal)->isChecked())
+ format = "d";
+ else if (theDebuggerAction(FormatOctal)->isChecked())
+ format = "o";
+ else if (theDebuggerAction(FormatBinary)->isChecked())
+ format = "t";
+ else if (theDebuggerAction(FormatRaw)->isChecked())
+ format = "r";
+ else
+ format = "N";
sendCommand("-data-list-register-values " + format, RegisterListValues);
}
@@ -2718,43 +2661,6 @@ static QString m_toolTipExpression;
static QPoint m_toolTipPos;
static QMap<QString, WatchData> m_toolTipCache;
-static bool hasLetterOrNumber(const QString &exp)
-{
- for (int i = exp.size(); --i >= 0; )
- if (exp[i].isLetterOrNumber() || exp[i] == '_')
- return true;
- return false;
-}
-
-static bool hasSideEffects(const QString &exp)
-{
- // FIXME: complete?
- return exp.contains("-=")
- || exp.contains("+=")
- || exp.contains("/=")
- || exp.contains("*=")
- || exp.contains("&=")
- || exp.contains("|=")
- || exp.contains("^=")
- || exp.contains("--")
- || exp.contains("++");
-}
-
-static bool isKeyWord(const QString &exp)
-{
- // FIXME: incomplete
- return exp == QLatin1String("class")
- || exp == QLatin1String("const")
- || exp == QLatin1String("do")
- || exp == QLatin1String("if")
- || exp == QLatin1String("return")
- || exp == QLatin1String("struct")
- || exp == QLatin1String("template")
- || exp == QLatin1String("void")
- || exp == QLatin1String("volatile")
- || exp == QLatin1String("while");
-}
-
void GdbEngine::setToolTipExpression(const QPoint &pos, const QString &exp0)
{
//qDebug() << "SET TOOLTIP EXP" << pos << exp0;
@@ -2861,85 +2767,6 @@ void GdbEngine::setToolTipExpression(const QPoint &pos, const QString &exp0)
static const QString strNotInScope = QLatin1String("<not in scope>");
-static bool isPointerType(const QString &type)
-{
- return type.endsWith("*") || type.endsWith("* const");
-}
-
-static bool isAccessSpecifier(const QString &str)
-{
- static const QStringList items =
- QStringList() << "private" << "protected" << "public";
- return items.contains(str);
-}
-
-static bool startsWithDigit(const QString &str)
-{
- return !str.isEmpty() && str[0] >= '0' && str[0] <= '9';
-}
-
-QString stripPointerType(QString type)
-{
- if (type.endsWith("*"))
- type.chop(1);
- if (type.endsWith("* const"))
- type.chop(7);
- if (type.endsWith(' '))
- type.chop(1);
- return type;
-}
-
-static QString gdbQuoteTypes(const QString &type)
-{
- // gdb does not understand sizeof(Core::IFile*).
- // "sizeof('Core::IFile*')" is also not acceptable,
- // it needs to be "sizeof('Core::IFile'*)"
- //
- // We never will have a perfect solution here (even if we had a full blown
- // C++ parser as we do not have information on what is a type and what is
- // a variable name. So "a<b>::c" could either be two comparisons of values
- // 'a', 'b' and '::c', or a nested type 'c' in a template 'a<b>'. We
- // assume here it is the latter.
- //return type;
-
- // (*('myns::QPointer<myns::QObject>*'*)0x684060)" is not acceptable
- // (*('myns::QPointer<myns::QObject>'**)0x684060)" is acceptable
- if (isPointerType(type))
- return gdbQuoteTypes(stripPointerType(type)) + "*";
-
- QString accu;
- QString result;
- int templateLevel = 0;
- for (int i = 0; i != type.size(); ++i) {
- QChar c = type.at(i);
- if (c.isLetterOrNumber() || c == '_' || c == ':' || c == ' ') {
- accu += c;
- } else if (c == '<') {
- ++templateLevel;
- accu += c;
- } else if (c == '<') {
- --templateLevel;
- accu += c;
- } else if (templateLevel > 0) {
- accu += c;
- } else {
- if (accu.contains(':') || accu.contains('<'))
- result += '\'' + accu + '\'';
- else
- result += accu;
- accu.clear();
- result += c;
- }
- }
- if (accu.contains(':') || accu.contains('<'))
- result += '\'' + accu + '\'';
- else
- result += accu;
- //qDebug() << "GDB_QUOTING" << type << " TO " << result;
-
- return result;
-}
-
static void setWatchDataValue(WatchData &data, const GdbMi &mi,
int encoding = 0)
{
@@ -3023,68 +2850,6 @@ static void setWatchDataSAddress(WatchData &data, const GdbMi &mi)
data.saddr = mi.data();
}
-static bool extractTemplate(const QString &type, QString *tmplate, QString *inner)
-{
- // Input "Template<Inner1,Inner2,...>::Foo" will return "Template::Foo" in
- // 'tmplate' and "Inner1@Inner2@..." etc in 'inner'. Result indicates
- // whether parsing was successful
- int level = 0;
- bool skipSpace = false;
- for (int i = 0; i != type.size(); ++i) {
- QChar c = type[i];
- if (c == ' ' && skipSpace) {
- skipSpace = false;
- } else if (c == '<') {
- *(level == 0 ? tmplate : inner) += c;
- ++level;
- } else if (c == '>') {
- --level;
- *(level == 0 ? tmplate : inner) += c;
- } else if (c == ',') {
- *inner += (level == 1) ? '@' : ',';
- skipSpace = true;
- } else {
- *(level == 0 ? tmplate : inner) += c;
- }
- }
- *tmplate = tmplate->trimmed();
- *tmplate = tmplate->remove("<>");
- *inner = inner->trimmed();
- //qDebug() << "EXTRACT TEMPLATE: " << *tmplate << *inner << " FROM " << type;
- return !inner->isEmpty();
-}
-
-static QString extractTypeFromPTypeOutput(const QString &str)
-{
- int pos0 = str.indexOf('=');
- int pos1 = str.indexOf('{');
- int pos2 = str.lastIndexOf('}');
- QString res = str;
- if (pos0 != -1 && pos1 != -1 && pos2 != -1)
- res = str.mid(pos0 + 2, pos1 - 1 - pos0)
- + " ... " + str.right(str.size() - pos2);
- return res.simplified();
-}
-
-static bool isIntOrFloatType(const QString &type)
-{
- static const QStringList types = QStringList()
- << "char" << "int" << "short" << "float" << "double" << "long"
- << "bool" << "signed char" << "unsigned" << "unsigned char"
- << "unsigned int" << "unsigned long" << "long long"
- << "unsigned long long";
- return types.contains(type);
-}
-
-static QString sizeofTypeExpression(const QString &type)
-{
- if (type.endsWith('*'))
- return "sizeof(void*)";
- if (type.endsWith('>'))
- return "sizeof(" + type + ")";
- return "sizeof(" + gdbQuoteTypes(type) + ")";
-}
-
void GdbEngine::setUseDumpers(bool on)
{
qDebug() << "SWITCHING ON/OFF DUMPER DEBUGGING:" << on;
@@ -4304,4 +4069,3 @@ IDebuggerEngine *createGdbEngine(DebuggerManager *parent)
{
return new GdbEngine(parent);
}
-
diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h
index 20c9c22287..d35f0f0827 100644
--- a/src/plugins/debugger/gdbengine.h
+++ b/src/plugins/debugger/gdbengine.h
@@ -265,7 +265,7 @@ private:
//
// Register specific stuff
//
- void reloadRegisters();
+ Q_SLOT void reloadRegisters();
void handleRegisterListNames(const GdbResultRecord &record);
void handleRegisterListValues(const GdbResultRecord &record);
diff --git a/src/plugins/debugger/registerhandler.cpp b/src/plugins/debugger/registerhandler.cpp
index 70bae1b2b3..12dd1d2131 100644
--- a/src/plugins/debugger/registerhandler.cpp
+++ b/src/plugins/debugger/registerhandler.cpp
@@ -51,9 +51,7 @@ using namespace Debugger::Constants;
RegisterHandler::RegisterHandler(QObject *parent)
: QAbstractTableModel(parent)
-{
- setProperty(PROPERTY_REGISTER_FORMAT, "x");
-}
+{}
int RegisterHandler::rowCount(const QModelIndex &parent) const
{
diff --git a/src/plugins/debugger/registerwindow.cpp b/src/plugins/debugger/registerwindow.cpp
index e83a3abb05..03239d8875 100644
--- a/src/plugins/debugger/registerwindow.cpp
+++ b/src/plugins/debugger/registerwindow.cpp
@@ -29,17 +29,19 @@
#include "registerwindow.h"
+#include "debuggeractions.h"
#include "debuggerconstants.h"
-#include <QAction>
-#include <QDebug>
-#include <QDir>
-#include <QFileInfo>
-#include <QFileInfoList>
-#include <QHeaderView>
-#include <QMenu>
-#include <QResizeEvent>
-#include <QToolButton>
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
+#include <QtCore/QFileInfoList>
+
+#include <QtGui/QAction>
+#include <QtGui/QHeaderView>
+#include <QtGui/QMenu>
+#include <QtGui/QResizeEvent>
+#include <QtGui/QToolButton>
using namespace Debugger::Internal;
@@ -72,14 +74,12 @@ void RegisterWindow::resizeEvent(QResizeEvent *ev)
void RegisterWindow::contextMenuEvent(QContextMenuEvent *ev)
{
- enum { Hex, Bin, Dec, Raw, Oct, Nat,
- Adjust, AlwaysAdjust, Reload, AlwaysReload, Count };
+ enum { Adjust, AlwaysAdjust, Reload, AlwaysReload, Count };
QMenu menu;
QAction *actions[Count];
- //QTreeWidgetItem *item = itemAt(ev->pos());
- QString format = model()->property(PROPERTY_REGISTER_FORMAT).toString();
- qDebug() << "FORMAT: " << format;
+ //QString format = model()->property(PROPERTY_REGISTER_FORMAT).toString();
+ //qDebug() << "FORMAT: " << format;
actions[Adjust] = menu.addAction("Adjust column widths to contents");
@@ -94,30 +94,15 @@ void RegisterWindow::contextMenuEvent(QContextMenuEvent *ev)
actions[AlwaysReload]->setChecked(m_alwaysReloadContents);
menu.addSeparator();
+ menu.addAction(theDebuggerAction(FormatHexadecimal));
+ menu.addAction(theDebuggerAction(FormatDecimal));
+ menu.addAction(theDebuggerAction(FormatOctal));
+ menu.addAction(theDebuggerAction(FormatBinary));
+ menu.addAction(theDebuggerAction(FormatRaw));
+ menu.addAction(theDebuggerAction(FormatNatural));
- actions[Hex] = menu.addAction("Hexadecimal");
- actions[Hex]->setCheckable(true);
- actions[Hex]->setChecked(format == "h");
-
- actions[Bin] = menu.addAction("Binary");
- actions[Bin]->setCheckable(true);
- actions[Bin]->setChecked(format == "t");
-
- actions[Dec] = menu.addAction("Decimal");
- actions[Dec]->setCheckable(true);
- actions[Dec]->setChecked(format == "d");
-
- actions[Raw] = menu.addAction("Raw");
- actions[Raw]->setCheckable(true);
- actions[Raw]->setChecked(format == "r");
-
- actions[Nat] = menu.addAction("Natural");
- actions[Nat]->setCheckable(true);
- actions[Nat]->setChecked(format == "N");
-
- actions[Oct] = menu.addAction("Octal");
- actions[Oct]->setCheckable(true);
- actions[Oct]->setChecked(format == "o");
+ menu.addSeparator();
+ menu.addAction(theDebuggerAction(SettingsDialog));
QAction *act = menu.exec(ev->globalPos());
@@ -129,17 +114,6 @@ void RegisterWindow::contextMenuEvent(QContextMenuEvent *ev)
reloadContents();
else if (act == actions[AlwaysReload])
setAlwaysReloadContents(!m_alwaysReloadContents);
- else if (act == actions[Hex])
- model()->setProperty(PROPERTY_REGISTER_FORMAT, "h");
- else if (act == actions[Oct])
- model()->setProperty(PROPERTY_REGISTER_FORMAT, "o");
- else if (act == actions[Bin])
- model()->setProperty(PROPERTY_REGISTER_FORMAT, "t");
- else if (act == actions[Dec])
- model()->setProperty(PROPERTY_REGISTER_FORMAT, "d");
- else if (act == actions[Nat])
- model()->setProperty(PROPERTY_REGISTER_FORMAT, "N");
-
}
void RegisterWindow::resizeColumnsToContents()
diff --git a/src/plugins/debugger/sourcefileswindow.cpp b/src/plugins/debugger/sourcefileswindow.cpp
index 1f90bc0d81..7b927cd4de 100644
--- a/src/plugins/debugger/sourcefileswindow.cpp
+++ b/src/plugins/debugger/sourcefileswindow.cpp
@@ -28,18 +28,19 @@
**************************************************************************/
#include "sourcefileswindow.h"
+#include "debuggeractions.h"
-#include <QDebug>
-#include <QAction>
-#include <QComboBox>
-#include <QFileInfo>
-#include <QDebug>
-#include <QHeaderView>
-#include <QMenu>
-#include <QResizeEvent>
-#include <QTreeView>
-#include <QSortFilterProxyModel>
-#include <QVBoxLayout>
+#include <QtCore/QDebug>
+#include <QtCore/QFileInfo>
+
+#include <QtGui/QAction>
+#include <QtGui/QComboBox>
+#include <QtGui/QHeaderView>
+#include <QtGui/QMenu>
+#include <QtGui/QResizeEvent>
+#include <QtGui/QSortFilterProxyModel>
+#include <QtGui/QTreeView>
+#include <QtGui/QVBoxLayout>
using Debugger::Internal::SourceFilesWindow;
using Debugger::Internal::SourceFilesModel;
@@ -205,6 +206,8 @@ void SourceFilesWindow::contextMenuEvent(QContextMenuEvent *ev)
menu.addAction(act1);
menu.addAction(act2);
+ menu.addSeparator();
+ menu.addAction(theDebuggerAction(SettingsDialog));
QAction *act = menu.exec(ev->globalPos());
diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp
index cfe0eb5338..e8bb8d5fe5 100644
--- a/src/plugins/debugger/watchhandler.cpp
+++ b/src/plugins/debugger/watchhandler.cpp
@@ -370,9 +370,12 @@ WatchHandler::WatchHandler()
connect(theDebuggerAction(WatchExpression),
SIGNAL(triggered()), this, SLOT(watchExpression()));
-
connect(theDebuggerAction(RemoveWatchExpression),
SIGNAL(triggered()), this, SLOT(removeWatchExpression()));
+ connect(theDebuggerAction(ExpandItem),
+ SIGNAL(triggered()), this, SLOT(expandChildren()));
+ connect(theDebuggerAction(CollapseItem),
+ SIGNAL(triggered()), this, SLOT(collapseChildren()));
}
static QString niceType(QString type)
@@ -748,7 +751,8 @@ void WatchHandler::rebuildModel()
m_inChange = true;
//qDebug() << "WATCHHANDLER: RESET ABOUT TO EMIT";
- emit reset();
+ //emit reset();
+ emit layoutChanged();
//qDebug() << "WATCHHANDLER: RESET EMITTED";
m_inChange = false;
@@ -785,15 +789,19 @@ void WatchHandler::cleanup()
emit reset();
}
-void WatchHandler::collapseChildren(const QModelIndex &idx)
+void WatchHandler::collapseChildren()
+{
+ if (QAction *act = qobject_cast<QAction *>(sender()))
+ collapseChildren(act->data().toString());
+}
+
+void WatchHandler::collapseChildren(const QString &iname)
{
if (m_inChange || m_completeSet.isEmpty()) {
- qDebug() << "WATCHHANDLER: COLLAPSE IGNORED" << idx;
+ qDebug() << "WATCHHANDLER: COLLAPSE IGNORED" << iname;
return;
}
- QTC_ASSERT(checkIndex(idx.internalId()), return);
- QString iname0 = m_displaySet.at(idx.internalId()).iname;
- MODEL_DEBUG("COLLAPSE NODE" << iname0);
+ MODEL_DEBUG("COLLAPSE NODE" << iname);
#if 0
QString iname1 = iname0 + '.';
for (int i = m_completeSet.size(); --i >= 0; ) {
@@ -806,19 +814,32 @@ void WatchHandler::collapseChildren(const QModelIndex &idx)
}
}
#endif
- m_expandedINames.remove(iname0);
+ m_expandedINames.remove(iname);
//MODEL_DEBUG(toString());
//rebuildModel();
}
-void WatchHandler::expandChildren(const QModelIndex &idx)
+void WatchHandler::expandChildren()
+{
+ if (QAction *act = qobject_cast<QAction *>(sender()))
+ expandChildren(act->data().toString());
+}
+
+void WatchHandler::expandChildren(const QString &iname)
{
if (m_inChange || m_completeSet.isEmpty()) {
- //qDebug() << "WATCHHANDLER: EXPAND IGNORED" << idx;
+ //qDebug() << "WATCHHANDLER: EXPAND IGNORED" << iname;
return;
}
- int index = idx.internalId();
- if (index == 0)
+ int index = -1;
+ for (int i = 0; i != m_displaySet.size(); ++i) {
+ if (m_displaySet.at(i).iname == iname) {
+ index = i;
+ break;
+ }
+ }
+
+ if (index == -1)
return;
QTC_ASSERT(index >= 0, qDebug() << toString() << index; return);
QTC_ASSERT(index < m_completeSet.size(), qDebug() << toString() << index; return);
@@ -832,8 +853,7 @@ void WatchHandler::expandChildren(const QModelIndex &idx)
// "expand()" signals folr the root item from time to time.
// Try to handle that gracfully.
//MODEL_DEBUG(toString());
- qDebug() << "FIXME: expandChildren, no data " << display.iname << "found"
- << idx;
+ qDebug() << "FIXME: expandChildren, no data " << display.iname << "found";
//rebuildModel();
return;
}
diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h
index a419203815..6701eecda3 100644
--- a/src/plugins/debugger/watchhandler.h
+++ b/src/plugins/debugger/watchhandler.h
@@ -165,8 +165,10 @@ public:
Q_SLOT void removeWatchExpression(const QString &exp);
void reinitializeWatchers();
- void collapseChildren(const QModelIndex &idx);
- void expandChildren(const QModelIndex &idx);
+ Q_SLOT void collapseChildren();
+ Q_SLOT void expandChildren();
+ Q_SLOT void collapseChildren(const QString &iname);
+ Q_SLOT void expandChildren(const QString &iname);
void rebuildModel(); // unconditionally version of above
void showEditValue(const WatchData &data);
diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp
new file mode 100644
index 0000000000..c679857ab8
--- /dev/null
+++ b/src/plugins/debugger/watchutils.cpp
@@ -0,0 +1,303 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+**
+**************************************************************************/
+
+#include "watchutils.h"
+
+#include <QtCore/QDebug>
+#include <QtCore/QTime>
+#include <QtCore/QStringList>
+
+namespace Debugger {
+namespace Internal {
+
+QString dotEscape(QString str)
+{
+ const QChar dot = QLatin1Char(',');
+ str.replace(QLatin1Char(' '), dot);
+ str.replace(QLatin1Char('\\'), dot);
+ str.replace(QLatin1Char('/'), dot);
+ return str;
+}
+
+QString currentTime()
+{
+ return QTime::currentTime().toString(QLatin1String("hh:mm:ss.zzz"));
+}
+
+bool isSkippableFunction(const QString &funcName, const QString &fileName)
+{
+ if (fileName.endsWith(QLatin1String("kernel/qobject.cpp")))
+ return true;
+ if (fileName.endsWith(QLatin1String("kernel/moc_qobject.cpp")))
+ return true;
+ if (fileName.endsWith(QLatin1String("kernel/qmetaobject.cpp")))
+ return true;
+ if (fileName.endsWith(QLatin1String(".moc")))
+ return true;
+
+ if (funcName.endsWith("::qt_metacall"))
+ return true;
+
+ return false;
+}
+
+bool isLeavableFunction(const QString &funcName, const QString &fileName)
+{
+ if (funcName.endsWith(QLatin1String("QObjectPrivate::setCurrentSender")))
+ return true;
+ if (fileName.endsWith(QLatin1String("kernel/qmetaobject.cpp"))
+ && funcName.endsWith(QLatin1String("QMetaObject::methodOffset")))
+ return true;
+ if (fileName.endsWith(QLatin1String("kernel/qobject.h")))
+ return true;
+ if (fileName.endsWith(QLatin1String("kernel/qobject.cpp"))
+ && funcName.endsWith(QLatin1String("QObjectConnectionListVector::at")))
+ return true;
+ if (fileName.endsWith(QLatin1String("kernel/qobject.cpp"))
+ && funcName.endsWith(QLatin1String("~QObject")))
+ return true;
+ if (fileName.endsWith(QLatin1String("thread/qmutex.cpp")))
+ return true;
+ if (fileName.endsWith(QLatin1String("thread/qthread.cpp")))
+ return true;
+ if (fileName.endsWith(QLatin1String("thread/qthread_unix.cpp")))
+ return true;
+ if (fileName.endsWith(QLatin1String("thread/qmutex.h")))
+ return true;
+ if (fileName.contains(QLatin1String("thread/qbasicatomic")))
+ return true;
+ if (fileName.contains(QLatin1String("thread/qorderedmutexlocker_p")))
+ return true;
+ if (fileName.contains(QLatin1String("arch/qatomic")))
+ return true;
+ if (fileName.endsWith(QLatin1String("tools/qvector.h")))
+ return true;
+ if (fileName.endsWith(QLatin1String("tools/qlist.h")))
+ return true;
+ if (fileName.endsWith(QLatin1String("tools/qhash.h")))
+ return true;
+ if (fileName.endsWith(QLatin1String("tools/qmap.h")))
+ return true;
+ if (fileName.endsWith(QLatin1String("tools/qstring.h")))
+ return true;
+ if (fileName.endsWith(QLatin1String("global/qglobal.h")))
+ return true;
+
+ return false;
+}
+
+bool hasLetterOrNumber(const QString &exp)
+{
+ const QChar underscore = QLatin1Char('_');
+ for (int i = exp.size(); --i >= 0; )
+ if (exp.at(i).isLetterOrNumber() || exp.at(i) == underscore)
+ return true;
+ return false;
+}
+
+bool hasSideEffects(const QString &exp)
+{
+ // FIXME: complete?
+ return exp.contains(QLatin1String("-="))
+ || exp.contains(QLatin1String("+="))
+ || exp.contains(QLatin1String("/="))
+ || exp.contains(QLatin1String("*="))
+ || exp.contains(QLatin1String("&="))
+ || exp.contains(QLatin1String("|="))
+ || exp.contains(QLatin1String("^="))
+ || exp.contains(QLatin1String("--"))
+ || exp.contains(QLatin1String("++"));
+}
+
+bool isKeyWord(const QString &exp)
+{
+ // FIXME: incomplete
+ return exp == QLatin1String("class")
+ || exp == QLatin1String("const")
+ || exp == QLatin1String("do")
+ || exp == QLatin1String("if")
+ || exp == QLatin1String("return")
+ || exp == QLatin1String("struct")
+ || exp == QLatin1String("template")
+ || exp == QLatin1String("void")
+ || exp == QLatin1String("volatile")
+ || exp == QLatin1String("while");
+}
+
+bool isPointerType(const QString &type)
+{
+ return type.endsWith(QLatin1Char('*')) || type.endsWith(QLatin1String("* const"));
+}
+
+bool isAccessSpecifier(const QString &str)
+{
+ static const QStringList items =
+ QStringList() << QLatin1String("private") << QLatin1String("protected") << QLatin1String("public");
+ return items.contains(str);
+}
+
+bool startsWithDigit(const QString &str)
+{
+ return !str.isEmpty() && str.at(0).isDigit();
+}
+
+QString stripPointerType(QString type)
+{
+ if (type.endsWith(QLatin1Char('*')))
+ type.chop(1);
+ if (type.endsWith(QLatin1String("* const")))
+ type.chop(7);
+ if (type.endsWith(QLatin1Char(' ')))
+ type.chop(1);
+ return type;
+}
+
+QString gdbQuoteTypes(const QString &type)
+{
+ // gdb does not understand sizeof(Core::IFile*).
+ // "sizeof('Core::IFile*')" is also not acceptable,
+ // it needs to be "sizeof('Core::IFile'*)"
+ //
+ // We never will have a perfect solution here (even if we had a full blown
+ // C++ parser as we do not have information on what is a type and what is
+ // a variable name. So "a<b>::c" could either be two comparisons of values
+ // 'a', 'b' and '::c', or a nested type 'c' in a template 'a<b>'. We
+ // assume here it is the latter.
+ //return type;
+
+ // (*('myns::QPointer<myns::QObject>*'*)0x684060)" is not acceptable
+ // (*('myns::QPointer<myns::QObject>'**)0x684060)" is acceptable
+ if (isPointerType(type))
+ return gdbQuoteTypes(stripPointerType(type)) + QLatin1Char('*');
+
+ QString accu;
+ QString result;
+ int templateLevel = 0;
+
+ const QChar colon = QLatin1Char(':');
+ const QChar singleQuote = QLatin1Char('\'');
+ const QChar lessThan = QLatin1Char('<');
+ const QChar greaterThan = QLatin1Char('>');
+ for (int i = 0; i != type.size(); ++i) {
+ const QChar c = type.at(i);
+ if (c.isLetterOrNumber() || c == QLatin1Char('_') || c == colon || c == QLatin1Char(' ')) {
+ accu += c;
+ } else if (c == lessThan) {
+ ++templateLevel;
+ accu += c;
+ } else if (c == greaterThan) {
+ --templateLevel;
+ accu += c;
+ } else if (templateLevel > 0) {
+ accu += c;
+ } else {
+ if (accu.contains(colon) || accu.contains(lessThan))
+ result += singleQuote + accu + singleQuote;
+ else
+ result += accu;
+ accu.clear();
+ result += c;
+ }
+ }
+ if (accu.contains(colon) || accu.contains(lessThan))
+ result += singleQuote + accu + singleQuote;
+ else
+ result += accu;
+ //qDebug() << "GDB_QUOTING" << type << " TO " << result;
+
+ return result;
+}
+
+bool extractTemplate(const QString &type, QString *tmplate, QString *inner)
+{
+ // Input "Template<Inner1,Inner2,...>::Foo" will return "Template::Foo" in
+ // 'tmplate' and "Inner1@Inner2@..." etc in 'inner'. Result indicates
+ // whether parsing was successful
+ int level = 0;
+ bool skipSpace = false;
+
+ for (int i = 0; i != type.size(); ++i) {
+ const QChar c = type.at(i);
+ if (c == QLatin1Char(' ') && skipSpace) {
+ skipSpace = false;
+ } else if (c == QLatin1Char('<')) {
+ *(level == 0 ? tmplate : inner) += c;
+ ++level;
+ } else if (c == QLatin1Char('>')) {
+ --level;
+ *(level == 0 ? tmplate : inner) += c;
+ } else if (c == QLatin1Char(',')) {
+ *inner += (level == 1) ? QLatin1Char('@') : QLatin1Char(',');
+ skipSpace = true;
+ } else {
+ *(level == 0 ? tmplate : inner) += c;
+ }
+ }
+ *tmplate = tmplate->trimmed();
+ *tmplate = tmplate->remove(QLatin1String("<>"));
+ *inner = inner->trimmed();
+ //qDebug() << "EXTRACT TEMPLATE: " << *tmplate << *inner << " FROM " << type;
+ return !inner->isEmpty();
+}
+
+QString extractTypeFromPTypeOutput(const QString &str)
+{
+ int pos0 = str.indexOf(QLatin1Char('='));
+ int pos1 = str.indexOf(QLatin1Char('{'));
+ int pos2 = str.lastIndexOf(QLatin1Char('}'));
+ QString res = str;
+ if (pos0 != -1 && pos1 != -1 && pos2 != -1)
+ res = str.mid(pos0 + 2, pos1 - 1 - pos0)
+ + QLatin1String(" ... ") + str.right(str.size() - pos2);
+ return res.simplified();
+}
+
+bool isIntOrFloatType(const QString &type)
+{
+ static const QStringList types = QStringList()
+ << QLatin1String("char") << QLatin1String("int") << QLatin1String("short")
+ << QLatin1String("float") << QLatin1String("double") << QLatin1String("long")
+ << QLatin1String("bool") << QLatin1String("signed char") << QLatin1String("unsigned")
+ << QLatin1String("unsigned char")
+ << QLatin1String("unsigned int") << QLatin1String("unsigned long")
+ << QLatin1String("long long") << QLatin1String("unsigned long long");
+ return types.contains(type);
+}
+
+QString sizeofTypeExpression(const QString &type)
+{
+ if (type.endsWith(QLatin1Char('*')))
+ return QLatin1String("sizeof(void*)");
+ if (type.endsWith(QLatin1Char('>')))
+ return QLatin1String("sizeof(") + type + QLatin1Char(')');
+ return QLatin1String("sizeof(") + gdbQuoteTypes(type) + QLatin1Char(')');
+}
+
+}
+}
diff --git a/src/plugins/debugger/watchutils.h b/src/plugins/debugger/watchutils.h
new file mode 100644
index 0000000000..6c7dbb9143
--- /dev/null
+++ b/src/plugins/debugger/watchutils.h
@@ -0,0 +1,70 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+**
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+**
+**************************************************************************/
+
+#ifndef WATCHUTILS_H
+#define WATCHUTILS_H
+
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+class QString;
+QT_END_NAMESPACE
+
+namespace Debugger {
+namespace Internal {
+
+QString dotEscape(QString str);
+QString currentTime();
+bool isSkippableFunction(const QString &funcName, const QString &fileName);
+bool isLeavableFunction(const QString &funcName, const QString &fileName);
+
+inline bool isNameChar(char c)
+{
+ // could be 'stopped' or 'shlibs-added'
+ return (c >= 'a' && c <= 'z') || c == '-';
+}
+
+bool hasLetterOrNumber(const QString &exp);
+bool hasSideEffects(const QString &exp);
+bool isKeyWord(const QString &exp);
+bool isPointerType(const QString &type);
+bool isAccessSpecifier(const QString &str);
+bool startsWithDigit(const QString &str);
+QString stripPointerType(QString type);
+QString gdbQuoteTypes(const QString &type);
+bool extractTemplate(const QString &type, QString *tmplate, QString *inner);
+QString extractTypeFromPTypeOutput(const QString &str);
+bool isIntOrFloatType(const QString &type);
+QString sizeofTypeExpression(const QString &type);
+
+
+} // namespace Internal
+} // namespace Debugger
+
+#endif // WATCHUTILS_H
diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp
index de30e8f380..e10d39319b 100644
--- a/src/plugins/debugger/watchwindow.cpp
+++ b/src/plugins/debugger/watchwindow.cpp
@@ -125,19 +125,16 @@ WatchWindow::WatchWindow(Type type, QWidget *parent)
void WatchWindow::expandNode(const QModelIndex &idx)
{
- //QModelIndex mi0 = idx.sibling(idx.row(), 0);
- //QString iname = model()->data(mi0, INameRole).toString();
- //QString name = model()->data(mi0, Qt::DisplayRole).toString();
- emit requestExpandChildren(idx);
+ QModelIndex mi0 = idx.sibling(idx.row(), 0);
+ QVariant iname = model()->data(mi0, INameRole);
+ theDebuggerAction(ExpandItem)->trigger(iname);
}
void WatchWindow::collapseNode(const QModelIndex &idx)
{
- //QModelIndex mi0 = idx.sibling(idx.row(), 0);
- //QString iname = model()->data(mi0, INameRole).toString();
- //QString name = model()->data(mi0, Qt::DisplayRole).toString();
- //qDebug() << "COLLAPSE NODE " << idx;
- emit requestCollapseChildren(idx);
+ QModelIndex mi0 = idx.sibling(idx.row(), 0);
+ QVariant iname = model()->data(mi0, INameRole);
+ theDebuggerAction(CollapseItem)->trigger(iname);
}
void WatchWindow::keyPressEvent(QKeyEvent *ev)
@@ -218,16 +215,13 @@ void WatchWindow::editItem(const QModelIndex &idx)
void WatchWindow::reset()
{
+ QTreeView::reset();
int row = 0;
if (m_type == TooltipType)
row = 1;
else if (m_type == WatchersType)
row = 2;
- //qDebug() << "WATCHWINDOW::RESET" << row;
- QTreeView::reset();
setRootIndex(model()->index(row, 0, model()->index(0, 0)));
- //setRootIndex(model()->index(0, 0));
- resetHelper(model()->index(0, 0));
}
void WatchWindow::setModel(QAbstractItemModel *model)
@@ -239,16 +233,27 @@ void WatchWindow::setModel(QAbstractItemModel *model)
header()->setResizeMode(QHeaderView::ResizeToContents);
if (m_type != LocalsType)
header()->hide();
+
+ connect(model, SIGNAL(layoutChanged()), this, SLOT(resetHelper()));
+}
+
+void WatchWindow::resetHelper()
+{
+ resetHelper(model()->index(0, 0));
}
void WatchWindow::resetHelper(const QModelIndex &idx)
{
if (model()->data(idx, ExpandedRole).toBool()) {
+ //qDebug() << "EXPANDING " << model()->data(idx, INameRole);
expand(idx);
for (int i = 0, n = model()->rowCount(idx); i != n; ++i) {
QModelIndex idx1 = model()->index(i, 0, idx);
resetHelper(idx1);
}
+ } else {
+ //qDebug() << "COLLAPSING " << model()->data(idx, INameRole);
+ collapse(idx);
}
}
diff --git a/src/plugins/debugger/watchwindow.h b/src/plugins/debugger/watchwindow.h
index bf6995edb4..715507f8b1 100644
--- a/src/plugins/debugger/watchwindow.h
+++ b/src/plugins/debugger/watchwindow.h
@@ -57,15 +57,11 @@ public slots:
void setAlwaysResizeColumnsToContents(bool on = true);
void setModel(QAbstractItemModel *model);
-signals:
- void requestExpandChildren(const QModelIndex &idx);
- void requestCollapseChildren(const QModelIndex &idx);
-
-private slots:
- void expandNode(const QModelIndex &index);
- void collapseNode(const QModelIndex &index);
-
private:
+ Q_SLOT void expandNode(const QModelIndex &index);
+ Q_SLOT void collapseNode(const QModelIndex &index);
+ Q_SLOT void resetHelper();
+
void keyPressEvent(QKeyEvent *ev);
void contextMenuEvent(QContextMenuEvent *ev);
void editItem(const QModelIndex &idx);