Commit 44d02a65 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

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

parent 81bb2f63
......@@ -37,6 +37,7 @@ HEADERS += \
$$PWD/cdbdebugeventcallback.h \
$$PWD/cdbdebugoutput.h \
$$PWD/cdbsymbolgroupcontext.h \
$$PWD/cdbsymbolgroupcontext_tpl.h \
$$PWD/cdbstacktracecontext.h \
$$PWD/cdbstackframecontext.h \
$$PWD/cdbbreakpoint.h \
......
......@@ -650,23 +650,6 @@ bool CdbDebugEngine::startDebuggerWithExecutable(DebuggerStartMode sm, QString *
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)
{
setDebuggeeHandles(reinterpret_cast<HANDLE>(processHandle), reinterpret_cast<HANDLE>(initialThreadHandle));
......@@ -794,40 +777,9 @@ CdbStackFrameContext *CdbDebugEnginePrivate::getStackFrameContext(int frameIndex
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)
{
if (debugCDB > 1)
if (debugCDBWatchHandling)
qDebug() << Q_FUNC_INFO << wd->exp;
QString errorMessage;
QString value;
......@@ -844,12 +796,12 @@ void CdbDebugEngine::evaluateWatcher(WatchData *wd)
void CdbDebugEngine::updateWatchData(const WatchData &incomplete)
{
// Stack trace exists and evaluation funcs can only be called
// when running
if (m_d->isDebuggeeRunning()) {
qWarning("updateWatchModel() called while debuggee is running.");
return;
}
// Watch item was edited while running
if (m_d->isDebuggeeRunning())
return;
if (debugCDBWatchHandling)
qDebug() << Q_FUNC_INFO << "\n " << incomplete.toString();
WatchHandler *watchHandler = m_d->m_debuggerManagerAccess->watchHandler();
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();
if (debugCDB)
qDebug() << Q_FUNC_INFO << "\n fi=" << frameIndex << incomplete.iname;
bool success = false;
QString errorMessage;
do {
......@@ -1199,12 +1148,14 @@ void CdbDebugEngine::activateFrame(int frameIndex)
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);
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);
if (!success)
warning(msgFunctionFailed(Q_FUNC_INFO, errorMessage));
......@@ -1545,6 +1496,7 @@ void CdbDebugEnginePrivate::updateStackTrace()
m_debuggerManagerAccess->stackHandler()->setCurrentIndex(current);
m_engine->activateFrame(current);
}
m_debuggerManagerAccess->watchHandler()->updateWatchers();
}
void CdbDebugEnginePrivate::updateModules()
......
......@@ -117,7 +117,6 @@ struct CdbDebugEnginePrivate
void handleDebugEvent();
void updateThreadList();
void updateStackTrace();
bool updateLocals(int frameIndex, WatchHandler *wh, QString *errorMessage);
void updateModules();
void handleBreakpointEvent(PDEBUG_BREAKPOINT2 pBP);
......@@ -182,6 +181,7 @@ QString msgDebugEngineComResult(HRESULT hr);
QString msgComFailed(const char *func, HRESULT hr);
enum { debugCDB = 0 };
enum { debugCDBWatchHandling = 0 };
} // namespace Internal
} // namespace Debugger
......
......@@ -28,6 +28,7 @@
**************************************************************************/
#include "cdbstackframecontext.h"
#include "cdbdebugengine_p.h"
#include "cdbsymbolgroupcontext.h"
#include "cdbdumperhelper.h"
#include "debuggeractions.h"
......@@ -131,7 +132,7 @@ bool CdbStackFrameContext::assignValue(const QString &iname, const QString &valu
bool CdbStackFrameContext::populateModelInitially(WatchHandler *wh, QString *errorMessage)
{
if (debug)
if (debugCDBWatchHandling)
qDebug() << "populateModelInitially";
const bool rc = m_useDumpers ?
CdbSymbolGroupContext::populateModelInitially(m_symbolContext,
......@@ -149,8 +150,8 @@ bool CdbStackFrameContext::completeData(const WatchData &incompleteLocal,
WatchHandler *wh,
QString *errorMessage)
{
if (debug)
qDebug() << ">completeData " << incompleteLocal.iname;
if (debugCDBWatchHandling)
qDebug() << ">completeData " << incompleteLocal.iname << " src=" << incompleteLocal.source;
if (!m_useDumpers) {
return CdbSymbolGroupContext::completeData(m_symbolContext, incompleteLocal,
......
......@@ -202,7 +202,9 @@ bool CdbSymbolGroupContext::completeData(CdbSymbolGroupContext *sg,
const bool contextExpanded = sg->isExpanded(incompleteLocal.iname);
if (debugSgRecursion)
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();
*it = incompleteLocal;
++it;
......
......@@ -879,6 +879,8 @@ void WatchHandler::watchExpression(const QString &exp)
WatchData data;
data.exp = exp;
data.name = exp;
if (exp == watcherEditPlaceHolder())
data.setAllUnneeded();
data.iname = watcherName(exp);
insertData(data);
saveWatchers();
......@@ -1063,5 +1065,10 @@ WatchData *WatchHandler::findItem(const QString &iname) const
return model->findItem(iname, model->m_root);
}
QString WatchHandler::watcherEditPlaceHolder()
{
static const QString rc = tr("<Edit>");
return rc;
}
} // namespace Internal
} // namespace Debugger
......@@ -210,6 +210,8 @@ public:
QSet<QString> expandedINames() const
{ return m_expandedINames; }
static QString watcherEditPlaceHolder();
signals:
void watchDataUpdateNeeded(const WatchData &data);
void sessionValueRequested(const QString &name, QVariant *value);
......
......@@ -28,6 +28,7 @@
**************************************************************************/
#include "watchwindow.h"
#include "watchhandler.h"
#include "debuggeractions.h"
......@@ -54,8 +55,6 @@ using namespace Debugger::Internal;
//
/////////////////////////////////////////////////////////////////////
enum { INameRole = Qt::UserRole, ExpressionRole, ExpandedRole };
class WatchDelegate : public QItemDelegate
{
public:
......@@ -64,7 +63,6 @@ public:
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
const QModelIndex &) const
{
qDebug() << "CREATE EDITOR";
return new QLineEdit(parent);
}
......@@ -236,7 +234,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
else if (act == act2)
setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents);
else if (act == act3)
theDebuggerAction(WatchExpression)->trigger(tr("<Edit>"));
theDebuggerAction(WatchExpression)->trigger(WatchHandler::watcherEditPlaceHolder());
}
void WatchWindow::resizeColumnsToContents()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment