Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Include/cpython/pyframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,26 @@ PyAPI_FUNC(PyObject*) PyFrame_GetVarString(PyFrameObject *frame, const char *nam
/* The following functions are for use by debuggers and other tools
* implementing custom frame evaluators with PEP 523. */

struct _PyInterpreterFrameCore;
struct _PyInterpreterFrame;

/* Returns the code object of the frame (strong reference).
* Does not raise an exception. */
PyAPI_FUNC(PyObject *) PyUnstable_InterpreterFrame_GetCode(struct _PyInterpreterFrame *frame);
PyAPI_FUNC(PyObject *) PyUnstable_InterpreterFrame_GetCode(struct _PyInterpreterFrameCore *frame);

/* Returns a byte offset into the last executed instruction.
* Does not raise an exception. */
PyAPI_FUNC(int) PyUnstable_InterpreterFrame_GetLasti(struct _PyInterpreterFrame *frame);
PyAPI_FUNC(int) PyUnstable_InterpreterFrame_GetLasti(struct _PyInterpreterFrameCore *frame);

/* Returns the currently executing line number, or -1 if there is no line number.
* Does not raise an exception. */
PyAPI_FUNC(int) PyUnstable_InterpreterFrame_GetLine(struct _PyInterpreterFrame *frame);
PyAPI_FUNC(int) PyUnstable_InterpreterFrame_GetLine(struct _PyInterpreterFrameCore *frame);

#define PyUnstable_EXECUTABLE_KIND_SKIP 0
#define PyUnstable_EXECUTABLE_KIND_PY_FUNCTION 1
#define PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION 3
#define PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR 4
#define PyUnstable_EXECUTABLE_KINDS 5
#define PyUnstable_EXECUTABLE_KIND_JIT 5
#define PyUnstable_EXECUTABLE_KINDS 6

PyAPI_DATA(const PyTypeObject *) const PyUnstable_ExecutableKinds[PyUnstable_EXECUTABLE_KINDS+1];
8 changes: 4 additions & 4 deletions Include/cpython/pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@ struct _ts {
int what_event; /* The event currently being monitored, if any. */

/* Pointer to currently executing frame. */
struct _PyInterpreterFrame *current_frame;
struct _PyInterpreterFrameCore *current_frame;

/* Pointer to the base frame (bottommost sentinel frame).
Used by profilers to validate complete stack unwinding.
Points to the embedded base_frame in _PyThreadStateImpl.
The frame is embedded there rather than here because _PyInterpreterFrame
The frame is embedded there rather than here because _PyInterpreterFrameCore
is defined in internal headers that cannot be exposed in the public API. */
struct _PyInterpreterFrame *base_frame;
struct _PyInterpreterFrameCore *base_frame;

struct _PyInterpreterFrame *last_profiled_frame;
struct _PyInterpreterFrameCore *last_profiled_frame;

Py_tracefunc c_profilefunc;
Py_tracefunc c_tracefunc;
Expand Down
6 changes: 3 additions & 3 deletions Include/internal/pycore_ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extern "C" {
#include "pycore_interp.h" // PyInterpreterState.eval_frame
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_stats.h" // EVAL_CALL_STAT_INC()
#include "pycore_typedefs.h" // _PyInterpreterFrame
#include "pycore_typedefs.h" // _PyInterpreterFrameCore


/* Forward declarations */
Expand Down Expand Up @@ -268,7 +268,7 @@ PyAPI_FUNC(int) _Py_ReachedRecursionLimitWithMargin(
static inline void _Py_LeaveRecursiveCall(void) {
}

extern _PyInterpreterFrame* _PyEval_GetFrame(void);
extern _PyInterpreterFrameCore* _PyEval_GetFrame(void);

extern PyObject * _PyEval_GetGlobalsFromRunningMain(PyThreadState *);
extern int _PyEval_EnsureBuiltins(
Expand Down Expand Up @@ -310,7 +310,7 @@ PyAPI_FUNC(void) _PyEval_FormatExcCheckArg(PyThreadState *tstate, PyObject *exc,
PyAPI_FUNC(void) _PyEval_FormatExcUnbound(PyThreadState *tstate, PyCodeObject *co, int oparg);
PyAPI_FUNC(void) _PyEval_FormatKwargsError(PyThreadState *tstate, PyObject *func, PyObject *kwargs);
PyAPI_FUNC(PyObject *) _PyEval_ImportFrom(PyThreadState *, PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) _PyEval_ImportName(PyThreadState *, _PyInterpreterFrame *, PyObject *, PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) _PyEval_ImportName(PyThreadState *, _PyInterpreterFrameCore *, PyObject *, PyObject *, PyObject *);
PyAPI_FUNC(PyObject *)_PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type, Py_ssize_t nargs, PyObject *kwargs);
PyAPI_FUNC(PyObject *)_PyEval_MatchKeys(PyThreadState *tstate, PyObject *map, PyObject *keys);
PyAPI_FUNC(void) _PyEval_MonitorRaise(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr);
Expand Down
6 changes: 3 additions & 3 deletions Include/internal/pycore_debug_offsets.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,11 @@ typedef struct _Py_DebugOffsets {
}, \
.interpreter_frame = { \
.size = sizeof(_PyInterpreterFrame), \
.previous = offsetof(_PyInterpreterFrame, previous), \
.executable = offsetof(_PyInterpreterFrame, f_executable), \
.previous = offsetof(_PyInterpreterFrameCore, previous), \
.executable = offsetof(_PyInterpreterFrameCore, f_executable), \
.instr_ptr = offsetof(_PyInterpreterFrame, instr_ptr), \
.localsplus = offsetof(_PyInterpreterFrame, localsplus), \
.owner = offsetof(_PyInterpreterFrame, owner), \
.owner = offsetof(_PyInterpreterFrameCore, owner), \
.stackpointer = offsetof(_PyInterpreterFrame, stackpointer), \
.tlbc_index = _Py_Debug_interpreter_frame_tlbc_index, \
}, \
Expand Down
5 changes: 3 additions & 2 deletions Include/internal/pycore_genobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ extern "C" {
# error "this header requires Py_BUILD_CORE define"
#endif

#include "pycore_interpframe_structs.h" // _PyGenObject
#include "pycore_interpframe.h" // _PyFrame_Core
#include "pycore_interpframe_structs.h" // _PyInterpreterFrame

#include <stddef.h> // offsetof()


static inline
PyGenObject *_PyGen_GetGeneratorFromFrame(_PyInterpreterFrame *frame)
{
assert(frame->owner == FRAME_OWNED_BY_GENERATOR);
assert(_PyFrame_Core(frame)->owner & FRAME_OWNED_BY_GENERATOR);
size_t offset_in_gen = offsetof(PyGenObject, gi_iframe);
return (PyGenObject *)(((char *)frame) - offset_in_gen);
}
Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_interp_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ struct _gc_runtime_state {
int collecting;
// The frame that started the current collection. It might be NULL even when
// collecting (if no Python frame is running):
_PyInterpreterFrame *frame;
_PyInterpreterFrameCore *frame;
/* list of uncollectable objects */
PyObject *garbage;
/* a list of callbacks to be invoked when collection is performed */
Expand Down
Loading
Loading