Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Limited Support for PEP-523 eval_frame hook #275

Closed

Description

@akruis

The Pydev debugger (https://github.com/fabioz/PyDev.Debugger) started using the eval_frame hook and this caused crashes with Stackless (see #240). The first and obvious mitigation was to teach pydevd not to use this hook, if it detects Stackless (done, see fabioz/PyDev.Debugger#198).

Now, that #270 made significant progress, I think it is possible to support the evel_frame hook well enough to enable its usage with pydevd. The principal problem with this hook is, that the Stackless frame evaluation function PyEval_EvalFrameEx_slp:

  • has an additional third argument "retval"
  • can be entered multiple times for the same frame
  • observes the frame transfer protocol as described in pycore_stackless.h

But for each frame f the first invocation of PyEval_EvalFrameEx_slp has always the form PyEval_EvalFrameEx_slp(f, 0, Py_None) with f->f_executing == 0. And therefore we can map this first call to the signature of the C-Python frame evaluation function _PyFrameEvalFunction.

I'll try to create a pull request, do some testing with pydevd and see if this works out in practice.

Activity

  1. self-assigned this
    on Jun 22, 2021
  2. akruis commented on Jun 22, 2021

    @akruis
    Author

    For a real test with pydevd we need PEP 570 (commit 8c77b8c) first. I added merging pull request #276 to the plan in #254.

  3. akruis commented on Jul 16, 2021

    @akruis
    Author

    Well, 8c77b8c is merged, but testing with a real Pydevd is still not possible. Experiments with C-Python reveal, that we need to merge commit bdace21 first. That's somewhere between v3.8.0b4 and v3.8.0rc1. This commit modifies a structure and Cython probably depends on the layout of this structure.

    Command line for testing:

    PYDEVD_USE_FRAME_EVAL=yes PYDEVD_USE_CYTHON=yes python3.8  pydevd.py --port 5678 --client 127.0.0.1 --file /path/to/a/python_script.py
    
  4. added 2 commits that reference this issue on Aug 8, 2021
  5. akruis commented on Aug 8, 2021

    @akruis
    Author

    Successfully tested and merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions