Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor Concord's TruncatedString flag to reduce memory usage #68969

Merged
merged 1 commit into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private string GetValueStringForCharacter(DkmClrValue value, DkmInspectionContex

private bool HasUnderlyingString(DkmClrValue value, DkmInspectionContext inspectionContext)
{
return GetUnderlyingString(value, inspectionContext) != null;
return value.EvalFlags.HasFlag(DkmEvaluationResultFlags.TruncatedString) || GetUnderlyingString(value, inspectionContext) != null;
}

private string GetUnderlyingString(DkmClrValue value, DkmInspectionContext inspectionContext)
Expand Down Expand Up @@ -236,6 +236,12 @@ private string GetUnderlyingStringImpl(DkmClrValue value, DkmInspectionContext i

if (lmrType.IsString())
{
if (value.EvalFlags.HasFlag(DkmEvaluationResultFlags.TruncatedString))
{
var extendedInspectionContext = inspectionContext.With(DkmEvaluationFlags.IncreaseMaxStringSize);
return value.EvaluateToString(extendedInspectionContext);
}

return (string)value.HostObjectValue;
}
else if (!IsPredefinedType(lmrType))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,12 @@ public static bool Includes(this DkmEvaluationResultFlags flags, DkmEvaluationRe

internal static DkmInspectionContext With(this DkmInspectionContext inspectionContext, DkmEvaluationFlags flags)
{
return DkmInspectionContext.Create(
inspectionContext.InspectionSession,
inspectionContext.RuntimeInstance,
inspectionContext.Thread,
return inspectionContext.WithProperties(
inspectionContext.Timeout,
inspectionContext.EvaluationFlags | flags,
inspectionContext.FuncEvalFlags,
inspectionContext.Radix,
inspectionContext.Language,
inspectionContext.ReturnValue,
inspectionContext.AdditionalVisualizationData,
inspectionContext.AdditionalVisualizationDataPriority,
inspectionContext.ReturnValues);
inspectionContext.Radix
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ public enum DkmEvaluationFlags
NoExpansion = 65536,
FilterToFavorites = 0x40000,
UseSimpleDisplayString = 0x80000,
IncreaseMaxStringSize = 0x100000
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@ public enum DkmEvaluationResultFlags
HasFavorites = 0x4000000,
IsObjectReplaceable = 0x8000000,
ExpansionHasSideEffects = 0x10000000,
CanEvaluateWithoutOptimization = 0x20000000,
TruncatedString = 0x40000000
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ public string GetTypeName(DkmClrType ClrType, DkmClrCustomTypeInfo CustomTypeInf
{
return InspectionSession.InvokeFormatter(this, MethodId.GetTypeName, f => f.GetTypeName(this, ClrType, CustomTypeInfo, FormatSpecifiers));
}

public DkmInspectionContext WithProperties(uint Timeout, DkmEvaluationFlags EvaluationFlags, DkmFuncEvalFlags FuncEvalFlags, uint Radix)
{
return new DkmInspectionContext(
this.InspectionSession,
EvaluationFlags,
Radix,
this.RuntimeInstance);
}
}

public enum DkmFuncEvalFlags
Expand Down