Further cleanup of watch code, do not evaluate "<Edit>" watcher.

This commit is contained in:
Friedemann Kleint
2009-06-18 10:34:53 +02:00
parent 81bb2f6378
commit 44d02a652b
8 changed files with 35 additions and 72 deletions

View File

@@ -37,6 +37,7 @@ HEADERS += \
$$PWD/cdbdebugeventcallback.h \ $$PWD/cdbdebugeventcallback.h \
$$PWD/cdbdebugoutput.h \ $$PWD/cdbdebugoutput.h \
$$PWD/cdbsymbolgroupcontext.h \ $$PWD/cdbsymbolgroupcontext.h \
$$PWD/cdbsymbolgroupcontext_tpl.h \
$$PWD/cdbstacktracecontext.h \ $$PWD/cdbstacktracecontext.h \
$$PWD/cdbstackframecontext.h \ $$PWD/cdbstackframecontext.h \
$$PWD/cdbbreakpoint.h \ $$PWD/cdbbreakpoint.h \

View File

@@ -650,23 +650,6 @@ bool CdbDebugEngine::startDebuggerWithExecutable(DebuggerStartMode sm, QString *
return true; return true;
} }
// check for a breakpoint at 'main()'
static inline bool hasBreakPointAtMain(const BreakHandler *bp)
{
if (const int count = bp->size()) {
// check all variations, resolved or not
const QString main = QLatin1String("main");
const QString qMain = QLatin1String("qMain");
const QString moduleMainPattern = QLatin1String("!main");
for (int i = 0; i < count ; i++) {
const QString &function = bp->at(i)->funcName;
if (function == main || function == qMain || function.endsWith(moduleMainPattern))
return true;
}
}
return false;
}
void CdbDebugEnginePrivate::processCreatedAttached(ULONG64 processHandle, ULONG64 initialThreadHandle) void CdbDebugEnginePrivate::processCreatedAttached(ULONG64 processHandle, ULONG64 initialThreadHandle)
{ {
setDebuggeeHandles(reinterpret_cast<HANDLE>(processHandle), reinterpret_cast<HANDLE>(initialThreadHandle)); setDebuggeeHandles(reinterpret_cast<HANDLE>(processHandle), reinterpret_cast<HANDLE>(initialThreadHandle));
@@ -794,40 +777,9 @@ CdbStackFrameContext *CdbDebugEnginePrivate::getStackFrameContext(int frameIndex
return 0; return 0;
} }
static inline QString formatWatchList(const WatchList &wl)
{
const int count = wl.size();
QString rc;
for (int i = 0; i < count; i++) {
if (i)
rc += QLatin1String(", ");
rc += wl.at(i).iname;
rc += QLatin1String(" (");
rc += wl.at(i).exp;
rc += QLatin1Char(')');
}
return rc;
}
bool CdbDebugEnginePrivate::updateLocals(int frameIndex,
WatchHandler *wh,
QString *errorMessage)
{
wh->beginCycle();
if (debugCDB)
qDebug() << Q_FUNC_INFO << "\n " << frameIndex;
bool success = false;
if (CdbStackFrameContext *sgc = getStackFrameContext(frameIndex, errorMessage))
success = sgc->populateModelInitially(wh, errorMessage);
wh->endCycle();
return success;
}
void CdbDebugEngine::evaluateWatcher(WatchData *wd) void CdbDebugEngine::evaluateWatcher(WatchData *wd)
{ {
if (debugCDB > 1) if (debugCDBWatchHandling)
qDebug() << Q_FUNC_INFO << wd->exp; qDebug() << Q_FUNC_INFO << wd->exp;
QString errorMessage; QString errorMessage;
QString value; QString value;
@@ -844,12 +796,12 @@ void CdbDebugEngine::evaluateWatcher(WatchData *wd)
void CdbDebugEngine::updateWatchData(const WatchData &incomplete) void CdbDebugEngine::updateWatchData(const WatchData &incomplete)
{ {
// Stack trace exists and evaluation funcs can only be called // Watch item was edited while running
// when running if (m_d->isDebuggeeRunning())
if (m_d->isDebuggeeRunning()) {
qWarning("updateWatchModel() called while debuggee is running.");
return; return;
}
if (debugCDBWatchHandling)
qDebug() << Q_FUNC_INFO << "\n " << incomplete.toString();
WatchHandler *watchHandler = m_d->m_debuggerManagerAccess->watchHandler(); WatchHandler *watchHandler = m_d->m_debuggerManagerAccess->watchHandler();
if (incomplete.iname.startsWith(QLatin1String("watch."))) { if (incomplete.iname.startsWith(QLatin1String("watch."))) {
@@ -861,9 +813,6 @@ void CdbDebugEngine::updateWatchData(const WatchData &incomplete)
const int frameIndex = m_d->m_debuggerManagerAccess->stackHandler()->currentIndex(); const int frameIndex = m_d->m_debuggerManagerAccess->stackHandler()->currentIndex();
if (debugCDB)
qDebug() << Q_FUNC_INFO << "\n fi=" << frameIndex << incomplete.iname;
bool success = false; bool success = false;
QString errorMessage; QString errorMessage;
do { do {
@@ -1199,12 +1148,14 @@ void CdbDebugEngine::activateFrame(int frameIndex)
break; break;
} }
if (oldIndex != frameIndex || m_d->m_firstActivatedFrame)
if (!m_d->updateLocals(frameIndex, watchHandler, &errorMessage))
break;
m_d->m_debuggerManager->gotoLocation(frame.file, frame.line, true); m_d->m_debuggerManager->gotoLocation(frame.file, frame.line, true);
success =true;
if (oldIndex != frameIndex || m_d->m_firstActivatedFrame) {
watchHandler->beginCycle();
if (CdbStackFrameContext *sgc = m_d->getStackFrameContext(frameIndex, &errorMessage))
success = sgc->populateModelInitially(watchHandler, &errorMessage);
watchHandler->endCycle();
}
} while (false); } while (false);
if (!success) if (!success)
warning(msgFunctionFailed(Q_FUNC_INFO, errorMessage)); warning(msgFunctionFailed(Q_FUNC_INFO, errorMessage));
@@ -1545,6 +1496,7 @@ void CdbDebugEnginePrivate::updateStackTrace()
m_debuggerManagerAccess->stackHandler()->setCurrentIndex(current); m_debuggerManagerAccess->stackHandler()->setCurrentIndex(current);
m_engine->activateFrame(current); m_engine->activateFrame(current);
} }
m_debuggerManagerAccess->watchHandler()->updateWatchers();
} }
void CdbDebugEnginePrivate::updateModules() void CdbDebugEnginePrivate::updateModules()

View File

@@ -117,7 +117,6 @@ struct CdbDebugEnginePrivate
void handleDebugEvent(); void handleDebugEvent();
void updateThreadList(); void updateThreadList();
void updateStackTrace(); void updateStackTrace();
bool updateLocals(int frameIndex, WatchHandler *wh, QString *errorMessage);
void updateModules(); void updateModules();
void handleBreakpointEvent(PDEBUG_BREAKPOINT2 pBP); void handleBreakpointEvent(PDEBUG_BREAKPOINT2 pBP);
@@ -182,6 +181,7 @@ QString msgDebugEngineComResult(HRESULT hr);
QString msgComFailed(const char *func, HRESULT hr); QString msgComFailed(const char *func, HRESULT hr);
enum { debugCDB = 0 }; enum { debugCDB = 0 };
enum { debugCDBWatchHandling = 0 };
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger

View File

@@ -28,6 +28,7 @@
**************************************************************************/ **************************************************************************/
#include "cdbstackframecontext.h" #include "cdbstackframecontext.h"
#include "cdbdebugengine_p.h"
#include "cdbsymbolgroupcontext.h" #include "cdbsymbolgroupcontext.h"
#include "cdbdumperhelper.h" #include "cdbdumperhelper.h"
#include "debuggeractions.h" #include "debuggeractions.h"
@@ -131,7 +132,7 @@ bool CdbStackFrameContext::assignValue(const QString &iname, const QString &valu
bool CdbStackFrameContext::populateModelInitially(WatchHandler *wh, QString *errorMessage) bool CdbStackFrameContext::populateModelInitially(WatchHandler *wh, QString *errorMessage)
{ {
if (debug) if (debugCDBWatchHandling)
qDebug() << "populateModelInitially"; qDebug() << "populateModelInitially";
const bool rc = m_useDumpers ? const bool rc = m_useDumpers ?
CdbSymbolGroupContext::populateModelInitially(m_symbolContext, CdbSymbolGroupContext::populateModelInitially(m_symbolContext,
@@ -149,8 +150,8 @@ bool CdbStackFrameContext::completeData(const WatchData &incompleteLocal,
WatchHandler *wh, WatchHandler *wh,
QString *errorMessage) QString *errorMessage)
{ {
if (debug) if (debugCDBWatchHandling)
qDebug() << ">completeData " << incompleteLocal.iname; qDebug() << ">completeData " << incompleteLocal.iname << " src=" << incompleteLocal.source;
if (!m_useDumpers) { if (!m_useDumpers) {
return CdbSymbolGroupContext::completeData(m_symbolContext, incompleteLocal, return CdbSymbolGroupContext::completeData(m_symbolContext, incompleteLocal,

View File

@@ -202,7 +202,9 @@ bool CdbSymbolGroupContext::completeData(CdbSymbolGroupContext *sg,
const bool contextExpanded = sg->isExpanded(incompleteLocal.iname); const bool contextExpanded = sg->isExpanded(incompleteLocal.iname);
if (debugSgRecursion) if (debugSgRecursion)
qDebug() << " " << incompleteLocal.iname << "CE=" << contextExpanded; qDebug() << " " << incompleteLocal.iname << "CE=" << contextExpanded;
if (contextExpanded) { // TODO: Legacy, should not be required any more // The view reinserts any node being expanded with flag 'ChildrenNeeded'.
// Recurse down one level in context unless this is already the case.
if (contextExpanded) {
incompleteLocal.setChildrenUnneeded(); incompleteLocal.setChildrenUnneeded();
*it = incompleteLocal; *it = incompleteLocal;
++it; ++it;

View File

@@ -879,6 +879,8 @@ void WatchHandler::watchExpression(const QString &exp)
WatchData data; WatchData data;
data.exp = exp; data.exp = exp;
data.name = exp; data.name = exp;
if (exp == watcherEditPlaceHolder())
data.setAllUnneeded();
data.iname = watcherName(exp); data.iname = watcherName(exp);
insertData(data); insertData(data);
saveWatchers(); saveWatchers();
@@ -1063,5 +1065,10 @@ WatchData *WatchHandler::findItem(const QString &iname) const
return model->findItem(iname, model->m_root); return model->findItem(iname, model->m_root);
} }
QString WatchHandler::watcherEditPlaceHolder()
{
static const QString rc = tr("<Edit>");
return rc;
}
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger

View File

@@ -210,6 +210,8 @@ public:
QSet<QString> expandedINames() const QSet<QString> expandedINames() const
{ return m_expandedINames; } { return m_expandedINames; }
static QString watcherEditPlaceHolder();
signals: signals:
void watchDataUpdateNeeded(const WatchData &data); void watchDataUpdateNeeded(const WatchData &data);
void sessionValueRequested(const QString &name, QVariant *value); void sessionValueRequested(const QString &name, QVariant *value);

View File

@@ -28,6 +28,7 @@
**************************************************************************/ **************************************************************************/
#include "watchwindow.h" #include "watchwindow.h"
#include "watchhandler.h"
#include "debuggeractions.h" #include "debuggeractions.h"
@@ -54,8 +55,6 @@ using namespace Debugger::Internal;
// //
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
enum { INameRole = Qt::UserRole, ExpressionRole, ExpandedRole };
class WatchDelegate : public QItemDelegate class WatchDelegate : public QItemDelegate
{ {
public: public:
@@ -64,7 +63,6 @@ public:
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
const QModelIndex &) const const QModelIndex &) const
{ {
qDebug() << "CREATE EDITOR";
return new QLineEdit(parent); return new QLineEdit(parent);
} }
@@ -236,7 +234,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
else if (act == act2) else if (act == act2)
setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents); setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents);
else if (act == act3) else if (act == act3)
theDebuggerAction(WatchExpression)->trigger(tr("<Edit>")); theDebuggerAction(WatchExpression)->trigger(WatchHandler::watcherEditPlaceHolder());
} }
void WatchWindow::resizeColumnsToContents() void WatchWindow::resizeColumnsToContents()