diff --git a/Include/cpython/monitoring.h b/Include/cpython/monitoring.h index 5094c8c23ae32b..513b18ad041882 100644 --- a/Include/cpython/monitoring.h +++ b/Include/cpython/monitoring.h @@ -9,7 +9,7 @@ extern "C" { /* Local events. - * These require bytecode instrumentation */ + * Some of these require bytecode instrumentation */ #define PY_MONITORING_EVENT_PY_START 0 #define PY_MONITORING_EVENT_PY_RESUME 1 @@ -24,13 +24,18 @@ extern "C" { #define PY_MONITORING_EVENT_STOP_ITERATION 10 #define PY_MONITORING_IS_INSTRUMENTED_EVENT(ev) \ - ((ev) < _PY_MONITORING_LOCAL_EVENTS) +((ev) <= PY_MONITORING_EVENT_STOP_ITERATION) + +#define PY_MONITORING_EVENT_PY_UNWIND 11 + +#define PY_MONITORING_IS_LOCAL_EVENT(ev) \ +((ev) < _PY_MONITORING_LOCAL_EVENTS) + /* Other events, mainly exceptions */ -#define PY_MONITORING_EVENT_RAISE 11 #define PY_MONITORING_EVENT_EXCEPTION_HANDLED 12 -#define PY_MONITORING_EVENT_PY_UNWIND 13 +#define PY_MONITORING_EVENT_RAISE 13 #define PY_MONITORING_EVENT_PY_THROW 14 #define PY_MONITORING_EVENT_RERAISE 15 diff --git a/Include/internal/pycore_instruments.h b/Include/internal/pycore_instruments.h index ebc5622912f0cb..61e1b00c364533 100644 --- a/Include/internal/pycore_instruments.h +++ b/Include/internal/pycore_instruments.h @@ -74,7 +74,7 @@ extern PyObject _PyInstrumentation_DISABLE; /* Total tool ids available */ #define PY_MONITORING_TOOL_IDS 8 /* Count of all local monitoring events */ -#define _PY_MONITORING_LOCAL_EVENTS 11 +#define _PY_MONITORING_LOCAL_EVENTS 12 /* Count of all "real" monitoring events (not derived from other events) */ #define _PY_MONITORING_UNGROUPED_EVENTS 16 /* Count of all monitoring events */ diff --git a/Python/ceval.c b/Python/ceval.c index 5381cd826dfd19..c78b02632c9309 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2615,7 +2615,7 @@ monitor_unwind(PyThreadState *tstate, _PyInterpreterFrame *frame, _Py_CODEUNIT *instr) { - if (no_tools_for_global_event(tstate, PY_MONITORING_EVENT_PY_UNWIND)) { + if (no_tools_for_local_event(tstate, frame, PY_MONITORING_EVENT_PY_UNWIND)) { return; } do_monitor_exc(tstate, frame, instr, PY_MONITORING_EVENT_PY_UNWIND); diff --git a/Python/instrumentation.c b/Python/instrumentation.c index 9e750433cffa89..c037b500eece75 100644 --- a/Python/instrumentation.c +++ b/Python/instrumentation.c @@ -1102,7 +1102,7 @@ get_tools_for_instruction(PyCodeObject *code, PyInterpreterState *interp, int i, event == PY_MONITORING_EVENT_C_RETURN); event = PY_MONITORING_EVENT_CALL; } - if (PY_MONITORING_IS_INSTRUMENTED_EVENT(event)) { + if (PY_MONITORING_IS_LOCAL_EVENT(event)) { CHECK(debug_check_sanity(interp, code)); if (code->_co_monitoring->tools) { tools = code->_co_monitoring->tools[i];