Skip to content
Merged
Changes from 1 commit
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
19 changes: 11 additions & 8 deletions src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ internal sealed unsafe partial class SOSDacImpl
ISOSDacInterface11, ISOSDacInterface12, ISOSDacInterface13, ISOSDacInterface14, ISOSDacInterface15
{
private readonly Target _target;
private readonly TargetPointer _stringMethodTable;
private readonly TargetPointer _objectMethodTable;
private readonly Lazy<TargetPointer> _stringMethodTable;
private readonly Lazy<TargetPointer> _objectMethodTable;

private readonly ISOSDacInterface? _legacyImpl;
private readonly ISOSDacInterface2? _legacyImpl2;
Expand All @@ -52,8 +52,11 @@ internal sealed unsafe partial class SOSDacImpl
public SOSDacImpl(Target target, object? legacyObj)
{
_target = target;
_stringMethodTable = _target.ReadPointer(_target.ReadGlobalPointer(Constants.Globals.StringMethodTable));
_objectMethodTable = _target.ReadPointer(_target.ReadGlobalPointer(Constants.Globals.ObjectMethodTable));
_stringMethodTable = new Lazy<TargetPointer>(
() => _target.ReadPointer(_target.ReadGlobalPointer(Constants.Globals.StringMethodTable)));

_objectMethodTable = new Lazy<TargetPointer>(
() => _target.ReadPointer(_target.ReadGlobalPointer(Constants.Globals.ObjectMethodTable)));

// Get all the interfaces for delegating to the legacy DAC
if (legacyObj is not null)
Expand Down Expand Up @@ -619,14 +622,14 @@ int ISOSDacInterface.GetObjectData(ulong objAddr, DacpObjectData* data)
ulong numComponentsOffset = (ulong)_target.GetTypeInfo(DataType.Array).Fields[Data.Array.FieldNames.NumComponents].Offset;
data->Size += _target.Read<uint>(objAddr + numComponentsOffset) * data->dwComponentSize;
}
else if (mt == _stringMethodTable)
else if (mt == _stringMethodTable.Value)
{
data->ObjectType = DacpObjectType.OBJ_STRING;

// Update the size to include the string character components
data->Size += (uint)objectContract.GetStringValue(objAddr).Length * data->dwComponentSize;
}
else if (mt == _objectMethodTable)
else if (mt == _objectMethodTable.Value)
{
data->ObjectType = DacpObjectType.OBJ_OBJECT;
}
Expand Down Expand Up @@ -967,8 +970,8 @@ int ISOSDacInterface.GetUsefulGlobals(DacpUsefulGlobalsData* data)
{
data->ArrayMethodTable = _target.ReadPointer(
_target.ReadGlobalPointer(Constants.Globals.ObjectArrayMethodTable));
data->StringMethodTable = _stringMethodTable;
data->ObjectMethodTable = _objectMethodTable;
data->StringMethodTable = _stringMethodTable.Value;
data->ObjectMethodTable = _objectMethodTable.Value;
data->ExceptionMethodTable = _target.ReadPointer(
_target.ReadGlobalPointer(Constants.Globals.ExceptionMethodTable));
data->FreeMethodTable = _target.ReadPointer(
Expand Down
Loading