From ede21af844389d40efca832b1f49b02a84d77ad8 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Mon, 3 Dec 2012 22:00:54 -0500 Subject: [PATCH] Implement special handling for BObjectList. - BListValueNode now also handles BObjectLists. In the latter's case however, it uses the template type parameters to map the array elements to their actual type. As before, this requires a debug libbe to function. --- .../value/type_handlers/BListTypeHandler.cpp | 3 +- .../value/value_nodes/BListValueNode.cpp | 48 +++++++++++++++---- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/apps/debugger/value/type_handlers/BListTypeHandler.cpp b/src/apps/debugger/value/type_handlers/BListTypeHandler.cpp index c5918ed2879..961d3a38b4f 100644 --- a/src/apps/debugger/value/type_handlers/BListTypeHandler.cpp +++ b/src/apps/debugger/value/type_handlers/BListTypeHandler.cpp @@ -21,7 +21,8 @@ float BListTypeHandler::SupportsType(Type* type) { if (dynamic_cast(type) != NULL - && type->Name() == "BList") + && (type->Name() == "BList" + || type->Name().Compare("BObjectList", 11) == 0)) return 1.0f; return 0.0f; diff --git a/src/apps/debugger/value/value_nodes/BListValueNode.cpp b/src/apps/debugger/value/value_nodes/BListValueNode.cpp index 167c8884c05..697b6512eb8 100644 --- a/src/apps/debugger/value/value_nodes/BListValueNode.cpp +++ b/src/apps/debugger/value/value_nodes/BListValueNode.cpp @@ -101,7 +101,8 @@ BListValueNode::BListValueNode(ValueNodeChild* nodeChild, : ValueNode(nodeChild), fType(type), - fLoader(NULL) + fLoader(NULL), + fItemCount(0) { fType->AcquireReference(); } @@ -153,6 +154,21 @@ BListValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader, ValueLocation* memberLocation = NULL; CompoundType* baseType = dynamic_cast(fType); + if (baseType->CountTemplateParameters()) { + // for BObjectList we need to walk up + // the hierarchy: BObjectList -> _PointerList_ -> BList + baseType = dynamic_cast(baseType->BaseTypeAt(0) + ->GetType()); + if (baseType == NULL || baseType->Name() != "_PointerList_") + return B_BAD_DATA; + + baseType = dynamic_cast(baseType->BaseTypeAt(0) + ->GetType()); + if (baseType == NULL || baseType->Name() != "BList") + return B_BAD_DATA; + + } + for (int32 i = 0; i < baseType->CountDataMembers(); i++) { DataMember* member = baseType->DataMemberAt(i); if (strcmp(member->Name(), "fObjectList") == 0) { @@ -213,14 +229,30 @@ BListValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader, status_t BListValueNode::CreateChildren() { - BString typeName; - TypeLookupConstraints constraints; - constraints.SetTypeKind(TYPE_ADDRESS); - constraints.SetBaseTypeName("void"); + if (fItemCount == 0 || fChildrenCreated) { + fChildrenCreated = true; + return B_OK; + } + Type* type = NULL; - status_t result = fLoader->LookupTypeByName(typeName, constraints, type); - if (result != B_OK) - return result; + CompoundType* objectType = dynamic_cast(fType); + if (objectType->CountTemplateParameters() != 0) { + AddressType* addressType = NULL; + status_t result = objectType->TemplateParameterAt(0)->GetType() + ->CreateDerivedAddressType(DERIVED_TYPE_POINTER, addressType); + if (result != B_OK) + return result; + + type = addressType; + } else { + BString typeName; + TypeLookupConstraints constraints; + constraints.SetTypeKind(TYPE_ADDRESS); + constraints.SetBaseTypeName("void"); + status_t result = fLoader->LookupTypeByName(typeName, constraints, type); + if (result != B_OK) + return result; + } for (int32 i = 0; i < fItemCount && i < kMaxArrayElementCount; i++) {