Skip to content

Commit 259dfa9

Browse files
committed
implement getassemblydata
1 parent e6d984a commit 259dfa9

File tree

8 files changed

+297
-159
lines changed

8 files changed

+297
-159
lines changed

docs/design/datacontracts/Loader.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ TargetPointer GetStubHeap(TargetPointer loaderAllocatorPointer);
108108
| `ModuleLookupMap` | `Count` | Number of TargetPointer sized entries in this section of the map |
109109
| `ModuleLookupMap` | `Next` | Pointer to next ModuleLookupMap segment for this map |
110110
| `Assembly` | `Module` | Pointer to the Assemblies module |
111-
| `Assembly` | `IsCollectible` | Flag indicating if this is module may be collected |
111+
| `Assembly` | `IsCollectible` | Flag indicating if this module may be collected |
112+
| `Assembly` | `IsDynamic` | Flag indicating if this module is dynamic |
112113
| `Assembly` | `Error` | Pointer to exception. No error if nullptr |
113114
| `Assembly` | `NotifyFlags` | Flags relating to the debugger/profiler notification state of the assembly |
114115
| `Assembly` | `Level` | File load level of the assembly |
@@ -481,6 +482,13 @@ bool IsCollectible(ModuleHandle handle)
481482
return isCollectible != 0;
482483
}
483484

