-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[cDAC] Support passing global string values #114085
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for passing global string values to the data contract reader and descriptor model. Key changes include:
- Introducing new fields and APIs for global strings in targets and builders.
- Enhancing test coverage with new tests for reading global string values.
- Updating the build tool and parser to handle global string specifications in the data descriptor blob.
Reviewed Changes
Copilot reviewed 10 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/native/managed/cdacreader/tests/TestPlaceholderTarget.cs | Added global strings field and TryReadGlobalString method. |
src/native/managed/cdacreader/tests/ContractDescriptor/TargetTests.cs | Added tests to validate global string value reading. |
src/native/managed/cdacreader/tests/ContractDescriptor/ContractDescriptorHelpers.cs | Added helper for JSON serialization of global strings. |
src/native/managed/cdacreader/tests/ContractDescriptor/ContractDescriptorBuilder.cs | Extended builder API to include global strings. |
src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader/ContractDescriptorTarget.cs | Integrated global strings into target reading. |
src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader/ContractDescriptorParser.cs | Added global strings support in JSON serialization and diagnostics. |
src/native/managed/cdacreader/Microsoft.Diagnostics.DataContractReader.Abstractions/Target.cs | Defined abstract TryReadGlobalString method. |
src/coreclr/tools/cdac-build-tool/data-descriptor-blob.md | Updated blob specification to include GlobalStringSpec. |
src/coreclr/tools/cdac-build-tool/ObjectFileScraper.cs | Modified header reading and parsing logic to handle global string specs. |
src/coreclr/tools/cdac-build-tool/DataDescriptorModel.cs | Extended descriptor model to incorporate global strings. |
Files not reviewed (4)
- src/coreclr/debug/runtimeinfo/datadescriptor.cpp: Language not supported
- src/coreclr/debug/runtimeinfo/datadescriptor.h: Language not supported
- src/coreclr/tools/cdac-build-tool/sample/sample.blob.c: Language not supported
- src/coreclr/tools/cdac-build-tool/sample/sample.data.h: Language not supported
Tagging subscribers to this area: @tommcdon |
7eef3b3
to
c25c6b1
Compare
return new GlobalDescriptor { NumericValue = valueCase1, Kind = GlobalDescriptor.KindEnum.Direct }; | ||
// Case 2: string | ||
if (TryGetStringFromToken(ref reader, out string valueCase2)) | ||
return new GlobalDescriptor { StringValue = valueCase2, Kind = GlobalDescriptor.KindEnum.String }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the algorithm of "try a number, if it fails it is a string." Since we own the spec we should be able to do better. Is there a reason we have to have the implicit string type and can't just use the explicit one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the type of the json node or the optional string representing the type of the value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant the optional string, could we have a string by itself be a number and only treat it as a string if we add the optional type
c25c6b1
to
799e5d4
Compare
Closing as this content was combined in #113899 |
Will be used in #113899 to pass target runtime identifier.
To support passing global strings, I have modified the data descriptor spec. Previously globals were of the form
Where the
VALUE
may be a JSON numeric constant integer or a string containing a signed or unsigned decimal or hex (with prefix 0x or 0X) integer constant.I have modified
VALUE
to be less constrained:VALUE
may be either a number or a string. JSON numeric constants are always parsed as numbers. JSON strings are always parsed as strings and may additionally parse as a hex (with prefix0x
or0X
) or decimal number.To fit the new spec, the cDAC data contract implementation was modified in three main:
datadescriptor.h
anddatadescriptor.cpp
in the runtime.CDAC_GLOBAL_STRING(name, value)
to pass global strings which are a mapping of a string (name) to string (value). Both strings exist in the existing string pool.cdac-build-tool
which takes the obj file and converts it to a JSON human readable contract.cdacreader
which reads the JSON into aTarget
.With this change existing stringy numbers can be parsed as either a number or a string.
Example: