-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cdac] break up cdacreader into 4 separate assemblies (#108156)
Break up the monolithic cdacreader assembly into four parts: 1. `Microsoft.Diagnostics.DataContractReader.Abstractions` just the API surface for contract implementations and clients. **Note**: everything is internal for now (with IVT for the other assemblies) - we're not committing to a public API surface yet 2. `Microsoft.Diagnostics.DataContractReader.Contracts`: the concrete implementations of the contracts and data 3. `Microsoft.Diagnostics.DataContractReader`: a concrete Target that ties everything together 4. `cdacreader`: just the unmanaged entrypoints and the legacy DAC API surface `SOSDacImpl` To untangle things I had to add a new `IContractFactory<TContract>` interface - this is what the target's ContractRegistry uses to instantiate specific versions of contracts. Goals: * Make it possible to mock a Target and its ContractRegistry so that concrete contracts can be tested in isolation for example by making dummy dependent contracts that return canned answers. * Eventually make it possible to inject additional contract implementations into a ContractRegistry implementation Make it possible to consume just the Target and Contracts without the unmanaged entrypoints or the legacy interfaces Changes: * [cdac] break up cdacreader into 4 separate assemblies * rename the contract factories using libraries naming convention * removed unused usings * document all abstract Target members * rename Target -> ContractDescriptorTarget * Add ReadTargetPointerFromSpan to abstract Target Allows the TypeNameBuidler and SigFormat to depend on the abstract target * change SOSDacImpl to depend on the abstract Target * fixup filenames and namespaces
- Loading branch information
1 parent
13e55a4
commit a7e5426
Showing
75 changed files
with
673 additions
and
287 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...aged/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/ContractRegistry.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.Diagnostics.DataContractReader.Contracts; | ||
|
||
|
||
namespace Microsoft.Diagnostics.DataContractReader; | ||
|
||
/// <summary> | ||
/// A registry of all the contracts that may be provided by a target. | ||
/// </summary> | ||
internal abstract class ContractRegistry | ||
{ | ||
/// <summary> | ||
/// Gets an instance of the Exception contract for the target. | ||
/// </summary> | ||
public abstract IException Exception { get;} | ||
/// <summary> | ||
/// Gets an instance of the Loader contract for the target. | ||
/// </summary> | ||
public abstract ILoader Loader { get; } | ||
/// <summary> | ||
/// Gets an instance of the EcmaMetadata contract for the target. | ||
/// </summary> | ||
public abstract IEcmaMetadata EcmaMetadata { get; } | ||
/// <summary> | ||
/// Gets an instance of the Object contract for the target. | ||
/// </summary> | ||
public abstract IObject Object { get; } | ||
/// <summary> | ||
/// Gets an instance of the Thread contract for the target. | ||
/// </summary> | ||
public abstract IThread Thread { get; } | ||
/// <summary> | ||
/// Gets an instance of the RuntimeTypeSystem contract for the target. | ||
/// </summary> | ||
public abstract IRuntimeTypeSystem RuntimeTypeSystem { get; } | ||
/// <summary> | ||
/// Gets an instance of the DacStreams contract for the target. | ||
/// </summary> | ||
public abstract IDacStreams DacStreams { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 1 addition & 14 deletions
15
...ed/cdacreader/src/Contracts/DacStreams.cs → ...der.Abstractions/Contracts/IDacStreams.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...ged/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IThread.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
|
||
namespace Microsoft.Diagnostics.DataContractReader.Contracts; | ||
|
||
internal record struct ThreadStoreData( | ||
int ThreadCount, | ||
TargetPointer FirstThread, | ||
TargetPointer FinalizerThread, | ||
TargetPointer GCThread); | ||
|
||
internal record struct ThreadStoreCounts( | ||
int UnstartedThreadCount, | ||
int BackgroundThreadCount, | ||
int PendingThreadCount, | ||
int DeadThreadCount); | ||
|
||
[Flags] | ||
internal enum ThreadState | ||
{ | ||
Unknown = 0x00000000, | ||
Hijacked = 0x00000080, // Return address has been hijacked | ||
Background = 0x00000200, // Thread is a background thread | ||
Unstarted = 0x00000400, // Thread has never been started | ||
Dead = 0x00000800, // Thread is dead | ||
ThreadPoolWorker = 0x01000000, // Thread is a thread pool worker thread | ||
} | ||
|
||
internal record struct ThreadData( | ||
uint Id, | ||
TargetNUInt OSId, | ||
ThreadState State, | ||
bool PreemptiveGCDisabled, | ||
TargetPointer AllocContextPointer, | ||
TargetPointer AllocContextLimit, | ||
TargetPointer Frame, | ||
TargetPointer FirstNestedException, | ||
TargetPointer TEB, | ||
TargetPointer LastThrownObjectHandle, | ||
TargetPointer NextThread); | ||
|
||
internal interface IThread : IContract | ||
{ | ||
static string IContract.Name { get; } = nameof(Thread); | ||
|
||
public virtual ThreadStoreData GetThreadStoreData() => throw new NotImplementedException(); | ||
public virtual ThreadStoreCounts GetThreadCounts() => throw new NotImplementedException(); | ||
public virtual ThreadData GetThreadData(TargetPointer thread) => throw new NotImplementedException(); | ||
} | ||
|
||
internal readonly struct Thread : IThread | ||
{ | ||
// Everything throws NotImplementedException | ||
} |
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
...aged/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/IContractFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
|
||
namespace Microsoft.Diagnostics.DataContractReader; | ||
|
||
internal interface IContractFactory<out TContract> where TContract : Contracts.IContract | ||
{ | ||
TContract CreateContract(Target target, int version); | ||
} |
21 changes: 21 additions & 0 deletions
21
...aContractReader.Abstractions/Microsoft.Diagnostics.DataContractReader.Abstractions.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework> | ||
<RootNamespace>Microsoft.Diagnostics.DataContractReader</RootNamespace> | ||
<Nullable>enable</Nullable> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<!-- Do not produce a public package. This ships as part of the runtime --> | ||
<IsShippingPackage>false</IsShippingPackage> | ||
<InvariantGlobalization>true</InvariantGlobalization> | ||
<JsonSerializerIsReflectionEnabledByDefault>false</JsonSerializerIsReflectionEnabledByDefault> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<InternalsVisibleTo Include="Microsoft.Diagnostics.DataContractReader.Tests" /> | ||
<InternalsVisibleTo Include="Microsoft.Diagnostics.DataContractReader.Contracts" /> | ||
<InternalsVisibleTo Include="Microsoft.Diagnostics.DataContractReader" /> | ||
<InternalsVisibleTo Include="cdacreader" Condition="'$(TargetsWindows)' == 'true'"/> | ||
<InternalsVisibleTo Include="libcdacreader" Condition="'$(TargetsWindows)' != 'true'"/> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.