485+
bool IsDynamic(ModuleHandle handle)
486+
{
487+
TargetPointer assembly = target.ReadPointer(handle.Address + /*Module::Assembly*/);
488+
byte isDynamic = target.Read<byte>(assembly + /* Assembly::IsDynamic*/);
489+
return isDynamic != 0;
490+
}
491+
484492
bool IsAssemblyLoaded(ModuleHandle handle)
485493
{
486494
TargetPointer assembly = target.ReadPointer(handle.Address + /*Module::Assembly*/);

src/coreclr/vm/assembly.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ struct cdac_data<Assembly>
546546
#ifdef FEATURE_COLLECTIBLE_TYPES
547547
static constexpr size_t IsCollectible = offsetof(Assembly, m_isCollectible);
548548
#endif
549+
static constexpr size_t IsDynamic = offsetof(Assembly, m_isDynamic);
549550
static constexpr size_t Module = offsetof(Assembly, m_pModule);
550551
static constexpr size_t Error = offsetof(Assembly, m_pError);
551552
static constexpr size_t NotifyFlags = offsetof(Assembly, m_notifyFlags);

src/coreclr/vm/datadescriptor/datadescriptor.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ CDAC_TYPE_INDETERMINATE(Assembly)
187187
#ifdef FEATURE_COLLECTIBLE_TYPES
188188
CDAC_TYPE_FIELD(Assembly, /*uint8*/, IsCollectible, cdac_data<Assembly>::IsCollectible)
189189
#endif
190+
CDAC_TYPE_FIELD(Assembly, /*bool*/, IsDynamic, cdac_data<Assembly>::IsDynamic)
190191
CDAC_TYPE_FIELD(Assembly, /*pointer*/, Module, cdac_data<Assembly>::Module)
191192
CDAC_TYPE_FIELD(Assembly, /*pointer*/, Error, cdac_data<Assembly>::Error)
192193
CDAC_TYPE_FIELD(Assembly, /*uint32*/, NotifyFlags, cdac_data<Assembly>::NotifyFlags)

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/ILoader.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public interface ILoader : IContract
9898
ModuleLookupTables GetLookupTables(ModuleHandle handle) => throw new NotImplementedException();
9999
TargetPointer GetModuleLookupMapElement(TargetPointer table, uint token, out TargetNUInt flags) => throw new NotImplementedException();
100100
bool IsCollectible(ModuleHandle handle) => throw new NotImplementedException();
101+
bool IsDynamic(ModuleHandle handle) => throw new NotImplementedException();
101102
bool IsAssemblyLoaded(ModuleHandle handle) => throw new NotImplementedException();
102103

103104
TargetPointer GetGlobalLoaderAllocator() => throw new NotImplementedException();

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Loader_1.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,17 @@ TargetPointer ILoader.GetModuleLookupMapElement(TargetPointer table, uint token,
386386
bool ILoader.IsCollectible(ModuleHandle handle)
387387
{
388388
Data.Module module = _target.ProcessedData.GetOrAdd<Data.Module>(handle.Address);
389-
TargetPointer assembly = module.Assembly;
390-
Data.Assembly la = _target.ProcessedData.GetOrAdd<Data.Assembly>(assembly);
389+
Data.Assembly la = _target.ProcessedData.GetOrAdd<Data.Assembly>(module.Assembly);
391390
return la.IsCollectible != 0;
392391
}
393392

393+
bool ILoader.IsDynamic(ModuleHandle handle)
394+
{
395+
Data.Module module = _target.ProcessedData.GetOrAdd<Data.Module>(handle.Address);
396+
Data.Assembly assembly = _target.ProcessedData.GetOrAdd<Data.Assembly>(module.Assembly);
397+
return assembly.IsDynamic;
398+
}
399+
394400
bool ILoader.IsAssemblyLoaded(ModuleHandle handle)
395401
{
396402
Data.Module module = _target.ProcessedData.GetOrAdd<Data.Module>(handle.Address);

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/Assembly.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ public Assembly(Target target, TargetPointer address)
1414

1515
Module = target.ReadPointer(address + (ulong)type.Fields[nameof(Module)].Offset);
1616
IsCollectible = target.Read<byte>(address + (ulong)type.Fields[nameof(IsCollectible)].Offset);
17+
IsDynamic = target.Read<byte>(address + (ulong)type.Fields[nameof(IsDynamic)].Offset) != 0;
1718
Error = target.ReadPointer(address + (ulong)type.Fields[nameof(Error)].Offset);
1819
NotifyFlags = target.Read<uint>(address + (ulong)type.Fields[nameof(NotifyFlags)].Offset);
1920
Level = target.Read<uint>(address + (ulong)type.Fields[nameof(Level)].Offset);
2021
}
2122

2223
public TargetPointer Module { get; init; }
2324
public byte IsCollectible { get; init; }
25+
public bool IsDynamic { get; init; }
2426
public TargetPointer Error { get; init; }
2527
public uint NotifyFlags { get; init; }
2628
public uint Level { get; init; }

src/native/managed/cdac/mscordaccore_universal/Legacy/ISOSDacInterface.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,21 @@ internal struct DacpAppDomainStoreData
7474
public ClrDataAddress systemDomain;
7575
public int DomainCount;
7676
};
77+
78+
internal struct DacpAssemblyData
79+
{
80+
public ClrDataAddress AssemblyPtr;
81+
public ClrDataAddress ClassLoader;
82+
public ClrDataAddress ParentDomain;
83+
public ClrDataAddress DomainPtr;
84+
public ClrDataAddress AssemblySecDesc;
85+
public int isDynamic;
86+
public uint ModuleCount;
87+
public uint LoadContext;
88+
public int isDomainNeutral; // Always false, preserved for backward compatibility
89+
public uint dwLocationFlags;
90+
}
91+
7792
internal struct DacpThreadData
7893
{
7994
public int corThreadId;
@@ -270,7 +285,7 @@ internal unsafe partial interface ISOSDacInterface
270285
[PreserveSig]
271286
int GetAssemblyList(ClrDataAddress appDomain, int count, [In, Out, MarshalUsing(CountElementName = nameof(count))] ClrDataAddress[]? values, int* pNeeded);
272287
[PreserveSig]
273-
int GetAssemblyData(ClrDataAddress baseDomainPtr, ClrDataAddress assembly, /*struct DacpAssemblyData*/ void* data);
288+
int GetAssemblyData(ClrDataAddress domain, ClrDataAddress assembly, DacpAssemblyData* data);
274289
[PreserveSig]
275290
int GetAssemblyName(ClrDataAddress assembly, uint count, char* name, uint* pNeeded);
276291

0 commit comments

Comments
 (0)