diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp index 2b4b040159..ba8cabee54 100644 --- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp @@ -1593,11 +1593,17 @@ VariablesView::MessageReceived(BMessage* message) ->SelectionModel()->NodeAt(0); int32 lowerBound, upperBound; ValueNode* valueNode = node->NodeChild()->Node(); - if (!valueNode->IsRangedContainer()) + if (!valueNode->IsRangedContainer()) { valueNode = node->ChildAt(0)->NodeChild()->Node(); + if (!valueNode->IsRangedContainer()) + break; + } - if (valueNode->SupportedChildRange(lowerBound, upperBound) != B_OK) + bool fixedRange = valueNode->IsContainerRangeFixed(); + if (valueNode->SupportedChildRange(lowerBound, upperBound) + != B_OK) { break; + } BMessage* promptMessage = new(std::nothrow) BMessage( MSG_SET_CONTAINER_RANGE); @@ -1606,9 +1612,16 @@ VariablesView::MessageReceived(BMessage* message) ObjectDeleter messageDeleter(promptMessage); promptMessage->AddPointer("node", node); + promptMessage->AddBool("fixedRange", fixedRange); BString infoText; - infoText.SetToFormat("Allowed range: %" B_PRId32 - "-%" B_PRId32 ".", lowerBound, upperBound); + if (fixedRange) { + infoText.SetToFormat("Allowed range: %" B_PRId32 + "-%" B_PRId32 ".", lowerBound, upperBound); + } else { + infoText.SetToFormat("Current range: %" B_PRId32 + "-%" B_PRId32 ".", lowerBound, upperBound); + } + PromptWindow* promptWindow = new(std::nothrow) PromptWindow( "Set Range", "Range: ", infoText.String(), BMessenger(this), promptMessage); @@ -1631,13 +1644,15 @@ VariablesView::MessageReceived(BMessage* message) if (valueNode->SupportedChildRange(lowerBound, upperBound) != B_OK) break; + bool fixedRange = message->FindBool("fixedRange"); + BString rangeExpression = message->FindString("text"); if (rangeExpression.Length() == 0) break; RangeList ranges; status_t result = UiUtils::ParseRangeExpression( - rangeExpression, lowerBound, upperBound, ranges); + rangeExpression, lowerBound, upperBound, fixedRange, ranges); if (result != B_OK) break; diff --git a/src/apps/debugger/user_interface/util/UiUtils.cpp b/src/apps/debugger/user_interface/util/UiUtils.cpp index 6ed0c58e04..39eee3f784 100644 --- a/src/apps/debugger/user_interface/util/UiUtils.cpp +++ b/src/apps/debugger/user_interface/util/UiUtils.cpp @@ -411,7 +411,7 @@ static status_t ParseRangeString(BString& rangeString, int32& lowerBound, /*static*/ status_t UiUtils::ParseRangeExpression(const BString& rangeExpression, int32 lowerBound, - int32 upperBound, RangeList& _output) + int32 upperBound, bool fixedRange, RangeList& _output) { if (rangeExpression.IsEmpty()) return B_BAD_DATA; @@ -440,7 +440,8 @@ UiUtils::ParseRangeExpression(const BString& rangeExpression, int32 lowerBound, if (result != B_OK) return result; - if (lowValue < lowerBound || highValue > upperBound) + + if (fixedRange && (lowValue < lowerBound || highValue > upperBound)) return B_BAD_VALUE; result = _output.AddRange(lowValue, highValue); diff --git a/src/apps/debugger/user_interface/util/UiUtils.h b/src/apps/debugger/user_interface/util/UiUtils.h index ccb67d51bc..7b11be9a18 100644 --- a/src/apps/debugger/user_interface/util/UiUtils.h +++ b/src/apps/debugger/user_interface/util/UiUtils.h @@ -55,6 +55,7 @@ public: static status_t ParseRangeExpression( const BString& rangeString, int32 lowerBound, int32 upperBound, + bool fixedRange, RangeList& _output); }; diff --git a/src/apps/debugger/value/value_nodes/ArrayValueNode.cpp b/src/apps/debugger/value/value_nodes/ArrayValueNode.cpp index 6752c9b156..bc05323c02 100644 --- a/src/apps/debugger/value/value_nodes/ArrayValueNode.cpp +++ b/src/apps/debugger/value/value_nodes/ArrayValueNode.cpp @@ -31,7 +31,10 @@ AbstractArrayValueNode::AbstractArrayValueNode(ValueNodeChild* nodeChild, : ValueNode(nodeChild), fType(type), - fDimension(dimension) + fDimension(dimension), + fLowerBound(0), + fUpperBound(0), + fBoundsInitialized(false) { fType->AcquireReference(); } @@ -106,6 +109,8 @@ void AbstractArrayValueNode::ClearChildren() { fChildren.MakeEmpty(); + fLowerBound = 0; + fUpperBound = 0; if (fContainer != NULL) fContainer->NotifyValueNodeChildrenDeleted(this); } @@ -121,14 +126,22 @@ AbstractArrayValueNode::CreateChildrenInRange(int32 lowIndex, int32 dimensionCount = fType->CountDimensions(); bool isFinalDimension = fDimension + 1 == dimensionCount; + status_t error = B_OK; - int32 lowerBound, upperBound; - if (SupportedChildRange(lowerBound, upperBound) == B_OK) { - // clamp inputs to supported range. - if (lowIndex < lowerBound) - lowIndex = lowerBound; - if (highIndex > upperBound) - highIndex = upperBound; + if (!fBoundsInitialized) { + int32 lowerBound, upperBound; + error = SupportedChildRange(lowerBound, upperBound); + if (error != B_OK) + return error; + + fLowerBound = lowerBound; + fUpperBound = upperBound; + fBoundsInitialized = true; + } else { + if (lowIndex < fLowerBound) + fLowerBound = lowIndex; + if (highIndex > fUpperBound) + fUpperBound = highIndex; } // create children for the array elements @@ -166,19 +179,23 @@ status_t AbstractArrayValueNode::SupportedChildRange(int32& lowIndex, int32& highIndex) const { - ArrayDimension* dimension = fType->DimensionAt(fDimension); + if (!fBoundsInitialized) { + ArrayDimension* dimension = fType->DimensionAt(fDimension); - SubrangeType* dimensionType = dynamic_cast( - dimension->GetType()); + SubrangeType* dimensionType = dynamic_cast( + dimension->GetType()); - if (dimensionType != NULL) { - lowIndex = dimensionType->LowerBound().ToInt32(); - highIndex = dimensionType->UpperBound().ToInt32(); - - return B_OK; + if (dimensionType != NULL) { + lowIndex = dimensionType->LowerBound().ToInt32(); + highIndex = dimensionType->UpperBound().ToInt32(); + } else + return B_UNSUPPORTED; + } else { + lowIndex = fLowerBound; + highIndex = fUpperBound; } - return B_UNSUPPORTED; + return B_OK; } diff --git a/src/apps/debugger/value/value_nodes/ArrayValueNode.h b/src/apps/debugger/value/value_nodes/ArrayValueNode.h index cc305e7528..242954dfcf 100644 --- a/src/apps/debugger/value/value_nodes/ArrayValueNode.h +++ b/src/apps/debugger/value/value_nodes/ArrayValueNode.h @@ -54,6 +54,9 @@ protected: ArrayType* fType; ChildList fChildren; int32 fDimension; + int32 fLowerBound; + int32 fUpperBound; + bool fBoundsInitialized; };