Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fixup
  • Loading branch information
picnixz committed Mar 20, 2025
commit af9703ad34693e94f665811f3a0e64801776c57e
67 changes: 37 additions & 30 deletions Python/legacy_tracing.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ sys_profile_start(
PyObject *op, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
assert(kwnames == NULL);
assert(PyVectorcall_NARGS(nargsf) == 2);
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
return call_profile_func(self, Py_None);
}

Expand All @@ -70,9 +70,9 @@ sys_profile_throw(
PyObject *op, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
assert(kwnames == NULL);
assert(PyVectorcall_NARGS(nargsf) == 3);
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
return call_profile_func(self, Py_None);
}

Expand All @@ -81,9 +81,9 @@ sys_profile_return(
PyObject *op, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
assert(kwnames == NULL);
assert(PyVectorcall_NARGS(nargsf) == 3);
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
return call_profile_func(self, args[2]);
}

Expand All @@ -92,9 +92,9 @@ sys_profile_unwind(
PyObject *op, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
assert(kwnames == NULL);
assert(PyVectorcall_NARGS(nargsf) == 3);
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
return call_profile_func(self, NULL);
}

Expand All @@ -103,9 +103,9 @@ sys_profile_call_or_return(
PyObject *op, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
assert(kwnames == NULL);
assert(PyVectorcall_NARGS(nargsf) == 4);
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
PyObject *callable = args[2];
if (PyCFunction_Check(callable)) {
return call_profile_func(self, callable);
Expand Down Expand Up @@ -190,9 +190,10 @@ call_trace_func(_PyLegacyEventHandler *self, PyObject *arg)

static PyObject *
sys_trace_exception_func(
_PyLegacyEventHandler *self, PyObject *const *args,
PyObject *op, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
assert(kwnames == NULL);
assert(PyVectorcall_NARGS(nargsf) == 3);
PyObject *exc = args[2];
Expand All @@ -214,39 +215,43 @@ sys_trace_exception_func(

static PyObject *
sys_trace_start(
_PyLegacyEventHandler *self, PyObject *const *args,
PyObject *op, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
assert(kwnames == NULL);
assert(PyVectorcall_NARGS(nargsf) == 2);
return call_trace_func(self, Py_None);
}

static PyObject *
sys_trace_throw(
_PyLegacyEventHandler *self, PyObject *const *args,
PyObject *op, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
assert(kwnames == NULL);
assert(PyVectorcall_NARGS(nargsf) == 3);
return call_trace_func(self, Py_None);
}

static PyObject *
sys_trace_unwind(
_PyLegacyEventHandler *self, PyObject *const *args,
PyObject *op, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
assert(kwnames == NULL);
assert(PyVectorcall_NARGS(nargsf) == 3);
return call_trace_func(self, NULL);
}

static PyObject *
sys_trace_return(
_PyLegacyEventHandler *self, PyObject *const *args,
PyObject *op, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
assert(!PyErr_Occurred());
assert(kwnames == NULL);
assert(PyVectorcall_NARGS(nargsf) == 3);
Expand All @@ -258,19 +263,21 @@ sys_trace_return(

static PyObject *
sys_trace_yield(
_PyLegacyEventHandler *self, PyObject *const *args,
PyObject *op, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
assert(kwnames == NULL);
assert(PyVectorcall_NARGS(nargsf) == 3);
return call_trace_func(self, args[2]);
}

static PyObject *
sys_trace_instruction_func(
_PyLegacyEventHandler *self, PyObject *const *args,
PyObject *op, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = _PyLegacyEventHandler_CAST(op);
assert(kwnames == NULL);
assert(PyVectorcall_NARGS(nargsf) == 2);
PyFrameObject *frame = PyEval_GetFrame();
Expand Down Expand Up @@ -520,48 +527,48 @@ setup_tracing(PyThreadState *tstate, Py_tracefunc func, PyObject *arg, PyObject
if (!tstate->interp->sys_trace_initialized) {
tstate->interp->sys_trace_initialized = true;
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
(vectorcallfunc)sys_trace_start, PyTrace_CALL,
PY_MONITORING_EVENT_PY_START, PY_MONITORING_EVENT_PY_RESUME)) {
sys_trace_start, PyTrace_CALL,
PY_MONITORING_EVENT_PY_START, PY_MONITORING_EVENT_PY_RESUME)) {
return -1;
}
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
(vectorcallfunc)sys_trace_throw, PyTrace_CALL,
PY_MONITORING_EVENT_PY_THROW, -1)) {
sys_trace_throw, PyTrace_CALL,
PY_MONITORING_EVENT_PY_THROW, -1)) {
return -1;
}
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
(vectorcallfunc)sys_trace_return, PyTrace_RETURN,
PY_MONITORING_EVENT_PY_RETURN, -1)) {
sys_trace_return, PyTrace_RETURN,
PY_MONITORING_EVENT_PY_RETURN, -1)) {
return -1;
}
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
(vectorcallfunc)sys_trace_yield, PyTrace_RETURN,
PY_MONITORING_EVENT_PY_YIELD, -1)) {
sys_trace_yield, PyTrace_RETURN,
PY_MONITORING_EVENT_PY_YIELD, -1)) {
return -1;
}
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
(vectorcallfunc)sys_trace_exception_func, PyTrace_EXCEPTION,
PY_MONITORING_EVENT_RAISE, PY_MONITORING_EVENT_STOP_ITERATION)) {
sys_trace_exception_func, PyTrace_EXCEPTION,
PY_MONITORING_EVENT_RAISE, PY_MONITORING_EVENT_STOP_ITERATION)) {
return -1;
}
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
(vectorcallfunc)sys_trace_line_func, PyTrace_LINE,
PY_MONITORING_EVENT_LINE, -1)) {
sys_trace_line_func, PyTrace_LINE,
PY_MONITORING_EVENT_LINE, -1)) {
return -1;
}
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
(vectorcallfunc)sys_trace_unwind, PyTrace_RETURN,
PY_MONITORING_EVENT_PY_UNWIND, -1)) {
sys_trace_unwind, PyTrace_RETURN,
PY_MONITORING_EVENT_PY_UNWIND, -1)) {
return -1;
}
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
(vectorcallfunc)sys_trace_jump_func, PyTrace_LINE,
PY_MONITORING_EVENT_JUMP, -1)) {
sys_trace_jump_func, PyTrace_LINE,
PY_MONITORING_EVENT_JUMP, -1)) {
return -1;
}
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
(vectorcallfunc)sys_trace_instruction_func, PyTrace_OPCODE,
PY_MONITORING_EVENT_INSTRUCTION, -1)) {
sys_trace_instruction_func, PyTrace_OPCODE,
PY_MONITORING_EVENT_INSTRUCTION, -1)) {
return -1;
}
}
Expand Down