-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[cDAC] implement IXCLRDataMethodInstance::GetName and associated APIs #118966
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
max-charlamb
merged 14 commits into
dotnet:main
from
max-charlamb:cdac-methodinstance-getname
Sep 15, 2025
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cb40b94
implement IXCLRDataMethodInstance::GetName
max-charlamb 84bc116
wip
max-charlamb c8c3325
Merge remote-tracking branch 'origin/main' into cdac-methodinstance-g…
max-charlamb eea0eac
Merge branch 'main' into cdac-methodinstance-getname
max-charlamb 80cf184
implement IXCLRStackWalk::GetFrame
max-charlamb 31d5947
clean up
max-charlamb cf961d3
add docs
max-charlamb c8c2803
cleanup
max-charlamb e753559
Update docs/design/datacontracts/StackWalk.md
max-charlamb 470eceb
clean up
max-charlamb b809437
Merge branch 'main' into cdac-methodinstance-getname
max-charlamb 66f9370
apply changes over merge
max-charlamb 58aea64
Merge branch 'main' into cdac-methodinstance-getname
max-charlamb f209850
add todo
max-charlamb 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
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
127 changes: 127 additions & 0 deletions
127
src/native/managed/cdac/mscordaccore_universal/Legacy/ClrDataFrame.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,127 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.InteropServices.Marshalling; | ||
using Microsoft.Diagnostics.DataContractReader.Contracts; | ||
|
||
namespace Microsoft.Diagnostics.DataContractReader.Legacy; | ||
|
||
[GeneratedComClass] | ||
internal sealed unsafe partial class ClrDataFrame : IXCLRDataFrame, IXCLRDataFrame2 | ||
{ | ||
private readonly Target _target; | ||
private readonly IXCLRDataFrame? _legacyImpl; | ||
private readonly IXCLRDataFrame2? _legacyImpl2; | ||
|
||
private readonly IStackDataFrameHandle _dataFrame; | ||
|
||
public ClrDataFrame(Target target, IStackDataFrameHandle dataFrame, IXCLRDataFrame? legacyImpl) | ||
{ | ||
_target = target; | ||
_legacyImpl = legacyImpl; | ||
_legacyImpl2 = legacyImpl as IXCLRDataFrame2; | ||
|
||
_dataFrame = dataFrame; | ||
} | ||
|
||
// IXCLRDataFrame implementation | ||
int IXCLRDataFrame.GetFrameType(uint* simpleType, uint* detailedType) | ||
=> _legacyImpl is not null ? _legacyImpl.GetFrameType(simpleType, detailedType) : HResults.E_NOTIMPL; | ||
|
||
int IXCLRDataFrame.GetContext( | ||
uint contextFlags, | ||
uint contextBufSize, | ||
uint* contextSize, | ||
[Out, MarshalUsing(CountElementName = nameof(contextBufSize))] byte[] contextBuf) | ||
=> _legacyImpl is not null ? _legacyImpl.GetContext(contextFlags, contextBufSize, contextSize, contextBuf) : HResults.E_NOTIMPL; | ||
|
||
int IXCLRDataFrame.GetAppDomain(void** appDomain) | ||
=> _legacyImpl is not null ? _legacyImpl.GetAppDomain(appDomain) : HResults.E_NOTIMPL; | ||
|
||
int IXCLRDataFrame.GetNumArguments(uint* numArgs) | ||
=> _legacyImpl is not null ? _legacyImpl.GetNumArguments(numArgs) : HResults.E_NOTIMPL; | ||
|
||
int IXCLRDataFrame.GetArgumentByIndex( | ||
uint index, | ||
void** arg, | ||
uint bufLen, | ||
uint* nameLen, | ||
char* name) | ||
=> _legacyImpl is not null ? _legacyImpl.GetArgumentByIndex(index, arg, bufLen, nameLen, name) : HResults.E_NOTIMPL; | ||
|
||
int IXCLRDataFrame.GetNumLocalVariables(uint* numLocals) | ||
=> _legacyImpl is not null ? _legacyImpl.GetNumLocalVariables(numLocals) : HResults.E_NOTIMPL; | ||
|
||
int IXCLRDataFrame.GetLocalVariableByIndex( | ||
uint index, | ||
void** localVariable, | ||
uint bufLen, | ||
uint* nameLen, | ||
char* name) | ||
=> _legacyImpl is not null ? _legacyImpl.GetLocalVariableByIndex(index, localVariable, bufLen, nameLen, name) : HResults.E_NOTIMPL; | ||
|
||
int IXCLRDataFrame.GetCodeName( | ||
uint flags, | ||
uint bufLen, | ||
uint* nameLen, | ||
char* nameBuf) | ||
=> _legacyImpl is not null ? _legacyImpl.GetCodeName(flags, bufLen, nameLen, nameBuf) : HResults.E_NOTIMPL; | ||
|
||
int IXCLRDataFrame.GetMethodInstance(out IXCLRDataMethodInstance? method) | ||
{ | ||
int hr = HResults.S_OK; | ||
method = null; | ||
|
||
IXCLRDataMethodInstance? legacyMethod = null; | ||
if (_legacyImpl is not null) | ||
{ | ||
int hrLocal = _legacyImpl.GetMethodInstance(out legacyMethod); | ||
if (hrLocal < 0) | ||
return hrLocal; | ||
} | ||
|
||
try | ||
{ | ||
IStackWalk stackWalk = _target.Contracts.StackWalk; | ||
IRuntimeTypeSystem rts = _target.Contracts.RuntimeTypeSystem; | ||
|
||
TargetPointer methodDesc = stackWalk.GetMethodDescPtr(_dataFrame); | ||
|
||
if (methodDesc == TargetPointer.Null) | ||
throw Marshal.GetExceptionForHR(/*E_NOINTERFACE*/ HResults.COR_E_INVALIDCAST)!; | ||
|
||
MethodDescHandle mdh = rts.GetMethodDescHandle(methodDesc); | ||
TargetPointer appDomain = _target.ReadPointer( | ||
_target.ReadGlobalPointer(Constants.Globals.AppDomain)); | ||
|
||
method = new ClrDataMethodInstance(_target, mdh, appDomain, legacyMethod); | ||
} | ||
catch (System.Exception ex) | ||
{ | ||
hr = ex.HResult; | ||
} | ||
|
||
return hr; | ||
} | ||
|
||
int IXCLRDataFrame.Request( | ||
uint reqCode, | ||
uint inBufferSize, | ||
byte* inBuffer, | ||
uint outBufferSize, | ||
byte* outBuffer) | ||
=> _legacyImpl is not null ? _legacyImpl.Request(reqCode, inBufferSize, inBuffer, outBufferSize, outBuffer) : HResults.E_NOTIMPL; | ||
|
||
int IXCLRDataFrame.GetNumTypeArguments(uint* numTypeArgs) | ||
=> _legacyImpl is not null ? _legacyImpl.GetNumTypeArguments(numTypeArgs) : HResults.E_NOTIMPL; | ||
|
||
int IXCLRDataFrame.GetTypeArgumentByIndex(uint index, void** typeArg) | ||
=> _legacyImpl is not null ? _legacyImpl.GetTypeArgumentByIndex(index, typeArg) : HResults.E_NOTIMPL; | ||
|
||
// IXCLRDataFrame2 implementation | ||
int IXCLRDataFrame2.GetExactGenericArgsToken(void** genericToken) | ||
=> _legacyImpl2 is not null ? _legacyImpl2.GetExactGenericArgsToken(genericToken) : HResults.E_NOTIMPL; | ||
} |
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.
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.