Commit 24cf802a authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Compile new watch model for CDB.

parent c222f2aa
......@@ -813,23 +813,15 @@ bool CdbDebugEnginePrivate::updateLocals(int frameIndex,
WatchHandler *wh,
QString *errorMessage)
{
wh->reinitializeWatchers();
QList<WatchData> incompletes = wh->takeCurrentIncompletes();
wh->beginCycle();
if (debugCDB)
qDebug() << Q_FUNC_INFO << "\n " << frameIndex << formatWatchList(incompletes);
m_engine->filterEvaluateWatchers(&incompletes, wh);
if (!incompletes.empty()) {
const QString msg = QLatin1String("Warning: Locals left in incomplete list: ") + formatWatchList(incompletes);
m_engine->warning(msg);
}
qDebug() << Q_FUNC_INFO << "\n " << frameIndex;
bool success = false;
if (CdbStackFrameContext *sgc = getStackFrameContext(frameIndex, errorMessage))
success = sgc->populateModelInitially(wh, errorMessage);
wh->rebuildModel();
wh->endCycle();
return success;
}
......@@ -850,69 +842,36 @@ void CdbDebugEngine::evaluateWatcher(WatchData *wd)
wd->setChildCount(0);
}
void CdbDebugEngine::filterEvaluateWatchers(QList<WatchData> *wd, WatchHandler *wh)
{
typedef QList<WatchData> WatchList;
if (wd->empty())
return;
// Filter out actual watchers. Ignore the "<Edit>" top level place holders
SyntaxSetter syntaxSetter(m_d->m_cif.debugControl, DEBUG_EXPR_CPLUSPLUS);
const QString watcherPrefix = QLatin1String("watch.");
const QChar lessThan = QLatin1Char('<');
const QChar greaterThan = QLatin1Char('>');
bool placeHolderSeen = false;
for (WatchList::iterator it = wd->begin(); it != wd->end(); ) {
if (it->iname.startsWith(watcherPrefix)) {
const bool isPlaceHolder = it->exp.startsWith(lessThan) && it->exp.endsWith(greaterThan);
if (isPlaceHolder) {
if (!placeHolderSeen) { // Max one place holder
it->setChildCount(0);
it->setAllUnneeded();
wh->insertData(*it);
placeHolderSeen = true;
}
} else {
evaluateWatcher(&(*it));
wh->insertData(*it);
}
it = wd->erase(it);
} else {
++it;
}
}
}
void CdbDebugEngine::updateWatchModel()
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;
}
WatchHandler *watchHandler = m_d->m_debuggerManagerAccess->watchHandler();
if (incomplete.iname.startsWith(QLatin1String("watch."))) {
WatchData watchData = incomplete;
evaluateWatcher(&watchData);
watchHandler->insertData(watchData);
return;
}
const int frameIndex = m_d->m_debuggerManagerAccess->stackHandler()->currentIndex();
WatchHandler *watchHandler = m_d->m_debuggerManagerAccess->watchHandler();
WatchList incomplete = watchHandler->takeCurrentIncompletes();
if (incomplete.empty())
return;
if (debugCDB)
qDebug() << Q_FUNC_INFO << "\n fi=" << frameIndex << formatWatchList(incomplete);
qDebug() << Q_FUNC_INFO << "\n fi=" << frameIndex << incomplete.iname;
bool success = false;
QString errorMessage;
do {
// Filter out actual watchers
filterEvaluateWatchers(&incomplete, watchHandler);
// Do locals. We might get called while running when someone enters watchers
if (!incomplete.empty()) {
CdbStackFrameContext *sg = m_d->m_currentStackTrace->frameContextAt(frameIndex, &errorMessage);
if (!sg || !sg->completeModel(incomplete, watchHandler, &errorMessage))
break;
}
watchHandler->rebuildModel();
CdbStackFrameContext *sg = m_d->m_currentStackTrace->frameContextAt(frameIndex, &errorMessage);
if (!sg)
break;
if (!sg->completeData(incomplete, watchHandler, &errorMessage))
break;
success = true;
} while (false);
if (!success)
......@@ -1132,10 +1091,10 @@ void CdbDebugEngine::assignValueInDebugger(const QString &expr, const QString &v
break;
// Update view
WatchHandler *watchHandler = m_d->m_debuggerManagerAccess->watchHandler();
if (WatchData *fwd = watchHandler->findData(expr)) {
if (WatchData *fwd = watchHandler->findItem(expr)) {
fwd->setValue(newValue);
watchHandler->insertData(*fwd);
watchHandler->rebuildModel();
watchHandler->updateWatchers();
}
success = true;
} while (false);
......@@ -1233,8 +1192,8 @@ void CdbDebugEngine::activateFrame(int frameIndex)
const StackFrame &frame = stackHandler->currentFrame();
if (!frame.isUsable()) {
// Clean out model
watchHandler->reinitializeWatchers();
watchHandler->rebuildModel();
watchHandler->beginCycle();
watchHandler->endCycle();
errorMessage = QString::fromLatin1("%1: file %2 unusable.").
arg(QLatin1String(Q_FUNC_INFO), frame.file);
break;
......
......@@ -119,7 +119,6 @@ private:
bool executeDebuggerCommand(const QString &command, QString *errorMessage);
bool evaluateExpression(const QString &expression, QString *value, QString *type, QString *errorMessage);
void evaluateWatcher(WatchData *wd);
void filterEvaluateWatchers(QList<WatchData> *wd, WatchHandler *wh);
QString editorToolTip(const QString &exp, const QString &function);
CdbDebugEnginePrivate *m_d;
......
......@@ -145,40 +145,31 @@ bool CdbStackFrameContext::populateModelInitially(WatchHandler *wh, QString *err
return rc;
}
bool CdbStackFrameContext::completeModel(const QList<WatchData> &incompleteLocals,
WatchHandler *wh,
QString *errorMessage)
bool CdbStackFrameContext::completeData(const WatchData &incompleteLocal,
WatchHandler *wh,
QString *errorMessage)
{
if (debug) {
QDebug nsp = qDebug().nospace();
nsp << ">completeModel ";
foreach (const WatchData &wd, incompleteLocals)
nsp << wd.iname << ' ';
nsp << '\n';
}
if (debug)
qDebug() << ">completeData " << incompleteLocal.iname;
if (!m_useDumpers) {
return CdbSymbolGroupContext::completeModel(m_symbolContext, incompleteLocals,
WatchHandlerModelInserter(wh),
errorMessage);
return CdbSymbolGroupContext::completeData(m_symbolContext, incompleteLocal,
WatchHandlerModelInserter(wh),
errorMessage);
}
// Expand dumper items
int handledDumpers = 0;
foreach (const WatchData &cwd, incompleteLocals) {
if (cwd.source == OwnerDumper) { // You already know that.
WatchData wd = cwd;
wd.setAllUnneeded();
wh->insertData(wd);
handledDumpers++;
}
}
if (handledDumpers == incompleteLocals.size())
// Expand dumper items (not implemented)
if (incompleteLocal.source == OwnerDumper) {
WatchData wd = incompleteLocal;
wd.setAllUnneeded();
wh->insertData(wd);
return true;
}
// Expand symbol group items
return CdbSymbolGroupContext::completeModel(m_symbolContext, incompleteLocals,
WatchHandlerSorterInserter(wh, m_dumper),
errorMessage);
return CdbSymbolGroupContext::completeData(m_symbolContext, incompleteLocal,
WatchHandlerSorterInserter(wh, m_dumper),
errorMessage);
}
CdbStackFrameContext::~CdbStackFrameContext()
......
......@@ -59,9 +59,9 @@ public:
bool populateModelInitially(WatchHandler *wh, QString *errorMessage);
bool completeModel(const QList<WatchData> &incompleteLocals,
WatchHandler *wh,
QString *errorMessage);
bool completeData(const WatchData &incompleteLocal,
WatchHandler *wh,
QString *errorMessage);
private:
const bool m_useDumpers;
......
......@@ -80,8 +80,8 @@ public:
OutputIterator it, QString *errorMessage);
template <class OutputIterator>
static bool completeModel(CdbSymbolGroupContext *sg,
const QList<WatchData> &incompleteLocals,
static bool completeData (CdbSymbolGroupContext *sg,
WatchData incompleteLocal,
OutputIterator it,
QString *errorMessage);
......
......@@ -192,27 +192,23 @@ bool CdbSymbolGroupContext::populateModelInitially(CdbSymbolGroupContext *sg,
}
template <class OutputIterator>
bool CdbSymbolGroupContext::completeModel(CdbSymbolGroupContext *sg,
const QList<WatchData> &incompleteLocals,
OutputIterator it,
QString *errorMessage)
bool CdbSymbolGroupContext::completeData(CdbSymbolGroupContext *sg,
WatchData incompleteLocal,
OutputIterator it,
QString *errorMessage)
{
if (debugSgRecursion)
qDebug().nospace() << "###>" << Q_FUNC_INFO << ' ' << incompleteLocals.size() << '\n';
// The view reinserts any node being expanded with flag 'ChildrenNeeded'.
// Recurse down one level in context unless this is already the case.
foreach(WatchData wd, incompleteLocals) {
const bool contextExpanded = sg->isExpanded(wd.iname);
if (debugSgRecursion)
qDebug() << " " << wd.iname << "CE=" << contextExpanded;
if (contextExpanded) { // You know that already.
wd.setChildrenUnneeded();
*it = wd;
++it;
} else {
if (!insertSymbolRecursion(wd, sg, it, 1, 0, errorMessage))
return false;
}
qDebug().nospace() << "###>" << Q_FUNC_INFO << ' ' << incompleteLocal.iname << '\n';
const bool contextExpanded = sg->isExpanded(incompleteLocal.iname);
if (debugSgRecursion)
qDebug() << " " << incompleteLocal.iname << "CE=" << contextExpanded;
if (contextExpanded) { // TODO: Legacy, should not be required any more
incompleteLocal.setChildrenUnneeded();
*it = incompleteLocal;
++it;
} else {
if (!insertSymbolRecursion(incompleteLocal, sg, it, 1, 0, errorMessage))
return false;
}
return true;
}
......
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