-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[cDAC] Add GetApproxTypeHandle DacDbi API #128921
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
Draft
Copilot
wants to merge
11
commits into
main
Choose a base branch
from
copilot/implement-getapproxtypehandle
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9e0b5cd
Implement DacDbiImpl.GetApproxTypeHandle in cDAC
Copilot 2b5aa4f
Add DacDbiApproxTypeHandle dump tests
Copilot b86eea6
Fix InstantiationApprox to look up open generic typeDef via vmAssembl…
Copilot bd99ceb
Update DacDbiApproxTypeHandleDumpTests.cs
rcj1 2fc978b
Apply suggestions from code review
rcj1 28923d0
Apply suggestions from code review
rcj1 9c85a41
Update RuntimeTypeSystem_1.cs
rcj1 d1fb150
Potential fix for pull request finding
rcj1 f948bfc
Apply UpCastTypeIfNeeded equivalent in InstantiationApprox
ba257a7
Merge remote-tracking branch 'rachel' into copilot/implement-getappro…
rcj1 d4edfae
Fix cDAC dump test build: add TestInfrastructure using directive
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
39 changes: 39 additions & 0 deletions
39
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DbiHelpers.cs
This file contains hidden or 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,39 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Runtime.InteropServices; | ||
| using Microsoft.Diagnostics.DataContractReader.Contracts; | ||
|
|
||
| namespace Microsoft.Diagnostics.DataContractReader.Legacy; | ||
| internal static class DbiHelpers | ||
| { | ||
| public static TypeHandle LookupTypeDefOrRefInAssembly(Target target, IRuntimeTypeSystem rts, ulong vmAssembly, uint metadataToken) | ||
| { | ||
| TypeHandle th = TryLookupTypeDefOrRefInAssembly(target, rts, vmAssembly, metadataToken); | ||
| if (th.IsNull) | ||
| throw Marshal.GetExceptionForHR(CorDbgHResults.CORDBG_E_CLASS_NOT_LOADED)!; | ||
| return th; | ||
| } | ||
|
|
||
| public static TypeHandle TryLookupTypeDefOrRefInAssembly(Target target, IRuntimeTypeSystem rts, ulong vmAssembly, uint metadataToken) | ||
| { | ||
| ILoader loader = target.Contracts.Loader; | ||
| ModuleHandle moduleHandle = loader.GetModuleHandleFromAssemblyPtr(new TargetPointer(vmAssembly)); | ||
| ModuleLookupTables lookupTables = loader.GetLookupTables(moduleHandle); | ||
| TargetPointer mt; | ||
| switch ((EcmaMetadataUtils.TokenType)(metadataToken & EcmaMetadataUtils.TokenTypeMask)) | ||
| { | ||
| case EcmaMetadataUtils.TokenType.mdtTypeDef: | ||
| mt = loader.GetModuleLookupMapElement(lookupTables.TypeDefToMethodTable, metadataToken, out _); | ||
| break; | ||
| case EcmaMetadataUtils.TokenType.mdtTypeRef: | ||
| mt = loader.GetModuleLookupMapElement(lookupTables.TypeRefToMethodTable, metadataToken, out _); | ||
| break; | ||
| default: | ||
| return default; | ||
| } | ||
| if (mt == TargetPointer.Null) | ||
| return default; | ||
| return rts.GetTypeHandle(mt); | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.