Skip to content

Commit

Permalink
Implement special handling for BObjectList.
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
anevilyak committed Dec 4, 2012
1 parent ada60b4 commit ede21af
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/apps/debugger/value/type_handlers/BListTypeHandler.cpp
Expand Up @@ -21,7 +21,8 @@ float
BListTypeHandler::SupportsType(Type* type)
{
if (dynamic_cast<CompoundType*>(type) != NULL
&& type->Name() == "BList")
&& (type->Name() == "BList"
|| type->Name().Compare("BObjectList", 11) == 0))
return 1.0f;

return 0.0f;
Expand Down
48 changes: 40 additions & 8 deletions src/apps/debugger/value/value_nodes/BListValueNode.cpp
Expand Up @@ -101,7 +101,8 @@ BListValueNode::BListValueNode(ValueNodeChild* nodeChild,
:
ValueNode(nodeChild),
fType(type),
fLoader(NULL)
fLoader(NULL),
fItemCount(0)
{
fType->AcquireReference();
}
Expand Down Expand Up @@ -153,6 +154,21 @@ BListValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
ValueLocation* memberLocation = NULL;
CompoundType* baseType = dynamic_cast<CompoundType*>(fType);

if (baseType->CountTemplateParameters()) {
// for BObjectList we need to walk up
// the hierarchy: BObjectList -> _PointerList_ -> BList
baseType = dynamic_cast<CompoundType*>(baseType->BaseTypeAt(0)
->GetType());
if (baseType == NULL || baseType->Name() != "_PointerList_")
return B_BAD_DATA;

baseType = dynamic_cast<CompoundType*>(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) {
Expand Down Expand Up @@ -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<CompoundType*>(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++)
{
Expand Down

0 comments on commit ede21af

Please sign in to comment.