Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
33 changes: 33 additions & 0 deletions docs/design/datacontracts/ComWrappers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Contract ComWrappers

This contract is for getting information related to COM wrappers.

## APIs of contract

``` csharp
// Get the address of the external COM object
TargetPointer GetComWrappersIdentity(TargetPointer rcw);
```

## Version 1

Data descriptors used:
| Data Descriptor Name | Field | Meaning |
| --- | --- | --- |
| `NativeObjectWrapperObject` | `ExternalComObject` | Address of the external COM object |

Global variables used:
| Global Name | Type | Purpose |
| --- | --- | --- |

Contracts used:
| Contract Name |
| --- |


``` csharp
public TargetPointer GetComWrappersIdentity(TargetPointer address)
{
return _target.ReadPointer(address + /* NativeObjectWrapperObject::ExternalComObject offset */);
}
```
7 changes: 3 additions & 4 deletions src/coreclr/clrdatadescriptors.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function(generate_data_descriptors)
set(options EXPORT_VISIBLE)
set(oneValueArgs LIBRARY_NAME CONTRACT_FILE CONTRACT_NAME INTERFACE_TARGET)
set(oneValueArgs LIBRARY_NAME CONTRACT_NAME INTERFACE_TARGET)
set(multiValueArgs "")
cmake_parse_arguments(DATA_DESCRIPTORS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV})

Expand Down Expand Up @@ -53,15 +53,14 @@ function(generate_data_descriptors)
set(CONTRACT_BASELINE_DIR "${CLR_REPO_ROOT_DIR}/docs/design/datacontracts/data")
set(CONTRACT_DESCRIPTOR_INPUT "${DATA_DESCRIPTOR_SHARED_SOURCE_DIR}/contract-descriptor.c.in")
set(CONTRACT_DESCRIPTOR_OUTPUT "${GENERATED_CDAC_DESCRIPTOR_DIR}/contract-descriptor.c")
set(CONTRACT_FILE "${DATA_DESCRIPTORS_CONTRACT_FILE}")

# generate the contract descriptor by running cdac-build-tool
# n.b. this just uses `dotnet` from the PATH. InitializeDotNetCli adds the appropriate directory
add_custom_command(
OUTPUT "${CONTRACT_DESCRIPTOR_OUTPUT}"
VERBATIM
COMMAND ${CLR_DOTNET_HOST_PATH} ${CDAC_BUILD_TOOL_BINARY_PATH} compose -i "${CONTRACT_DESCRIPTOR_INPUT}" -o "${CONTRACT_DESCRIPTOR_OUTPUT}" -b "${CONTRACT_BASELINE_DIR}" -c "${CONTRACT_FILE}" $<TARGET_OBJECTS:${INTERMEDIARY_LIBRARY}>
DEPENDS ${INTERMEDIARY_LIBRARY} ${DATA_DESCRIPTORS_DEPENDENCIES} $<TARGET_OBJECTS:${INTERMEDIARY_LIBRARY}> "${CONTRACT_FILE}" "${CONTRACT_DESCRIPTOR_INPUT}"
COMMAND ${CLR_DOTNET_HOST_PATH} ${CDAC_BUILD_TOOL_BINARY_PATH} compose -i "${CONTRACT_DESCRIPTOR_INPUT}" -o "${CONTRACT_DESCRIPTOR_OUTPUT}" -b "${CONTRACT_BASELINE_DIR}" $<TARGET_OBJECTS:${INTERMEDIARY_LIBRARY}>
DEPENDS ${INTERMEDIARY_LIBRARY} ${DATA_DESCRIPTORS_DEPENDENCIES} $<TARGET_OBJECTS:${INTERMEDIARY_LIBRARY}> "${CONTRACT_DESCRIPTOR_INPUT}"
USES_TERMINAL
)

Expand Down
27 changes: 27 additions & 0 deletions src/coreclr/debug/datadescriptor-shared/datadescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ struct GlobalStringSpec
uint32_t StringValue;
};

