Skip to content
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

Design cDAC level API to expose stack walking #111734

Open
Tracked by #110758
max-charlamb opened this issue Jan 23, 2025 · 1 comment
Open
Tracked by #110758

Design cDAC level API to expose stack walking #111734

max-charlamb opened this issue Jan 23, 2025 · 1 comment
Labels
area-Diagnostics-coreclr untriaged New issue has not been triaged by the area owner

Comments

@max-charlamb
Copy link
Contributor

max-charlamb commented Jan 23, 2025

Proposal 1

Using opaque IStackWalkHandle and IStackFrameHandle to hold state about the stack walk. These are passed back to the contract to be operated on.

// Each Contract version implements its own opaque handle StackWalkFrameHandle_1 for IStackFrameHandle and IStackWalkHandle etc..
// These are checked when passed in to verify that it is from the write contract version, otherwise an invalid argument exception is thrown
// This allows for flexibility in the handle implementation
//  
// if (uncheckedHandle is not StackWalkHandle_1 stackWalkHandle)
// {
//     throw new InvalidArgumentException();
// }

internal interface IStackFrameHandle { }

internal interface IStackWalkHandle { }

// IStackContext is implemented by each architectures thread context object. 

internal interface IStackContext 
{
    int GetContextSize();
    int GetContextFlags();
    TargetPointer GetIP();
    TargetPointer GetSP();
    bool WriteToBuffer(Span<byte> buffer);
}

internal interface IStackWalk : IContract
{
    // Creates a StackWalk 
    public IStackWalkHandle CreateStackWalk(ThreadData threadData);

    // Moves stackWalkHandle to the next managed frame
    // returns true if successful, false otherwise
    public bool Next(IStackWalkHandle stackWalkHandle);
    public IStackFrameHandle GetFrame(IStackWalkHandle stackWalkHandle);
    public IStackFrameContext GetContext(IStackWalkHandle stackWalkHandle);
    public int GetNumArgs(IStackFrameHandle stackFrameHandle);
    // ... other functions implemented on IXCLRDataFrame
}

Proposal 2

Same as proposal 1, except that instead of passing the opaque handles back to the contract, these can be operated on themselves.

internal interface IStackFrameHandle 
{
    // frame specific methods currently implemented on IXCLRDataFrame
    public int GetNumArgs();
    //...
}

internal interface IStackWalkHandle 
{
    // Moves stackWalkHandle to the next managed frame
    // returns true if successful, false otherwise
    public bool Next(IStackWalkHandle stackWalkHandle);
    public IStackFrameContext GetContext(IStackFrameHandle stackFrameHandle);
    public IStackFrameHandle GetFrame(IStackWalkHandle stackWalkHandle);
}

internal interface IStackWalk : IContract
{
    // Creates a StackWalk 
    public IStackWalkHandle CreateStackWalk(ThreadData threadData);
}
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 23, 2025
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jan 23, 2025
@max-charlamb max-charlamb changed the title Decide on a cDAC level API to expose stack walking. Design cDAC level API to expose stack walking Jan 23, 2025
@teo-tsirpanis teo-tsirpanis added area-Diagnostics-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jan 23, 2025
Copy link
Contributor

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Diagnostics-coreclr untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

2 participants