mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
GH-100987: Allow objects other than code objects as the "executable" of an internal frame. (GH-105727)
* Add table describing possible executable classes for out-of-process debuggers. * Remove shim code object creation code as it is no longer needed. * Make lltrace a bit more robust w.r.t. non-standard frames.
This commit is contained in:
parent
ad56340b66
commit
7199584ac8
28 changed files with 541 additions and 606 deletions
|
|
@ -47,7 +47,7 @@ enum _frameowner {
|
|||
};
|
||||
|
||||
typedef struct _PyInterpreterFrame {
|
||||
PyCodeObject *f_code; /* Strong reference */
|
||||
PyObject *f_executable; /* Strong reference */
|
||||
struct _PyInterpreterFrame *previous;
|
||||
PyObject *f_funcobj; /* Strong reference. Only valid if not on C stack */
|
||||
PyObject *f_globals; /* Borrowed reference. Only valid if not on C stack */
|
||||
|
|
@ -73,20 +73,25 @@ typedef struct _PyInterpreterFrame {
|
|||
} _PyInterpreterFrame;
|
||||
|
||||
#define _PyInterpreterFrame_LASTI(IF) \
|
||||
((int)((IF)->prev_instr - _PyCode_CODE((IF)->f_code)))
|
||||
((int)((IF)->prev_instr - _PyCode_CODE(_PyFrame_GetCode(IF))))
|
||||
|
||||
static inline PyCodeObject *_PyFrame_GetCode(_PyInterpreterFrame *f) {
|
||||
assert(PyCode_Check(f->f_executable));
|
||||
return (PyCodeObject *)f->f_executable;
|
||||
}
|
||||
|
||||
static inline PyObject **_PyFrame_Stackbase(_PyInterpreterFrame *f) {
|
||||
return f->localsplus + f->f_code->co_nlocalsplus;
|
||||
return f->localsplus + _PyFrame_GetCode(f)->co_nlocalsplus;
|
||||
}
|
||||
|
||||
static inline PyObject *_PyFrame_StackPeek(_PyInterpreterFrame *f) {
|
||||
assert(f->stacktop > f->f_code->co_nlocalsplus);
|
||||
assert(f->stacktop > _PyFrame_GetCode(f)->co_nlocalsplus);
|
||||
assert(f->localsplus[f->stacktop-1] != NULL);
|
||||
return f->localsplus[f->stacktop-1];
|
||||
}
|
||||
|
||||
static inline PyObject *_PyFrame_StackPop(_PyInterpreterFrame *f) {
|
||||
assert(f->stacktop > f->f_code->co_nlocalsplus);
|
||||
assert(f->stacktop > _PyFrame_GetCode(f)->co_nlocalsplus);
|
||||
f->stacktop--;
|
||||
return f->localsplus[f->stacktop];
|
||||
}
|
||||
|
|
@ -119,7 +124,7 @@ _PyFrame_Initialize(
|
|||
PyObject *locals, PyCodeObject *code, int null_locals_from)
|
||||
{
|
||||
frame->f_funcobj = (PyObject *)func;
|
||||
frame->f_code = (PyCodeObject *)Py_NewRef(code);
|
||||
frame->f_executable = Py_NewRef(code);
|
||||
frame->f_builtins = func->func_builtins;
|
||||
frame->f_globals = func->func_globals;
|
||||
frame->f_locals = locals;
|
||||
|
|
@ -172,8 +177,11 @@ _PyFrame_SetStackPointer(_PyInterpreterFrame *frame, PyObject **stack_pointer)
|
|||
static inline bool
|
||||
_PyFrame_IsIncomplete(_PyInterpreterFrame *frame)
|
||||
{
|
||||
if (frame->owner == FRAME_OWNED_BY_CSTACK) {
|
||||
return true;
|
||||
}
|
||||
return frame->owner != FRAME_OWNED_BY_GENERATOR &&
|
||||
frame->prev_instr < _PyCode_CODE(frame->f_code) + frame->f_code->_co_firsttraceable;
|
||||
frame->prev_instr < _PyCode_CODE(_PyFrame_GetCode(frame)) + _PyFrame_GetCode(frame)->_co_firsttraceable;
|
||||
}
|
||||
|
||||
static inline _PyInterpreterFrame *
|
||||
|
|
@ -272,6 +280,14 @@ PyGenObject *_PyFrame_GetGenerator(_PyInterpreterFrame *frame)
|
|||
return (PyGenObject *)(((char *)frame) - offset_in_gen);
|
||||
}
|
||||
|
||||
#define PY_EXECUTABLE_KIND_SKIP 0
|
||||
#define PY_EXECUTABLE_KIND_PY_FUNCTION 1
|
||||
#define PY_EXECUTABLE_KIND_BUILTIN_FUNCTION 3
|
||||
#define PY_EXECUTABLE_KIND_METHOD_DESCRIPTOR 4
|
||||
#define PY_EXECUTABLE_KINDS 5
|
||||
|
||||
PyAPI_DATA(const PyTypeObject *) const PyUnstable_ExecutableKinds[PY_EXECUTABLE_KINDS+1];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue