Skip to content

Make cdac APIs public but experimental #111180

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

Merged
merged 3 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 8 additions & 0 deletions src/native/managed/cdacreader/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<Import Project="..\Directory.Build.props" />
<ItemGroup>
<AssemblyAttribute Include="System.Diagnostics.CodeAnalysis.ExperimentalAttribute">
<_Parameter1>NETCDAC0001</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.Diagnostics.DataContractReader;
/// <summary>
/// A registry of all the contracts that may be provided by a target.
/// </summary>
internal abstract class ContractRegistry
public abstract class ContractRegistry
{
/// <summary>
/// Gets an instance of the Exception contract for the target.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

namespace Microsoft.Diagnostics.DataContractReader.Contracts.Extensions;

internal static class ICodeVersionsExtensions
public static class ICodeVersionsExtensions
{
internal static NativeCodeVersionHandle GetActiveNativeCodeVersion(this ICodeVersions cv, TargetPointer methodDesc)
public static NativeCodeVersionHandle GetActiveNativeCodeVersion(this ICodeVersions cv, TargetPointer methodDesc)
{
ILCodeVersionHandle ilCodeVersionHandle = cv.GetActiveILCodeVersion(methodDesc);
return cv.GetActiveNativeCodeVersionForILCodeVersion(methodDesc, ilCodeVersionHandle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Microsoft.Diagnostics.DataContractReader.Contracts.Extensions;

internal static class IReJITExtensions
public static class IReJITExtensions
{
public static IEnumerable<TargetNUInt> GetRejitIds(this IReJIT rejit, Target target, TargetPointer methodDesc)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Microsoft.Diagnostics.DataContractReader.Contracts;

internal interface ICodeVersions : IContract
public interface ICodeVersions : IContract
{
static string IContract.Name { get; } = nameof(CodeVersions);

Expand All @@ -27,11 +27,11 @@ internal interface ICodeVersions : IContract
public virtual bool CodeVersionManagerSupportsMethod(TargetPointer methodDesc) => throw new NotImplementedException();
}

internal readonly struct ILCodeVersionHandle
public readonly struct ILCodeVersionHandle
{
internal readonly TargetPointer Module;
internal readonly uint MethodDefinition;
internal readonly TargetPointer ILCodeVersionNode;
public readonly TargetPointer Module;
public readonly uint MethodDefinition;
public readonly TargetPointer ILCodeVersionNode;
private ILCodeVersionHandle(TargetPointer module, uint methodDef, TargetPointer ilCodeVersionNodeAddress)
{
if (module != TargetPointer.Null && ilCodeVersionNodeAddress != TargetPointer.Null)
Expand All @@ -49,23 +49,23 @@ private ILCodeVersionHandle(TargetPointer module, uint methodDef, TargetPointer
}

// for more information on Explicit/Synthetic code versions see docs/design/features/code-versioning.md
internal static ILCodeVersionHandle CreateExplicit(TargetPointer ilCodeVersionNodeAddress) =>
public static ILCodeVersionHandle CreateExplicit(TargetPointer ilCodeVersionNodeAddress) =>
new ILCodeVersionHandle(TargetPointer.Null, 0, ilCodeVersionNodeAddress);
internal static ILCodeVersionHandle CreateSynthetic(TargetPointer module, uint methodDef) =>
public static ILCodeVersionHandle CreateSynthetic(TargetPointer module, uint methodDef) =>
new ILCodeVersionHandle(module, methodDef, TargetPointer.Null);

public static ILCodeVersionHandle Invalid { get; } = new(TargetPointer.Null, 0, TargetPointer.Null);

public bool IsValid => Module != TargetPointer.Null || ILCodeVersionNode != TargetPointer.Null;

internal bool IsExplicit => ILCodeVersionNode != TargetPointer.Null;
public bool IsExplicit => ILCodeVersionNode != TargetPointer.Null;
}

internal readonly struct NativeCodeVersionHandle
public readonly struct NativeCodeVersionHandle
{
// no public constructors
internal readonly TargetPointer MethodDescAddress;
internal readonly TargetPointer CodeVersionNodeAddress;
public readonly TargetPointer MethodDescAddress;
public readonly TargetPointer CodeVersionNodeAddress;
private NativeCodeVersionHandle(TargetPointer methodDescAddress, TargetPointer codeVersionNodeAddress)
{
if (methodDescAddress != TargetPointer.Null && codeVersionNodeAddress != TargetPointer.Null)
Expand All @@ -77,19 +77,19 @@ private NativeCodeVersionHandle(TargetPointer methodDescAddress, TargetPointer c
}

// for more information on Explicit/Synthetic code versions see docs/design/features/code-versioning.md
internal static NativeCodeVersionHandle CreateExplicit(TargetPointer codeVersionNodeAddress) =>
public static NativeCodeVersionHandle CreateExplicit(TargetPointer codeVersionNodeAddress) =>
new NativeCodeVersionHandle(TargetPointer.Null, codeVersionNodeAddress);
internal static NativeCodeVersionHandle CreateSynthetic(TargetPointer methodDescAddress) =>
public static NativeCodeVersionHandle CreateSynthetic(TargetPointer methodDescAddress) =>
new NativeCodeVersionHandle(methodDescAddress, TargetPointer.Null);

public static NativeCodeVersionHandle Invalid { get; } = new(TargetPointer.Null, TargetPointer.Null);

public bool Valid => MethodDescAddress != TargetPointer.Null || CodeVersionNodeAddress != TargetPointer.Null;

internal bool IsExplicit => CodeVersionNodeAddress != TargetPointer.Null;
public bool IsExplicit => CodeVersionNodeAddress != TargetPointer.Null;
}

internal readonly struct CodeVersions : ICodeVersions
public readonly struct CodeVersions : ICodeVersions
{
// throws NotImplementedException for all methods
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Microsoft.Diagnostics.DataContractReader.Contracts;

internal interface IContract
public interface IContract
{
static virtual string Name => throw new NotImplementedException();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

namespace Microsoft.Diagnostics.DataContractReader.Contracts;

internal interface IDacStreams : IContract
public interface IDacStreams : IContract
{
static string IContract.Name { get; } = nameof(DacStreams);
public virtual string? StringFromEEAddress(TargetPointer address) => throw new NotImplementedException();
}

internal readonly struct DacStreams : IDacStreams
public readonly struct DacStreams : IDacStreams
{
// Everything throws NotImplementedException
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

namespace Microsoft.Diagnostics.DataContractReader.Contracts;

internal interface IEcmaMetadata : IContract
public interface IEcmaMetadata : IContract
{
static string IContract.Name { get; } = nameof(EcmaMetadata);
public virtual TargetSpan GetReadOnlyMetadataAddress(ModuleHandle handle) => throw new NotImplementedException();
public virtual MetadataReader? GetMetadata(ModuleHandle module) => throw new NotImplementedException();
}

internal readonly struct EcmaMetadata : IEcmaMetadata
public readonly struct EcmaMetadata : IEcmaMetadata
{
// Everything throws NotImplementedException
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Microsoft.Diagnostics.DataContractReader.Contracts;

internal record struct ExceptionData(
public record struct ExceptionData(
TargetPointer Message,
TargetPointer InnerException,
TargetPointer StackTrace,
Expand All @@ -15,15 +15,15 @@ internal record struct ExceptionData(
int HResult,
int XCode);

internal interface IException : IContract
public interface IException : IContract
{
static string IContract.Name { get; } = nameof(Exception);

public virtual TargetPointer GetNestedExceptionInfo(TargetPointer exception, out TargetPointer nextNestedException) => throw new NotImplementedException();
public virtual ExceptionData GetExceptionData(TargetPointer managedException) => throw new NotImplementedException();
}

internal readonly struct Exception : IException
public readonly struct Exception : IException
{
// Everything throws NotImplementedException
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@

namespace Microsoft.Diagnostics.DataContractReader.Contracts;

internal struct CodeBlockHandle
public struct CodeBlockHandle
{
public readonly TargetPointer Address;
internal CodeBlockHandle(TargetPointer address) => Address = address;
public CodeBlockHandle(TargetPointer address) => Address = address;
}

internal interface IExecutionManager : IContract
public interface IExecutionManager : IContract
{
static string IContract.Name { get; } = nameof(ExecutionManager);
CodeBlockHandle? GetCodeBlockHandle(TargetCodePointer ip) => throw new NotImplementedException();
TargetPointer GetMethodDesc(CodeBlockHandle codeInfoHandle) => throw new NotImplementedException();
TargetCodePointer GetStartAddress(CodeBlockHandle codeInfoHandle) => throw new NotImplementedException();
}

internal readonly struct ExecutionManager : IExecutionManager
public readonly struct ExecutionManager : IExecutionManager
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@

namespace Microsoft.Diagnostics.DataContractReader.Contracts;

internal readonly struct ModuleHandle
public readonly struct ModuleHandle
{
internal ModuleHandle(TargetPointer address)
public ModuleHandle(TargetPointer address)
{
Address = address;
}

internal TargetPointer Address { get; }
public TargetPointer Address { get; }
}

[Flags]
internal enum ModuleFlags
public enum ModuleFlags
{
EditAndContinue = 0x00000008, // Edit and Continue is enabled for this module
ReflectionEmit = 0x00000040, // Reflection.Emit was used to create this module
}

internal record struct ModuleLookupTables(
public record struct ModuleLookupTables(
TargetPointer FieldDefToDesc,
TargetPointer ManifestModuleReferences,
TargetPointer MemberRefToDesc,
Expand All @@ -32,7 +32,7 @@ internal record struct ModuleLookupTables(
TargetPointer TypeRefToMethodTable,
TargetPointer MethodDefToILCodeVersioningState);

internal interface ILoader : IContract
public interface ILoader : IContract
{
static string IContract.Name => nameof(Loader);

Expand All @@ -52,7 +52,7 @@ internal interface ILoader : IContract
public virtual bool IsCollectible(ModuleHandle handle) => throw new NotImplementedException();
}

internal readonly struct Loader : ILoader
public readonly struct Loader : ILoader
{
// Everything throws NotImplementedException
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Microsoft.Diagnostics.DataContractReader.Contracts;

internal interface IObject : IContract
public interface IObject : IContract
{
static string IContract.Name { get; } = nameof(Object);
public virtual TargetPointer GetMethodTableAddress(TargetPointer address) => throw new NotImplementedException();
Expand All @@ -14,7 +14,7 @@ internal interface IObject : IContract
public virtual bool GetBuiltInComData(TargetPointer address, out TargetPointer rcw, out TargetPointer ccw) => throw new NotImplementedException();
}

internal readonly struct Object : IObject
public readonly struct Object : IObject
{
// Everything throws NotImplementedException
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@

namespace Microsoft.Diagnostics.DataContractReader.Contracts;

internal enum CodePointerFlags : byte
public enum CodePointerFlags : byte
{
HasArm32ThumbBit = 0x1,
HasArm64PtrAuth = 0x2,
}

internal interface IPlatformMetadata : IContract
public interface IPlatformMetadata : IContract
{
static string IContract.Name { get; } = nameof(PlatformMetadata);
TargetPointer GetPrecodeMachineDescriptor() => throw new NotImplementedException();
CodePointerFlags GetCodePointerFlags() => throw new NotImplementedException();
}

internal readonly struct PlatformMetadata : IPlatformMetadata
public readonly struct PlatformMetadata : IPlatformMetadata
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

namespace Microsoft.Diagnostics.DataContractReader.Contracts;

internal interface IPrecodeStubs : IContract
public interface IPrecodeStubs : IContract
{
static string IContract.Name { get; } = nameof(PrecodeStubs);
TargetPointer GetMethodDescFromStubAddress(TargetCodePointer entryPoint) => throw new NotImplementedException();
}

internal readonly struct PrecodeStubs : IPrecodeStubs
public readonly struct PrecodeStubs : IPrecodeStubs
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public enum RejitState
Active
}

internal interface IReJIT : IContract
public interface IReJIT : IContract
{
static string IContract.Name { get; } = nameof(ReJIT);

Expand All @@ -23,7 +23,7 @@ internal interface IReJIT : IContract
TargetNUInt GetRejitId(ILCodeVersionHandle codeVersionHandle) => throw new NotImplementedException();
}

internal readonly struct ReJIT : IReJIT
public readonly struct ReJIT : IReJIT
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
namespace Microsoft.Diagnostics.DataContractReader.Contracts;

// an opaque handle to a type handle. See IMetadata.GetMethodTableData
internal readonly struct TypeHandle
public readonly struct TypeHandle
{
internal TypeHandle(TargetPointer address)
public TypeHandle(TargetPointer address)
{
Address = address;
}

internal TargetPointer Address { get; }
public TargetPointer Address { get; }

internal bool IsNull => Address == 0;
public bool IsNull => Address == 0;
}

internal enum CorElementType
public enum CorElementType
{
Void = 1,
Boolean = 2,
Expand Down Expand Up @@ -55,14 +55,14 @@ internal enum CorElementType
Sentinel = 0x41,
}

internal readonly struct MethodDescHandle
public readonly struct MethodDescHandle
{
internal MethodDescHandle(TargetPointer address)
public MethodDescHandle(TargetPointer address)
{
Address = address;
}

internal TargetPointer Address { get; }
public TargetPointer Address { get; }
}

public enum ArrayFunctionType
Expand All @@ -73,7 +73,7 @@ public enum ArrayFunctionType
Constructor = 3
}

internal interface IRuntimeTypeSystem : IContract
public interface IRuntimeTypeSystem : IContract
{
static string IContract.Name => nameof(RuntimeTypeSystem);

Expand Down Expand Up @@ -171,7 +171,7 @@ internal interface IRuntimeTypeSystem : IContract
#endregion MethodDesc inspection APIs
}

internal struct RuntimeTypeSystem : IRuntimeTypeSystem
public struct RuntimeTypeSystem : IRuntimeTypeSystem
{
// Everything throws NotImplementedException
}
Loading
Loading