| 
									
										
										
										
											2023-04-12 12:04:55 +01:00
										 |  |  | #ifndef Py_INTERNAL_INSTRUMENT_H
 | 
					
						
							|  |  |  | #define Py_INTERNAL_INSTRUMENT_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-21 19:15:52 +02:00
										 |  |  | #ifndef Py_BUILD_CORE
 | 
					
						
							|  |  |  | #  error "this header requires Py_BUILD_CORE define"
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2023-04-12 12:04:55 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-21 20:05:59 +02:00
										 |  |  | #include "pycore_frame.h"         // _PyInterpreterFrame
 | 
					
						
							| 
									
										
										
										
											2023-04-12 12:04:55 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PY_MONITORING_TOOL_IDS 8
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Local events.
 | 
					
						
							|  |  |  |  * These require bytecode instrumentation */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PY_MONITORING_EVENT_PY_START 0
 | 
					
						
							|  |  |  | #define PY_MONITORING_EVENT_PY_RESUME 1
 | 
					
						
							|  |  |  | #define PY_MONITORING_EVENT_PY_RETURN 2
 | 
					
						
							|  |  |  | #define PY_MONITORING_EVENT_PY_YIELD 3
 | 
					
						
							|  |  |  | #define PY_MONITORING_EVENT_CALL 4
 | 
					
						
							|  |  |  | #define PY_MONITORING_EVENT_LINE 5
 | 
					
						
							|  |  |  | #define PY_MONITORING_EVENT_INSTRUCTION 6
 | 
					
						
							|  |  |  | #define PY_MONITORING_EVENT_JUMP 7
 | 
					
						
							|  |  |  | #define PY_MONITORING_EVENT_BRANCH 8
 | 
					
						
							|  |  |  | #define PY_MONITORING_EVENT_STOP_ITERATION 9
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-27 15:27:11 +01:00
										 |  |  | #define PY_MONITORING_IS_INSTRUMENTED_EVENT(ev) \
 | 
					
						
							| 
									
										
										
										
											2023-09-05 08:03:53 +01:00
										 |  |  |     ((ev) < _PY_MONITORING_LOCAL_EVENTS) | 
					
						
							| 
									
										
										
										
											2023-04-12 12:04:55 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Other events, mainly exceptions */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PY_MONITORING_EVENT_RAISE 10
 | 
					
						
							|  |  |  | #define PY_MONITORING_EVENT_EXCEPTION_HANDLED 11
 | 
					
						
							|  |  |  | #define PY_MONITORING_EVENT_PY_UNWIND 12
 | 
					
						
							|  |  |  | #define PY_MONITORING_EVENT_PY_THROW 13
 | 
					
						
							| 
									
										
										
										
											2023-07-27 13:32:30 +01:00
										 |  |  | #define PY_MONITORING_EVENT_RERAISE 14
 | 
					
						
							| 
									
										
										
										
											2023-04-12 12:04:55 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Ancilliary events */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-27 13:32:30 +01:00
										 |  |  | #define PY_MONITORING_EVENT_C_RETURN 15
 | 
					
						
							|  |  |  | #define PY_MONITORING_EVENT_C_RAISE 16
 | 
					
						
							| 
									
										
										
										
											2023-04-12 12:04:55 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef uint32_t _PyMonitoringEventSet; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Tool IDs */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* These are defined in PEP 669 for convenience to avoid clashes */ | 
					
						
							|  |  |  | #define PY_MONITORING_DEBUGGER_ID 0
 | 
					
						
							|  |  |  | #define PY_MONITORING_COVERAGE_ID 1
 | 
					
						
							|  |  |  | #define PY_MONITORING_PROFILER_ID 2
 | 
					
						
							|  |  |  | #define PY_MONITORING_OPTIMIZER_ID 5
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Internal IDs used to suuport sys.setprofile() and sys.settrace() */ | 
					
						
							|  |  |  | #define PY_MONITORING_SYS_PROFILE_ID 6
 | 
					
						
							|  |  |  | #define PY_MONITORING_SYS_TRACE_ID 7
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyObject *_PyMonitoring_RegisterCallback(int tool_id, int event_id, PyObject *obj); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int _PyMonitoring_SetEvents(int tool_id, _PyMonitoringEventSet events); | 
					
						
							| 
									
										
										
										
											2023-11-03 09:39:50 -07:00
										 |  |  | int _PyMonitoring_SetLocalEvents(PyCodeObject *code, int tool_id, _PyMonitoringEventSet events); | 
					
						
							|  |  |  | int _PyMonitoring_GetLocalEvents(PyCodeObject *code, int tool_id, _PyMonitoringEventSet *events); | 
					
						
							| 
									
										
										
										
											2023-04-12 12:04:55 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | extern int | 
					
						
							|  |  |  | _Py_call_instrumentation(PyThreadState *tstate, int event, | 
					
						
							|  |  |  |     _PyInterpreterFrame *frame, _Py_CODEUNIT *instr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern int | 
					
						
							|  |  |  | _Py_call_instrumentation_line(PyThreadState *tstate, _PyInterpreterFrame* frame, | 
					
						
							| 
									
										
										
										
											2023-05-12 12:21:20 +01:00
										 |  |  |                               _Py_CODEUNIT *instr, _Py_CODEUNIT *prev); | 
					
						
							| 
									
										
										
										
											2023-04-12 12:04:55 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | extern int | 
					
						
							|  |  |  | _Py_call_instrumentation_instruction( | 
					
						
							|  |  |  |     PyThreadState *tstate, _PyInterpreterFrame* frame, _Py_CODEUNIT *instr); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-12 12:21:20 +01:00
										 |  |  | _Py_CODEUNIT * | 
					
						
							| 
									
										
										
										
											2023-04-12 12:04:55 +01:00
										 |  |  | _Py_call_instrumentation_jump( | 
					
						
							|  |  |  |     PyThreadState *tstate, int event, | 
					
						
							|  |  |  |     _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, _Py_CODEUNIT *target); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern int | 
					
						
							|  |  |  | _Py_call_instrumentation_arg(PyThreadState *tstate, int event, | 
					
						
							|  |  |  |     _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern int | 
					
						
							|  |  |  | _Py_call_instrumentation_2args(PyThreadState *tstate, int event, | 
					
						
							|  |  |  |     _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg0, PyObject *arg1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern void | 
					
						
							|  |  |  | _Py_call_instrumentation_exc2(PyThreadState *tstate, int event, | 
					
						
							|  |  |  |     _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg0, PyObject *arg1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern int | 
					
						
							|  |  |  | _Py_Instrumentation_GetLine(PyCodeObject *code, int index); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern PyObject _PyInstrumentation_MISSING; | 
					
						
							| 
									
										
										
										
											2023-05-12 12:21:20 +01:00
										 |  |  | extern PyObject _PyInstrumentation_DISABLE; | 
					
						
							| 
									
										
										
										
											2023-04-12 12:04:55 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | #endif /* !Py_INTERNAL_INSTRUMENT_H */
 |