Commit f97069eb authored by David Schulz's avatar David Schulz
Browse files

CdbExt: Setting actively which nodes should be expanded.



Change-Id: I1470a67aa559e4d93a01cc70701fb160e873317d
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent e855de40
......@@ -203,12 +203,9 @@ std::string SymbolGroup::dump(const std::string &iname,
DebugPrint() << "SymbolGroup::dump(" << iname << '/'
<< aNode->absoluteFullIName() <<" resolves to " << node->absoluteFullIName()
<< " expanded=" << node->isExpanded();
if (node->isExpanded()) { // Mark expand request by watch model
node->clearFlags(SymbolGroupNode::ExpandedByDumper);
} else {
if (node->canExpand() && !node->expand(errorMessage))
return std::string();
}
if (!node->isExpanded() && node->canExpand() && !node->expand(errorMessage))
return std::string();
node->addFlags(SymbolGroupNode::ExpandedByRequest);
// After expansion, run the complex dumpers
if (p.dumpFlags & DumpParameters::DumpComplexDumpers)
node->runComplexDumpers(ctx);
......@@ -378,8 +375,12 @@ static inline SymbolGroupNode *
bool SymbolGroup::expand(const std::string &nodeName, std::string *errorMessage)
{
if (SymbolGroupNode *node = findNodeForExpansion(this, nodeName, errorMessage))
return node == m_root ? true : node->expand(errorMessage);
if (SymbolGroupNode *node = findNodeForExpansion(this, nodeName, errorMessage)) {
if (node == m_root)
return true;
node->addFlags(SymbolGroupNode::ExpandedByRequest);
return node->expand(errorMessage);
}
return false;
}
......@@ -393,8 +394,12 @@ bool SymbolGroup::collapse(const std::string &nodeName, std::string *errorMessag
bool SymbolGroup::expandRunComplexDumpers(const std::string &nodeName, const SymbolGroupValueContext &ctx, std::string *errorMessage)
{
if (SymbolGroupNode *node = findNodeForExpansion(this, nodeName, errorMessage))
return node == m_root ? true : node->expandRunComplexDumpers(ctx, errorMessage);
if (SymbolGroupNode *node = findNodeForExpansion(this, nodeName, errorMessage)) {
if (node == m_root)
return true;
node->addFlags(SymbolGroupNode::ExpandedByRequest);
return node->expandRunComplexDumpers(ctx, errorMessage);
}
return false;
}
......
......@@ -62,8 +62,8 @@ static inline void debugNodeFlags(std::ostream &str, unsigned f)
str << " DumperOk";
if (f & SymbolGroupNode::SimpleDumperFailed)
str << " DumperFailed";
if (f & SymbolGroupNode::ExpandedByDumper)
str << " ExpandedByDumper";
if (f & SymbolGroupNode::ExpandedByRequest)
str << " ExpandedByRequest";
if (f & SymbolGroupNode::AdditionalSymbol)
str << " AdditionalSymbol";
if (f & SymbolGroupNode::Obscured)
......@@ -594,8 +594,8 @@ void ErrorSymbolGroupNode::debug(std::ostream &os, const std::string &visitingFu
\endlist
The dumping is mostly based on SymbolGroupValue expressions.
in the debugger. Evaluating those dumpers might expand symbol nodes, which are
then marked as 'ExpandedByDumper'. This stops the dump recursion to prevent
in the debugger. Evaluating those dumpers might expand symbol nodes, but those
are not marked as 'ExpandedByRequest'. This stops the dump recursion to prevent
outputting data that were not explicitly expanded by the watch handler.
\ingroup qtcreatorcdbext */
......@@ -1022,7 +1022,6 @@ void SymbolGroupNode::runComplexDumpers(const SymbolGroupValueContext &ctx)
if (ctChildren.empty())
return;
clearFlags(ExpandedByDumper);
// Mark current children as obscured. We cannot show both currently
// as this would upset the numerical sorting of the watch model
AbstractSymbolGroupNodePtrVectorConstIterator cend = children().end();
......@@ -1269,11 +1268,8 @@ bool SymbolGroupNode::expand(std::string *errorMessage)
DebugPrint() << "SymbolGroupNode::expand " << name()
<<'/' << absoluteFullIName() << ' '
<< m_index << DebugNodeFlags(flags());
if (isExpanded()) {
// Clear the flag indication dumper expansion on a second, explicit request
clearFlags(ExpandedByDumper);
if (isExpanded())
return true;
}
if (!canExpand()) {
*errorMessage = msgExpandFailed(name(), absoluteFullIName(), m_index,
"No subelements to expand in node.");
......@@ -1661,6 +1657,17 @@ SymbolGroupNodeVisitor::VisitResult
return VisitSkipChildren;
if (node->testFlags(SymbolGroupNode::AdditionalSymbol) && !node->testFlags(SymbolGroupNode::WatchNode))
return VisitSkipChildren;
// Recurse to children only if expanded by explicit watchmodel request
// and initialized.
bool visitChildren = true; // Report only one level for Qt Creator.
// Visit children of a SymbolGroupNode only if not expanded by its dumpers.
if (const SymbolGroupNode *realNode = node->resolveReference()->asSymbolGroupNode()) {
if (!realNode->isExpanded()
|| realNode->testFlags(SymbolGroupNode::Uninitialized)
|| !realNode->testFlags(SymbolGroupNode::ExpandedByRequest)) {
visitChildren = false;
}
}
// Comma between same level children given obscured children
if (depth == m_lastDepth)
m_os << ',';
......@@ -1673,28 +1680,16 @@ SymbolGroupNodeVisitor::VisitResult
m_os << '{';
const int childCount = node->dump(m_os, fullIname, m_parameters, m_context);
m_os << ",numchild=\"" << childCount << '"';
if (childCount) {
// Recurse to children only if expanded by explicit watchmodel request
// and initialized.
// Visit children of a SymbolGroupNode only if not expanded by its dumpers.
bool skipit = false;
if (const SymbolGroupNode *realNode = node->resolveReference()->asSymbolGroupNode()) {
if (!realNode->isExpanded() || realNode->testFlags(SymbolGroupNode::Uninitialized | SymbolGroupNode::ExpandedByDumper))
skipit = true;
}
if (!skipit) {
m_os << ",children=[";
if (m_parameters.humanReadable())
m_os << '\n';
return VisitContinue;
}
if (!childCount)
visitChildren = false;
if (visitChildren) { // open children array
m_os << ",children=[";
} else { // No children, close array.
m_os << '}';
}
// No children, close array.
m_os << '}';
if (m_parameters.humanReadable())
m_os << '\n';
return VisitSkipChildren;
return visitChildren ? VisitContinue : VisitSkipChildren;
}
void DumpSymbolGroupNodeVisitor::childrenVisited(const AbstractSymbolGroupNode *n, unsigned)
......
......@@ -224,7 +224,7 @@ public:
SimpleDumperOk = 0x4, // Internal dumper ran, value set
SimpleDumperFailed = 0x8, // Internal dumper failed
SimpleDumperMask = SimpleDumperNotApplicable|SimpleDumperOk|SimpleDumperFailed,
ExpandedByDumper = 0x10,
ExpandedByRequest = 0x10,
AdditionalSymbol = 0x20, // Introduced by addSymbol, should not be visible
Obscured = 0x40, // Symbol is obscured by (for example) fake container children
ComplexDumperOk = 0x80,
......
......@@ -160,10 +160,8 @@ bool SymbolGroupValue::ensureExpanded() const
// Set a flag indicating the node was expanded by SymbolGroupValue
// and not by an explicit request from the watch model.
if (m_node->expand(&m_errorMessage)) {
m_node->addFlags(SymbolGroupNode::ExpandedByDumper);
if (m_node->expand(&m_errorMessage))
return true;
}
if (SymbolGroupValue::verbose)
DebugPrint() << "Expand failure of '" << name() << "': " << m_errorMessage;
return false;
......
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