From f6c0237372c4b7d6fcdf94b2a0de0aea728a2150 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Tue, 16 Apr 2013 22:56:09 -0400 Subject: [PATCH] Fix handling of string fields in BMessages. We can't depend specifically on a generic array type of a primitive being available in the global type cache, because there might not have been a DIE for it. As such, simply look up the type for the character primitive and then derive an array type from that instead. --- .../value/value_nodes/BMessageValueNode.cpp | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/apps/debugger/value/value_nodes/BMessageValueNode.cpp b/src/apps/debugger/value/value_nodes/BMessageValueNode.cpp index 816fb8965e..7b55b9b2f5 100644 --- a/src/apps/debugger/value/value_nodes/BMessageValueNode.cpp +++ b/src/apps/debugger/value/value_nodes/BMessageValueNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2011, Rene Gollent, rene@gollent.com + * Copyright 2011-2013, Rene Gollent, rene@gollent.com * Distributed under the terms of the MIT License. */ @@ -22,6 +22,9 @@ #include "ValueNodeContainer.h" +static const int64 kMaxStringSize = 64; + + // #pragma mark - BMessageWhatNodeChild @@ -471,12 +474,6 @@ BMessageValueNode::_GetTypeForTypeCode(type_code type, constraints.SetTypeKind(TYPE_COMPOUND); break; - case B_POINTER_TYPE: - typeName = ""; - constraints.SetTypeKind(TYPE_ADDRESS); - constraints.SetBaseTypeName("void"); - break; - case B_RECT_TYPE: typeName = "BRect"; constraints.SetTypeKind(TYPE_COMPOUND); @@ -493,13 +490,30 @@ BMessageValueNode::_GetTypeForTypeCode(type_code type, break; case B_STRING_TYPE: - typeName = ""; - constraints.SetTypeKind(TYPE_ARRAY); - constraints.SetBaseTypeName("char"); - break; + { + typeName = "char"; + constraints.SetTypeKind(TYPE_PRIMITIVE); + Type* baseType = NULL; + status_t result = fLoader->LookupTypeByName(typeName, constraints, + baseType); + if (result != B_OK) + return result; + BReference typeReference(baseType, true); + ArrayType* arrayType; + result = baseType->CreateDerivedArrayType(0, kMaxStringSize, true, + arrayType); + if (result == B_OK) + _type = arrayType; + return result; + break; + } + + case B_POINTER_TYPE: default: - return B_BAD_VALUE; + typeName = ""; + constraints.SetTypeKind(TYPE_ADDRESS); + constraints.SetBaseTypeName("void"); break; }