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

Fix a couple of issues for statics in sos14 #1285

Merged
merged 1 commit into from
Sep 12, 2024
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 @@ -233,7 +233,7 @@ public ulong GetStaticFieldAddress(in AppDomainInfo appDomain, in ClrModuleInfo
{
if (_sos14 is not null)
{
(ulong nonGcBase, ulong gcBase) = _sos14.GetStaticBaseAddress(module.Address);
(ulong nonGcBase, ulong gcBase) = _sos14.GetStaticBaseAddress(type.MethodTable);
if (field.ElementType.IsPrimitive())
return nonGcBase + (uint)field.Offset;

Expand Down Expand Up @@ -275,7 +275,7 @@ public ulong GetThreadStaticFieldAddress(ulong threadAddress, in ClrModuleInfo m

if (_sos14 is not null)
{
(ulong nonGcBase, ulong gcBase) = _sos14.GetThreadStaticBaseAddress(module.Address, threadAddress);
(ulong nonGcBase, ulong gcBase) = _sos14.GetThreadStaticBaseAddress(type.MethodTable, threadAddress);
if (field.ElementType.IsPrimitive())
return nonGcBase + (uint)field.Offset;

Expand Down
8 changes: 4 additions & 4 deletions src/Microsoft.Diagnostics.Runtime/DacInterface/SosDac14.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public SosDac14(DacLibrary library, IntPtr ptr)

private ref readonly ISOSDac14VTable VTable => ref Unsafe.AsRef<ISOSDac14VTable>(_vtable);

public (ulong NonGCStaticsBase, ulong GCStaticsBase) GetStaticBaseAddress(ClrDataAddress module)
public (ulong NonGCStaticsBase, ulong GCStaticsBase) GetStaticBaseAddress(ClrDataAddress methodTable)
{
HResult hr = VTable.GetStaticBaseAddress(Self, module, out ClrDataAddress nonGCStaticsBase, out ClrDataAddress gcStaticsBase);
HResult hr = VTable.GetStaticBaseAddress(Self, methodTable, out ClrDataAddress nonGCStaticsBase, out ClrDataAddress gcStaticsBase);
return hr ? (nonGCStaticsBase, gcStaticsBase) : (0, 0);
}

public (ulong NonGCThreadStaticsBase, ulong GCThreadStaticsBase) GetThreadStaticBaseAddress(ClrDataAddress module, ClrDataAddress thread)
public (ulong NonGCThreadStaticsBase, ulong GCThreadStaticsBase) GetThreadStaticBaseAddress(ClrDataAddress methodTable, ClrDataAddress thread)
{
HResult hr = VTable.GetThreadStaticBaseAddress(Self, module, thread, out ClrDataAddress nonGCThreadStaticsBase, out ClrDataAddress gcThreadStaticsBase);
HResult hr = VTable.GetThreadStaticBaseAddress(Self, methodTable, thread, out ClrDataAddress nonGCThreadStaticsBase, out ClrDataAddress gcThreadStaticsBase);
return hr ? (nonGCThreadStaticsBase, gcThreadStaticsBase) : (0, 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static class ClrElementTypeExtensions
public static bool IsPrimitive(this ClrElementType cet)
{
return cet is >= ClrElementType.Boolean and <= ClrElementType.Double
or ClrElementType.NativeInt or ClrElementType.NativeUInt;
or ClrElementType.NativeInt or ClrElementType.NativeUInt or ClrElementType.Pointer;
}

public static bool IsValueType(this ClrElementType cet)
Expand Down