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

Make it easier to traverse the frame stack for third party tools. #100987

Open
markshannon opened this issue Jan 12, 2023 · 2 comments
Open

Make it easier to traverse the frame stack for third party tools. #100987

markshannon opened this issue Jan 12, 2023 · 2 comments
Assignees
Labels
type-feature A feature request or enhancement

Comments

@markshannon
Copy link
Member

markshannon commented Jan 12, 2023

Profilers and debuggers need to traverse the frame stack, but the layout of the stack is an internal implementation detail.
However can make some limited promises to make porting tools between Python versions a bit easier.

In order to traverse the stack, the offset of the previous pointer needs to be known. To understand the frame, more information is needed.

@pablogsal
@Yhg1s
expressed interest in this.

Linked PRs

@markshannon markshannon added the type-feature A feature request or enhancement label Jan 12, 2023
@markshannon
Copy link
Member Author

Initially, I propose to refactor the PyInterpreterFrame struct such that it starts:

typedef struct _PyInterpreterFrame {
    PyCodeObject *f_code;
    struct _PyInterpreterFrame *previous;
    ...

Currently f_code must be a code object, but we could generalize it to allow other objects.
For example, the shim frame inserted on entry to _PyEval_EvalFrameDefault could have that field set to None indicating it should be skipped in tracebacks, etc.

The order of f_code and previous doesn't really matter, but have f_code first makes #100719 a bit simpler

@pablogsal pablogsal self-assigned this Jan 12, 2023
@pablogsal
Copy link
Member

Let me collect some feedback from maintainers of debuggers and profilers and will comment here the requirements so we can think of solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants