Skip to content

gh-111178: Fix function signatures in legacy_tracing.c #131464

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

Merged
merged 1 commit into from
Mar 19, 2025
Merged
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
65 changes: 38 additions & 27 deletions Python/legacy_tracing.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,10 @@ call_trace_func(_PyLegacyEventHandler *self, PyObject *arg)

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

static PyObject *
sys_trace_start(
_PyLegacyEventHandler *self, PyObject *const *args,
PyObject *callable, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
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 *callable, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
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 *callable, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
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 *callable, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
assert(!PyErr_Occurred());
assert(kwnames == NULL);
assert(PyVectorcall_NARGS(nargsf) == 3);
Expand All @@ -251,19 +256,21 @@ sys_trace_return(

static PyObject *
sys_trace_yield(
_PyLegacyEventHandler *self, PyObject *const *args,
PyObject *callable, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
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 *callable, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
assert(kwnames == NULL);
assert(PyVectorcall_NARGS(nargsf) == 2);
PyFrameObject *frame = PyEval_GetFrame();
Expand Down Expand Up @@ -313,9 +320,10 @@ trace_line(

static PyObject *
sys_trace_line_func(
_PyLegacyEventHandler *self, PyObject *const *args,
PyObject *callable, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
assert(kwnames == NULL);
PyThreadState *tstate = _PyThreadState_GET();
if (tstate->c_tracefunc == NULL) {
Expand All @@ -339,9 +347,10 @@ sys_trace_line_func(
* Handle that case here */
static PyObject *
sys_trace_jump_func(
_PyLegacyEventHandler *self, PyObject *const *args,
PyObject *callable, PyObject *const *args,
size_t nargsf, PyObject *kwnames
) {
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
assert(kwnames == NULL);
PyThreadState *tstate = _PyThreadState_GET();
if (tstate->c_tracefunc == NULL) {
Expand Down Expand Up @@ -513,48 +522,50 @@ 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
Loading