Skip to content
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
6 changes: 3 additions & 3 deletions docs/design/datacontracts/DebugInfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ bool HasDebugInfo(TargetCodePointer pCode);
IEnumerable<OffsetMapping> GetMethodNativeMap(TargetCodePointer pCode, bool preferUninstrumented, out uint codeOffset);
```

## Version 2
## Version 1

<!-- BEGIN GENERATED: usage contract=DebugInfo version=c2 -->
<!-- BEGIN GENERATED: usage contract=DebugInfo version=c1 -->
### Data descriptors used

_None._
Expand All @@ -54,7 +54,7 @@ _None._
| `ExecutionManager` |
| `PlatformMetadata` |
| `RuntimeInfo` |
<!-- END GENERATED: usage contract=DebugInfo version=c2 -->
<!-- END GENERATED: usage contract=DebugInfo version=c1 -->

### Constants

Expand Down
6 changes: 3 additions & 3 deletions docs/design/datacontracts/ExecutionManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ public enum CodeKind : uint
}
```

## Version 2
## Version 1

The execution manager uses two data structures to map the entire target address space to native executable code.
The [range section map](#rangesectionmap) is used to partition the address space into large chunks which point to range section fragments. Each chunk is relatively large. If there is any executable code in the chunk, the chunk will contain one or more range section fragments that cover subsets of the chunk. Conversely if a massive method is JITed a single range section fragment may span multiple adjacent chunks.

Within a range section fragment, a [nibble map](#nibblemap) structure is used to map arbitrary IP addresses back to the start of the method (and to the code header which immediately preceeeds the entrypoint to the code).

<!-- BEGIN GENERATED: usage contract=ExecutionManager version=c2 -->
<!-- BEGIN GENERATED: usage contract=ExecutionManager version=c1 -->
### Data descriptors used

| Data Descriptor | Field | Type | Meaning |
Expand Down Expand Up @@ -272,7 +272,7 @@ Within a range section fragment, a [nibble map](#nibblemap) structure is used to
| `PrecodeStubs` |
| `RuntimeInfo` |
| `RuntimeTypeSystem` |
<!-- END GENERATED: usage contract=ExecutionManager version=c2 -->
<!-- END GENERATED: usage contract=ExecutionManager version=c1 -->

Contract constants used:
| Name | Type | Purpose | Value |
Expand Down
6 changes: 3 additions & 3 deletions docs/design/datacontracts/PrecodeStubs.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ This contract provides support for examining [precode](../coreclr/botr/method-de
TargetCodePointer GetInterpreterCodeFromInterpreterPrecodeIfPresent(TargetCodePointer entryPoint);
```

## Version 3
## Version 1

<!-- BEGIN GENERATED: usage contract=PrecodeStubs version=c3 -->
<!-- BEGIN GENERATED: usage contract=PrecodeStubs version=c1 -->
### Data descriptors used

| Data Descriptor | Field | Type | Meaning |
Expand Down Expand Up @@ -55,7 +55,7 @@ _None._
| Contract Name |
| --- |
| `PlatformMetadata` |
<!-- END GENERATED: usage contract=PrecodeStubs version=c3 -->
<!-- END GENERATED: usage contract=PrecodeStubs version=c1 -->

The `CodePointerToInstrPointerMask` converts IP values that may include an arm Thumb bit
(for example, extracted from disassembling a call instruction or from a snapshot of the
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/vm/datadescriptor/datadescriptor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1851,13 +1851,13 @@ CDAC_GLOBAL_CONTRACT(DacStreams, c1)
#if defined(DEBUGGING_SUPPORTED) && !defined(TARGET_WASM)
CDAC_GLOBAL_CONTRACT(Debugger, c1)
#endif // DEBUGGING_SUPPORTED && !TARGET_WASM
CDAC_GLOBAL_CONTRACT(DebugInfo, c2)
CDAC_GLOBAL_CONTRACT(DebugInfo, c1)
CDAC_GLOBAL_CONTRACT(EcmaMetadata, c1)
#ifdef FEATURE_METADATA_UPDATER
CDAC_GLOBAL_CONTRACT(RuntimeMutableTypeSystem, c1)
#endif // FEATURE_METADATA_UPDATER
CDAC_GLOBAL_CONTRACT(Exception, c1)
CDAC_GLOBAL_CONTRACT(ExecutionManager, c2)
CDAC_GLOBAL_CONTRACT(ExecutionManager, c1)
CDAC_GLOBAL_CONTRACT(GCInfo, c1)
CDAC_GLOBAL_CONTRACT(Loader, c1)
CDAC_GLOBAL_CONTRACT(ManagedTypeSource, c1)
Expand All @@ -1868,7 +1868,7 @@ CDAC_GLOBAL_CONTRACT(ObjectiveCMarshal, c1)
CDAC_GLOBAL_CONTRACT(Object, c1)
CDAC_GLOBAL_CONTRACT(FeatureFlags, c1)
CDAC_GLOBAL_CONTRACT(PlatformMetadata, c1)
CDAC_GLOBAL_CONTRACT(PrecodeStubs, c3)
CDAC_GLOBAL_CONTRACT(PrecodeStubs, c1)
#ifdef PROFILING_SUPPORTED
CDAC_GLOBAL_CONTRACT(ReJIT, c1)
#endif // PROFILING_SUPPORTED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Microsoft.Diagnostics.DataContractReader.Contracts;

internal sealed class DebugInfo_2(Target target) : IDebugInfo
internal sealed class DebugInfo_1(Target target) : IDebugInfo
{
private const uint DEBUG_INFO_FAT = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

namespace Microsoft.Diagnostics.DataContractReader.Contracts;

public sealed class ExecutionManager_2 : IExecutionManager
public sealed class ExecutionManager_1 : IExecutionManager
{
private IExecutionManager _executionManagerCore;

internal ExecutionManager_2(Target target)
internal ExecutionManager_1(Target target)
{
TargetPointer addr = target.ReadGlobalPointer(Constants.Globals.ExecutionManagerCodeRangeMapAddress);
_executionManagerCore = new ExecutionManagerCore<NibbleMapConstantLookup>(target, addr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Microsoft.Diagnostics.DataContractReader.Contracts;

internal struct PrecodeStubs_3_Impl : IPrecodeStubsContractCommonApi
internal struct PrecodeStubs_1_Impl : IPrecodeStubsContractCommonApi
{
public static TargetPointer StubPrecode_GetMethodDesc(TargetPointer instrPointer, Target target, Data.PrecodeMachineDescriptor precodeMachineDescriptor)
{
Expand Down Expand Up @@ -106,9 +106,9 @@ static bool ReadBytesAndCompare(TargetPointer instrAddress, byte[] expectedByteP
}
}

internal sealed class PrecodeStubs_3 : PrecodeStubsCommon<PrecodeStubs_3_Impl>
internal sealed class PrecodeStubs_1 : PrecodeStubsCommon<PrecodeStubs_1_Impl>
{
public PrecodeStubs_3(Target target) : base(target) { }
public PrecodeStubs_1(Target target) : base(target) { }

public override TargetCodePointer GetInterpreterCodeFromInterpreterPrecodeIfPresent(
TargetCodePointer entryPoint)
Expand All @@ -119,7 +119,7 @@ public override TargetCodePointer GetInterpreterCodeFromInterpreterPrecodeIfPres
if (!Target.IsAlignedToPointerSize(instrPointer))
return entryPoint;

if (PrecodeStubs_3_Impl.TryGetKnownPrecodeType(
if (PrecodeStubs_1_Impl.TryGetKnownPrecodeType(
instrPointer,
Target,
MachineDescriptor) is not KnownPrecodeType.Interpreter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void Register(ContractRegistry registry)
registry.Register<IAuxiliarySymbols>("c1", static t => new AuxiliarySymbols_1(t));
registry.Register<IDebugger>("c1", static t => new Debugger_1(t));

registry.Register<IDebugInfo>("c2", static t => new DebugInfo_2(t));
registry.Register<IDebugInfo>("c1", static t => new DebugInfo_1(t));
registry.Register<IStressLog>("c1", static t => new StressLog_1(t));
registry.Register<IStressLog>("c2", static t => new StressLog_2(t));

Expand All @@ -49,7 +49,7 @@ public static void Register(ContractRegistry registry)

registry.Register<IFeatureFlags>("c1", static t => new FeatureFlags_1(t));

registry.Register<IPrecodeStubs>("c3", static t => new PrecodeStubs_3(t));
registry.Register<IPrecodeStubs>("c1", static t => new PrecodeStubs_1(t));

registry.Register<IReJIT>("c1", static t => new ReJIT_1(t));

Expand All @@ -72,7 +72,7 @@ public static void Register(ContractRegistry registry)

registry.Register<ISyncBlock>("c1", static t => new SyncBlock_1(t));

registry.Register<IExecutionManager>("c2", static t => new ExecutionManager_2(t));
registry.Register<IExecutionManager>("c1", static t => new ExecutionManager_1(t));

registry.Register<IRuntimeMutableTypeSystem>("c1", static t => new RuntimeMutableTypeSystem_1(t));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,18 +379,18 @@ public void TryGetContract_UnrecognizedVersion_ReturnsContractUnrecognizedExcept
["ConditionalWeakTable"] = "c1",
["DacStreams"] = "c1",
["Debugger"] = "c1",
["DebugInfo"] = "c2",
["DebugInfo"] = "c1",
["EcmaMetadata"] = "c1",
["Exception"] = "c1",
["ExecutionManager"] = "c2",
["ExecutionManager"] = "c1",
["FeatureFlags"] = "c1",
["GC"] = "c1",
["GCInfo"] = "c1",
["Loader"] = "c1",
["Notifications"] = "c1",
["Object"] = "c1",
["PlatformMetadata"] = "c1",
["PrecodeStubs"] = "c3",
["PrecodeStubs"] = "c1",
["ReJIT"] = "c1",
["RuntimeInfo"] = "c1",
["RuntimeMutableTypeSystem"] = "c1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public void GetMethodDesc_R2R_OneRuntimeFunction(string version, MockTarget.Arch
// (32-bit little-endian) target, treating the code address as a virtual IP, and confirms the
// R2R classification.
[Theory]
[InlineData("c2")]
[InlineData("c1")]
public void GetMethodDesc_R2R_WasmVirtualIP(string version)
{
MockTarget.Architecture wasmArch = new() { IsLittleEndian = true, Is64Bit = false };
Expand Down Expand Up @@ -916,7 +916,7 @@ public static IEnumerable<object[]> StdArchAllVersions()
foreach (object[] arr in new MockTarget.StdArch())
{
MockTarget.Architecture arch = (MockTarget.Architecture)arr[0];
yield return new object[] { "c2", arch };
yield return new object[] { "c1", arch };
}
}

Expand Down Expand Up @@ -1175,7 +1175,7 @@ public void GetDynamicFunctionTableEntries_UnsupportedPlatform_ReturnsEmpty(
RuntimeInfoArchitecture architecture)
{
MockTarget.Architecture targetArchitecture = new() { IsLittleEndian = true, Is64Bit = true };
MockExecutionManagerBuilder emBuilder = new("c2", targetArchitecture, MockExecutionManagerBuilder.DefaultAllocationRange);
MockExecutionManagerBuilder emBuilder = new("c1", targetArchitecture, MockExecutionManagerBuilder.DefaultAllocationRange);
Target target = CreateTarget(emBuilder, operatingSystem, architecture);

IReadOnlyList<TargetPointer> entries =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ public NibbleMapTestBuilderBase(TargetPointer mapBase, ulong mapRangeSize, MockM
public abstract void AllocateCodeChunk(TargetCodePointer codeStart, uint codeSize);
}

internal class NibbleMapTestBuilder_2 : NibbleMapTestBuilderBase
internal class NibbleMapTestBuilder_1 : NibbleMapTestBuilderBase
{
public NibbleMapTestBuilder_2(TargetPointer mapBase, ulong mapRangeSize, TargetPointer mapStart, MockTarget.Architecture arch)
public NibbleMapTestBuilder_1(TargetPointer mapBase, ulong mapRangeSize, TargetPointer mapStart, MockTarget.Architecture arch)
: base(mapBase, mapRangeSize, mapStart, arch)
{
}

public NibbleMapTestBuilder_2(TargetPointer mapBase, ulong mapRangeSize, MockMemorySpace.BumpAllocator allocator, MockTarget.Architecture arch)
public NibbleMapTestBuilder_1(TargetPointer mapBase, ulong mapRangeSize, MockMemorySpace.BumpAllocator allocator, MockTarget.Architecture arch)
: base(mapBase, mapRangeSize, allocator, arch)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void NibbleMapOneItemLookupOk(MockTarget.Architecture arch)
/// this is how big the address space is that the map covers
const uint MapRangeSize = 0x1000;
TargetPointer MapEnd = mapBase + MapRangeSize;
var builder = new NibbleMapTestBuilder_2(mapBase, MapRangeSize, mapStart, arch);
var builder = new NibbleMapTestBuilder_1(mapBase, MapRangeSize, mapStart, arch);

// don't put the code too close to the start - the NibbleMap bails if the code is too close to the start of the range
TargetCodePointer inputPC = new(mapBase + 0x0200u);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static IEnumerable<object[]> StdArchAllVersions()
foreach (object[] arr in new MockTarget.StdArch())
{
MockTarget.Architecture arch = (MockTarget.Architecture)arr[0];
yield return new object[] { "c2", arch };
yield return new object[] { "c1", arch };
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ internal NibbleMapTestBuilderBase CreateNibbleMap(ulong codeRangeStart, uint cod
{
NibbleMapTestBuilderBase nibBuilder = Version switch
{
"c2" => new NibbleMapTestBuilder_2(codeRangeStart, codeRangeSize, _nibbleMapAllocator, Builder.TargetTestHelpers.Arch),
"c1" => new NibbleMapTestBuilder_1(codeRangeStart, codeRangeSize, _nibbleMapAllocator, Builder.TargetTestHelpers.Arch),
_ => throw new InvalidOperationException($"Unknown version '{Version}'"),
};

Expand Down
22 changes: 11 additions & 11 deletions src/native/managed/cdac/tests/UnitTests/PrecodeStubsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ public static IEnumerable<object[]> PrecodeTestDescriptorDataWithContractVersion
{
foreach (var data in PrecodeTestDescriptorData())
{
yield return new object[]{data[0], "c3"};
yield return new object[]{data[0], "c1"};
}
}

public static IEnumerable<object[]> PrecodeTestDescriptorDataVersion3()
public static IEnumerable<object[]> PrecodeTestDescriptorDataVersion1()
{
foreach (object[] data in PrecodeTestDescriptorData())
yield return [data[0], "c3"];
yield return [data[0], "c1"];
}

internal struct AllocationRange
Expand Down Expand Up @@ -456,8 +456,8 @@ public void TestInterpreterPrecodeReturnsExpectedMethodDesc(PrecodeTestDescripto
}

[Theory]
[MemberData(nameof(PrecodeTestDescriptorDataVersion3))]
public void GetInterpreterCode_Version3_ReturnsByteCodeAddress(
[MemberData(nameof(PrecodeTestDescriptorDataVersion1))]
public void GetInterpreterCode_Version1_ReturnsByteCodeAddress(
PrecodeTestDescriptor test,
string contractVersion)
{
Expand All @@ -479,8 +479,8 @@ public void GetInterpreterCode_Version3_ReturnsByteCodeAddress(
}

[Theory]
[MemberData(nameof(PrecodeTestDescriptorDataVersion3))]
public void GetInterpreterCode_Version3NonInterpreter_ReturnsOriginalAddress(
[MemberData(nameof(PrecodeTestDescriptorDataVersion1))]
public void GetInterpreterCode_Version1NonInterpreter_ReturnsOriginalAddress(
PrecodeTestDescriptor test,
string contractVersion)
{
Expand All @@ -500,8 +500,8 @@ public void GetInterpreterCode_Version3NonInterpreter_ReturnsOriginalAddress(
}

[Theory]
[MemberData(nameof(PrecodeTestDescriptorDataVersion3))]
public void GetInterpreterCode_Version3NullByteCodeAddress_ReturnsOriginalAddress(
[MemberData(nameof(PrecodeTestDescriptorDataVersion1))]
public void GetInterpreterCode_Version1NullByteCodeAddress_ReturnsOriginalAddress(
PrecodeTestDescriptor test,
string contractVersion)
{
Expand All @@ -524,8 +524,8 @@ public void GetInterpreterCode_Version3NullByteCodeAddress_ReturnsOriginalAddres
}

[Theory]
[MemberData(nameof(PrecodeTestDescriptorDataVersion3))]
public void GetInterpreterCode_Version3UnreadableAddress_ReturnsOriginalAddress(
[MemberData(nameof(PrecodeTestDescriptorDataVersion1))]
public void GetInterpreterCode_Version1UnreadableAddress_ReturnsOriginalAddress(
PrecodeTestDescriptor test,
string contractVersion)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public void ResolvesNativeTypesForFieldsReadThroughHelpers(
}

[Theory]
[InlineData("IExecutionManager", "c2", "Data.UnwindInfo", "FunctionLength")]
[InlineData("IPrecodeStubs", "c3", "Data.PrecodeMachineDescriptor", "StubCodePageSize")]
[InlineData("IExecutionManager", "c1", "Data.UnwindInfo", "FunctionLength")]
[InlineData("IPrecodeStubs", "c1", "Data.PrecodeMachineDescriptor", "StubCodePageSize")]
[InlineData("IStackWalk", "c1", "Data.ReadyToRunInfo", "ImportSections")]
[InlineData("IThread", "c1", "Data.Thread", "ThreadHandle")]
[InlineData("IThread", "c1", "Data.Thread", "DebuggerControlledThreadState")]
Expand Down Expand Up @@ -132,7 +132,7 @@ public void UsageWalkerTypeSizeEffectsAreIntegratedIntoUsageGraph()

Assert.True(DataType(
built.Value.Graph,
new ContractVersion(new ContractInterface("IExecutionManager"), "c2"),
new ContractVersion(new ContractInterface("IExecutionManager"), "c1"),
"Data.R2RExceptionClause").UsesTypeSize);
}

Expand Down Expand Up @@ -244,10 +244,10 @@ public void ResolvesGenericBaseAndStaticAbstractDispatch()
if (built is null) return; // cDAC source not found (running outside the repo)
UsageGraph graph = built!.Value.Graph;

// PrecodeStubs c3 reaches Data types only via a generic base + static-abstract dispatch.
// PrecodeStubs c1 reaches Data types only via a generic base + static-abstract dispatch.
HashSet<string> precodeTypes = DataTypesUsed(
graph,
new ContractVersion(new ContractInterface("IPrecodeStubs"), "c3"));
new ContractVersion(new ContractInterface("IPrecodeStubs"), "c1"));
Assert.Contains("Data.InterpMethod", precodeTypes);
}

Expand All @@ -259,7 +259,7 @@ public void ReportsInterpreterPrecodeUsage()

HashSet<string> dataTypes = DataTypesUsed(
built.Value.Graph,
new ContractVersion(new ContractInterface("IPrecodeStubs"), "c3"));
new ContractVersion(new ContractInterface("IPrecodeStubs"), "c1"));
Assert.Contains("Data.InterpreterPrecodeData", dataTypes);
}

Expand Down Expand Up @@ -297,15 +297,15 @@ public void ResolvesFieldReadsThroughSharedDataInterface()
// referenced by a concrete-typed read.
DataTypeUsage r2rUsage = DataType(
graph,
new ContractVersion(new ContractInterface("IExecutionManager"), "c2"),
new ContractVersion(new ContractInterface("IExecutionManager"), "c1"),
"Data.R2RExceptionClause");
string[] r2rFields = r2rUsage.Fields.Select(field => field.Name).ToArray();
Assert.Contains("Flags", r2rFields);
Assert.Contains("ClassToken", r2rFields); // a [Field] on R2R (computed on EE, so EE is not credited it)

string[] eeFields = DataType(
graph,
new ContractVersion(new ContractInterface("IExecutionManager"), "c2"),
new ContractVersion(new ContractInterface("IExecutionManager"), "c1"),
"Data.EEExceptionClause").Fields.Select(field => field.Name).ToArray();
Assert.Contains("Flags", eeFields);

Expand Down Expand Up @@ -355,7 +355,7 @@ public void ComputedConveniencePropertiesResolveToUnderlyingFields()
}

[Theory]
[InlineData("IExecutionManager", "c2")]
[InlineData("IExecutionManager", "c1")]
public void ExplicitDependenciesIncludeCompositeInfoWhereUsed(string contract, string version)
{
(UsageGraph Graph, string Root)? built = BuildRealGraph();
Expand Down
Loading