struct GlobalContractSpec
{
uint32_t Name;
uint32_t Version;
};

#define CONCAT(token1,token2) token1 ## token2
#define CONCAT4(token1, token2, token3, token4) token1 ## token2 ## token3 ## token4

Expand Down Expand Up @@ -78,6 +84,7 @@ struct CDacStringPoolSizes
DECL_LEN(MAKE_GLOBALVALUELEN_NAME(name), sizeof(STRINGIFY(stringval)))
#define CDAC_GLOBAL_POINTER(name,value) DECL_LEN(MAKE_GLOBALLEN_NAME(name), sizeof(#name))
#define CDAC_GLOBAL_SUB_DESCRIPTOR(name,value) DECL_LEN(MAKE_GLOBALLEN_NAME(name), sizeof(#name))
#define CDAC_GLOBAL_CONTRACT(name,value) DECL_LEN(MAKE_GLOBALLEN_NAME(name), sizeof(#name))
#define CDAC_GLOBAL(name,tyname,value) DECL_LEN(MAKE_GLOBALLEN_NAME(name), sizeof(#name)) \
DECL_LEN(MAKE_GLOBALTYPELEN_NAME(name), sizeof(#tyname))
#include "wrappeddatadescriptor.inc"
Expand Down Expand Up @@ -148,6 +155,15 @@ enum
#include "wrappeddatadescriptor.inc"
};

// count the contracts
enum
{
CDacBlobGlobalContractsCount =
#define CDAC_GLOBALS_BEGIN() 0
#define CDAC_GLOBAL_CONTRACT(name,value) + 1
#include "wrappeddatadescriptor.inc"
};


#define MAKE_TYPEFIELDS_TYNAME(tyname) CONCAT(CDacFieldsPoolTypeStart__, tyname)

Expand Down Expand Up @@ -226,6 +242,7 @@ struct BinaryBlobDataDescriptor
uint32_t GlobalStringValuesStart;

uint32_t GlobalSubDescriptorsStart;
uint32_t ContractsStart;
uint32_t NamesPoolStart;

uint32_t TypeCount;
Expand All @@ -235,6 +252,7 @@ struct BinaryBlobDataDescriptor
uint32_t GlobalPointerValuesCount;
uint32_t GlobalStringValuesCount;
uint32_t GlobalSubDescriptorsCount;
uint32_t GlobalContractsCount;

uint32_t NamesPoolCount;

Expand All @@ -253,6 +271,7 @@ struct BinaryBlobDataDescriptor
struct GlobalPointerSpec GlobalPointerValues[CDacBlobGlobalPointersCount + 1];
struct GlobalStringSpec GlobalStringValues[CDacBlobGlobalStringsCount + 1];
struct GlobalPointerSpec GlobalSubDescriptorValues[CDacBlobGlobalSubDescriptorsCount + 1];
struct GlobalContractSpec GlobalContractValues[CDacBlobGlobalContractsCount + 1];
uint8_t NamesPool[sizeof(struct CDacStringPoolSizes)];
uint8_t EndMagic[4];
};
Expand All @@ -279,13 +298,15 @@ struct MagicAndBlob BlobDataDescriptor = {
/* .GlobalPointersStart = */ offsetof(struct BinaryBlobDataDescriptor, GlobalPointerValues),
/* .GlobalStringValuesStart = */ offsetof(struct BinaryBlobDataDescriptor, GlobalStringValues),
/* .GlobalSubDescriptorsStart = */ offsetof(struct BinaryBlobDataDescriptor, GlobalSubDescriptorValues),
/* .ContractsStart = */ offsetof(struct BinaryBlobDataDescriptor, GlobalContractValues),
/* .NamesPoolStart = */ offsetof(struct BinaryBlobDataDescriptor, NamesPool),
/* .TypeCount = */ CDacBlobTypesCount,
/* .FieldsPoolCount = */ CDacBlobFieldsPoolCount,
/* .GlobalLiteralValuesCount = */ CDacBlobGlobalLiteralsCount,
/* .GlobalPointerValuesCount = */ CDacBlobGlobalPointersCount,
/* .GlobalStringValuesCount = */ CDacBlobGlobalStringsCount,
/* .GlobalSubDescriptorsCount = */ CDacBlobGlobalSubDescriptorsCount,
/* .GlobalContractsCount = */ CDacBlobGlobalContractsCount,
/* .NamesPoolCount = */ sizeof(struct CDacStringPoolSizes),
/* .TypeSpecSize = */ sizeof(struct TypeSpec),
/* .FieldSpecSize = */ sizeof(struct FieldSpec),
Expand Down Expand Up @@ -337,13 +358,19 @@ struct MagicAndBlob BlobDataDescriptor = {
#include "wrappeddatadescriptor.inc"
},

/* .GlobalContractValues = */ {
#define CDAC_GLOBAL_CONTRACT(name,value) { /* .Name = */ GET_GLOBAL_NAME(name), /* .Version = */ value },
#include "wrappeddatadescriptor.inc"
},

/* .NamesPool = */ ("\0" // starts with a nul
#define CDAC_BASELINE(name) name "\0"
#define CDAC_TYPE_BEGIN(name) #name "\0"
#define CDAC_TYPE_FIELD(tyname,membertyname,membername,offset) #membername "\0" #membertyname "\0"
#define CDAC_GLOBAL_STRING(name,value) #name "\0" STRINGIFY(value) "\0"
#define CDAC_GLOBAL_POINTER(name,value) #name "\0"
#define CDAC_GLOBAL_SUB_DESCRIPTOR(name,value) #name "\0"
#define CDAC_GLOBAL_CONTRACT(name,value) #name "\0"
#define CDAC_GLOBAL(name,tyname,value) #name "\0" #tyname "\0"
#include "wrappeddatadescriptor.inc"
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
#ifndef CDAC_GLOBAL_SUB_DESCRIPTOR
#define CDAC_GLOBAL_SUB_DESCRIPTOR(globalname,addr)
#endif
#ifndef CDAC_GLOBAL_CONTRACT
#define CDAC_GLOBAL_CONTRACT(name,value)
#endif
#ifndef CDAC_GLOBALS_END
#define CDAC_GLOBALS_END()
#endif
Expand All @@ -62,4 +65,5 @@
#undef CDAC_GLOBAL_POINTER
#undef CDAC_GLOBAL_STRING
#undef CDAC_GLOBAL_SUB_DESCRIPTOR
#undef CDAC_GLOBAL_CONTRACT
#undef CDAC_GLOBALS_END
4 changes: 0 additions & 4 deletions src/coreclr/gc/datadescriptor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ add_dependencies(gc_dll_wks_descriptor_interface eventing_headers)
generate_data_descriptors(
LIBRARY_NAME gc_dll_wks_descriptor
CONTRACT_NAME "GCContractDescriptorWKS"
CONTRACT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/contracts.jsonc"
INTERFACE_TARGET gc_dll_wks_descriptor_interface)

if (FEATURE_SVR_GC)
Expand All @@ -25,7 +24,6 @@ if (FEATURE_SVR_GC)
generate_data_descriptors(
LIBRARY_NAME gc_dll_svr_descriptor
CONTRACT_NAME "GCContractDescriptorSVR"
CONTRACT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/contracts.jsonc"
INTERFACE_TARGET gc_dll_svr_descriptor_interface)
endif()

Expand All @@ -38,7 +36,6 @@ if(BUILD_EXP_GC)
generate_data_descriptors(
LIBRARY_NAME gcexp_dll_wks_descriptor
CONTRACT_NAME "GCContractDescriptorWKS"
CONTRACT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/contracts.jsonc"
INTERFACE_TARGET gcexp_dll_wks_descriptor_interface)

if (FEATURE_SVR_GC)
Expand All @@ -51,7 +48,6 @@ if(BUILD_EXP_GC)
generate_data_descriptors(
LIBRARY_NAME gcexp_dll_svr_descriptor
CONTRACT_NAME "GCContractDescriptorSVR"
CONTRACT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/contracts.jsonc"
INTERFACE_TARGET gcexp_dll_svr_descriptor_interface)
endif()
endif()
13 changes: 0 additions & 13 deletions src/coreclr/gc/datadescriptor/contracts.jsonc

This file was deleted.

2 changes: 2 additions & 0 deletions src/coreclr/gc/datadescriptor/datadescriptor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,6 @@ CDAC_GLOBAL_POINTER(Heaps, cdac_data<GC_NAMESPACE::gc_heap>::Heaps)
CDAC_GLOBAL_POINTER(CurrentGCState, cdac_data<GC_NAMESPACE::gc_heap>::CurrentGCState)
#endif // BACKGROUND_GC

CDAC_GLOBAL_CONTRACT(GC, 1)

CDAC_GLOBALS_END()
15 changes: 0 additions & 15 deletions src/coreclr/tools/cdac-build-tool/ComposeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ internal sealed class ComposeCommand : Command
{
private readonly Argument<string[]> inputFiles = new("INPUT [INPUTS...]") { Arity = ArgumentArity.OneOrMore, Description = "One or more input files" };
private readonly Option<string> outputFile = new("-o") { Arity = ArgumentArity.ExactlyOne, HelpName = "OUTPUT", Required = true, Description = "Output file" };
private readonly Option<string[]> contractFile = new("-c") { Arity = ArgumentArity.ZeroOrMore, HelpName = "CONTRACT", Description = "Contract file (may be specified multiple times)" };
private readonly Option<string> baselinePath = new("-b", "--baseline") { Arity = ArgumentArity.ExactlyOne, HelpName = "BASELINEPATH", Description = "Directory containing the baseline contracts"};
private readonly Option<string> templateFile = new("-i", "--input-template") { Arity = ArgumentArity.ExactlyOne, HelpName = "TEMPLATE", Description = "Contract descriptor template to be filled in" };
private readonly Option<bool> _verboseOption;
Expand All @@ -21,7 +20,6 @@ public ComposeCommand(Option<bool> verboseOption) : base("compose")
_verboseOption = verboseOption;
Add(inputFiles);
Add(outputFile);
Add(contractFile);
Add(baselinePath);
Add(templateFile);
SetAction(Run);
Expand Down Expand Up @@ -65,7 +63,6 @@ private async Task<int> Run(ParseResult parse, CancellationToken token = default
Console.Error.WriteLine($"Template file {templateFilePath} does not exist");
return 1;
}
var contracts = parse.GetValue(contractFile);
var verbose = parse.GetValue(_verboseOption);
var builder = new DataDescriptorModel.Builder(baselinesDir);
var scraper = new ObjectFileScraper(verbose, builder);
Expand All @@ -78,18 +75,6 @@ private async Task<int> Run(ParseResult parse, CancellationToken token = default
return 1;
}
}
if (contracts != null)
{
var contractReader = new ContractReader(builder);
foreach (var contract in contracts)
{
if (!await contractReader.ParseContracts(contract, token).ConfigureAwait(false))
{
Console.Error.WriteLine($"could not parse contracts in {contract}");
return 1;
}
}
}

var model = builder.Build();
if (verbose)
Expand Down
33 changes: 0 additions & 33 deletions src/coreclr/tools/cdac-build-tool/ContractReader.cs

This file was deleted.

8 changes: 0 additions & 8 deletions src/coreclr/tools/cdac-build-tool/DataDescriptorModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,6 @@ public void AddOrUpdateContract(string name, int version)
contract.Version = version;
}

public void AddOrupdateContracts(IEnumerable<KeyValuePair<string, int>> contracts)
{
foreach (var (name, version) in contracts)
{
AddOrUpdateContract(name, version);
}
}

public void SetBaseline(string baseline)
{
if (_baseline != string.Empty && _baseline != baseline)
Expand Down
Loading
Loading