Refactor DebugReportGenerator to use PrintValueNodeGraph.
This commit is contained in:
@@ -312,7 +312,9 @@ DebugReportGenerator::_DumpDebuggedThreadInfo(BString& _output,
|
|||||||
AutoLocker<ValueNodeContainer> containerLocker(container);
|
AutoLocker<ValueNodeContainer> containerLocker(container);
|
||||||
for (int32 i = 0; i < container->CountChildren(); i++) {
|
for (int32 i = 0; i < container->CountChildren(); i++) {
|
||||||
ValueNodeChild* child = container->ChildAt(i);
|
ValueNodeChild* child = container->ChildAt(i);
|
||||||
_DumpValueNode(_output, frame, child);
|
_ResolveLocationIfNeeded(child, frame);
|
||||||
|
_ResolveValueIfNeeded(child->Node(), frame, 4);
|
||||||
|
UiUtils::PrintValueNodeGraph(_output, frame, child, 3, 2);
|
||||||
}
|
}
|
||||||
_output << "\n";
|
_output << "\n";
|
||||||
}
|
}
|
||||||
@@ -337,78 +339,8 @@ DebugReportGenerator::_DumpDebuggedThreadInfo(BString& _output,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DebugReportGenerator::_DumpValueNode(BString& _output, StackFrame* frame,
|
DebugReportGenerator::_ResolveValueIfNeeded(ValueNode* node, StackFrame* frame,
|
||||||
ValueNodeChild* child, bool recurse)
|
int32 maxDepth)
|
||||||
{
|
|
||||||
status_t result = _ResolveLocationIfNeeded(child, frame);
|
|
||||||
if (result != B_OK)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
_output << "\t\t\t";
|
|
||||||
if (!recurse)
|
|
||||||
_output << "\t";
|
|
||||||
_output << child->Name() << ": ";
|
|
||||||
|
|
||||||
ValueNode* node = child->Node();
|
|
||||||
if (node->LocationAndValueResolutionState() == VALUE_NODE_UNRESOLVED) {
|
|
||||||
if (_ResolveValueIfNeeded(node, frame) == B_OK) {
|
|
||||||
Value* value = node->GetValue();
|
|
||||||
if (value != NULL) {
|
|
||||||
BString valueData;
|
|
||||||
value->ToString(valueData);
|
|
||||||
_output << valueData;
|
|
||||||
} else
|
|
||||||
_output << "Unavailable";
|
|
||||||
} else
|
|
||||||
_output << "Unknown";
|
|
||||||
}
|
|
||||||
if (recurse && node->CountChildren() != 0)
|
|
||||||
_output << " {";
|
|
||||||
|
|
||||||
_output << "\n";
|
|
||||||
|
|
||||||
if (recurse) {
|
|
||||||
if (node->CountChildren() == 0)
|
|
||||||
return B_OK;
|
|
||||||
|
|
||||||
if (node->CountChildren() == 1
|
|
||||||
&& node->GetType()->Kind() == TYPE_ADDRESS
|
|
||||||
&& node->ChildAt(0)->GetType()->Kind() == TYPE_COMPOUND) {
|
|
||||||
// for the case of a pointer to a compound type,
|
|
||||||
// we want to hide the intervening compound node and print
|
|
||||||
// the children directly.
|
|
||||||
status_t result = fNodeManager->AddChildNodes(node->ChildAt(0));
|
|
||||||
if (result == B_OK) {
|
|
||||||
result = _ResolveLocationIfNeeded(node->ChildAt(0), frame);
|
|
||||||
if (result == B_OK) {
|
|
||||||
node = node->ChildAt(0)->Node();
|
|
||||||
// attempt to resolve the value here since the node's
|
|
||||||
// representation may requires its value to be resolved
|
|
||||||
// before its children can be created
|
|
||||||
result = _ResolveValueIfNeeded(node, frame);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32 i = 0; i < node->CountChildren(); i++) {
|
|
||||||
if (fNodeManager->AddChildNodes(node->ChildAt(i)) != B_OK)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// don't dump compound nodes since we won't traverse into
|
|
||||||
// them anyways and their top level node has no interesting
|
|
||||||
// information.
|
|
||||||
if (node->ChildAt(i)->GetType()->Kind() != TYPE_COMPOUND)
|
|
||||||
_DumpValueNode(_output, frame, node->ChildAt(i), false);
|
|
||||||
}
|
|
||||||
_output << "\t\t\t}\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
DebugReportGenerator::_ResolveValueIfNeeded(ValueNode* node, StackFrame* frame)
|
|
||||||
{
|
{
|
||||||
ValueLocation* location = NULL;
|
ValueLocation* location = NULL;
|
||||||
Value* value = NULL;
|
Value* value = NULL;
|
||||||
@@ -422,6 +354,21 @@ DebugReportGenerator::_ResolveValueIfNeeded(ValueNode* node, StackFrame* frame)
|
|||||||
if (value != NULL)
|
if (value != NULL)
|
||||||
value->ReleaseReference();
|
value->ReleaseReference();
|
||||||
|
|
||||||
|
if (result == B_OK && maxDepth > 0) {
|
||||||
|
for (int32 i = 0; i < node->CountChildren(); i++) {
|
||||||
|
ValueNodeChild* child = node->ChildAt(i);
|
||||||
|
result = _ResolveLocationIfNeeded(child, frame);
|
||||||
|
if (result != B_OK)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
result = fNodeManager->AddChildNodes(child);
|
||||||
|
if (result != B_OK)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
_ResolveValueIfNeeded(child->Node(), frame, maxDepth - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef DEBUG_REPORT_GENERATOR_H
|
#ifndef DEBUG_REPORT_GENERATOR_H
|
||||||
#define DEBUG_GENERATOR_H
|
#define DEBUG_REPORT_GENERATOR_H
|
||||||
|
|
||||||
|
|
||||||
#include <Looper.h>
|
#include <Looper.h>
|
||||||
@@ -44,14 +44,11 @@ private:
|
|||||||
status_t _DumpRunningThreads(BString& output);
|
status_t _DumpRunningThreads(BString& output);
|
||||||
status_t _DumpDebuggedThreadInfo(BString& output,
|
status_t _DumpDebuggedThreadInfo(BString& output,
|
||||||
::Thread* thread);
|
::Thread* thread);
|
||||||
status_t _DumpValueNode(BString& output,
|
|
||||||
StackFrame* frame, ValueNodeChild* child,
|
|
||||||
bool recurse = true);
|
|
||||||
|
|
||||||
status_t _ResolveLocationIfNeeded(ValueNodeChild* child,
|
status_t _ResolveLocationIfNeeded(ValueNodeChild* child,
|
||||||
StackFrame* frame);
|
StackFrame* frame);
|
||||||
status_t _ResolveValueIfNeeded(ValueNode* node,
|
status_t _ResolveValueIfNeeded(ValueNode* node,
|
||||||
StackFrame* frame);
|
StackFrame* frame, int32 maxDepth);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
::Team* fTeam;
|
::Team* fTeam;
|
||||||
|
|||||||
Reference in New Issue
Block a user