aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/instrumentation.c
diff options
context:
space:
mode:
authorTian Gao <gaogaotiantian@hotmail.com>2023-11-03 09:39:50 -0700
committerGitHub <noreply@github.com>2023-11-03 16:39:50 +0000
commite0afed7e276b6611a2142ec70a0440298d528305 (patch)
tree9170a4828e2961750e84251115ee5ac91f31f31e /Python/instrumentation.c
parent2bc01cc0c72a3d91bdcce09886efa987a90396d9 (diff)
downloadcpython-e0afed7e276b6611a2142ec70a0440298d528305.tar.gz
cpython-e0afed7e276b6611a2142ec70a0440298d528305.zip
gh-103615: Use local events for opcode tracing (GH-109472)
* Use local monitoring for opcode trace * Remove f_opcode_trace_set * Add test for setting f_trace_opcodes after settrace
Diffstat (limited to 'Python/instrumentation.c')
-rw-r--r--Python/instrumentation.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/Python/instrumentation.c b/Python/instrumentation.c
index 9ee11588e44..35b0e7a8f35 100644
--- a/Python/instrumentation.c
+++ b/Python/instrumentation.c
@@ -1833,6 +1833,23 @@ _PyMonitoring_SetLocalEvents(PyCodeObject *code, int tool_id, _PyMonitoringEvent
return 0;
}
+int
+_PyMonitoring_GetLocalEvents(PyCodeObject *code, int tool_id, _PyMonitoringEventSet *events)
+{
+ assert(0 <= tool_id && tool_id < PY_MONITORING_TOOL_IDS);
+ PyInterpreterState *interp = _PyInterpreterState_GET();
+ if (check_tool(interp, tool_id)) {
+ return -1;
+ }
+ if (code->_co_monitoring == NULL) {
+ *events = 0;
+ return 0;
+ }
+ _Py_LocalMonitors *local = &code->_co_monitoring->local_monitors;
+ *events = get_local_events(local, tool_id);
+ return 0;
+}
+
/*[clinic input]
module monitoring
[clinic start generated code]*/