From ae6ce8e4aedde6a99d47131310a710fea4233de1 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Wed, 12 Aug 2009 12:07:12 +0200 Subject: [PATCH] CDB: Improve expanding watch children. ... by storing the children information in an additional watchdata source bit, thus being able to prove the model wrong in case it claims children are needed. --- .../debugger/cdb/cdbstackframecontext.cpp | 21 ++++++++++++++----- .../debugger/cdb/cdbstackframecontext.h | 3 +++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbstackframecontext.cpp b/src/plugins/debugger/cdb/cdbstackframecontext.cpp index 2128fc8ceab..a3b3ac1d539 100644 --- a/src/plugins/debugger/cdb/cdbstackframecontext.cpp +++ b/src/plugins/debugger/cdb/cdbstackframecontext.cpp @@ -49,7 +49,7 @@ typedef QList<WatchData> WatchDataList; inline bool truePredicate(const WatchData & /* whatever */) { return true; } inline bool falsePredicate(const WatchData & /* whatever */) { return false; } inline bool isDumperPredicate(const WatchData &wd) -{ return wd.source == OwnerDumper; } +{ return (wd.source & CdbStackFrameContext::SourceMask) == OwnerDumper; } static inline void debugWatchDataList(const QList<WatchData> &l, const char *why = 0) { @@ -155,14 +155,14 @@ bool WatchHandleDumperInserter::expandPointerToDumpable(const WatchData &wd, QSt derefedWd.setAddress(hexAddrS); derefedWd.name = QString(QLatin1Char('*')); derefedWd.iname = wd.iname + QLatin1String(".*"); - derefedWd.source = OwnerDumper; + derefedWd.source = OwnerDumper | CdbStackFrameContext::ChildrenKnownBit; const CdbDumperHelper::DumpResult dr = m_dumper->dumpType(derefedWd, true, OwnerDumper, &m_dumperResult, errorMessage); if (dr != CdbDumperHelper::DumpOk) break; // Insert the pointer item with 1 additional child + its dumper results // Note: formal arguments might already be expanded in the symbol group. WatchData ptrWd = wd; - ptrWd.source = OwnerDumper; + ptrWd.source = OwnerDumper | CdbStackFrameContext::ChildrenKnownBit; ptrWd.setHasChildren(true); ptrWd.setChildrenUnneeded(); m_wh->insertData(ptrWd); @@ -200,6 +200,9 @@ static inline void fixDumperResult(const WatchData &source, } if (size == 1) return; + // If the model queries the expanding item by pretending childrenNeeded=1, + // refuse the request as the children are already known + returned.source |= CdbStackFrameContext::ChildrenKnownBit; // Fix the children: If the address is missing, we cannot query any further. const QList<WatchData>::iterator wend = result->end(); QList<WatchData>::iterator it = result->begin(); @@ -230,7 +233,7 @@ WatchHandleDumperInserter &WatchHandleDumperInserter::operator=(WatchData &wd) return *this; } // Expanded by internal dumper? : ok - if (wd.source == OwnerSymbolGroupDumper) { + if ((wd.source & CdbStackFrameContext::SourceMask) == OwnerSymbolGroupDumper) { m_wh->insertData(wd); return *this; } @@ -312,7 +315,15 @@ bool CdbStackFrameContext::completeData(const WatchData &incompleteLocal, } // Expand artifical dumper items - if (incompleteLocal.source == OwnerDumper) { + if ((incompleteLocal.source & CdbStackFrameContext::SourceMask) == OwnerDumper) { + // If the model queries the expanding item by pretending childrenNeeded=1, + // refuse the request if the children are already known + if (incompleteLocal.state == WatchData::ChildrenNeeded && (incompleteLocal.source & CdbStackFrameContext::ChildrenKnownBit)) { + WatchData local = incompleteLocal; + local.setChildrenUnneeded(); + wh->insertData(local); + return true; + } QList<WatchData> dumperResult; const CdbDumperHelper::DumpResult dr = m_dumper->dumpType(incompleteLocal, true, OwnerDumper, &dumperResult, errorMessage); if (dr == CdbDumperHelper::DumpOk) { diff --git a/src/plugins/debugger/cdb/cdbstackframecontext.h b/src/plugins/debugger/cdb/cdbstackframecontext.h index f9ba79c9f83..011d8045176 100644 --- a/src/plugins/debugger/cdb/cdbstackframecontext.h +++ b/src/plugins/debugger/cdb/cdbstackframecontext.h @@ -49,6 +49,9 @@ class CdbStackFrameContext { Q_DISABLE_COPY(CdbStackFrameContext) public: + // Mask bits for the source field of watch data. + enum { SourceMask = 0xFF, ChildrenKnownBit = 0x0100 }; + explicit CdbStackFrameContext(const QSharedPointer<CdbDumperHelper> &dumper, CdbSymbolGroupContext *symbolContext); ~CdbStackFrameContext(); -- GitLab