Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:18:08

0001 
0002 #ifndef Py_INTERNAL_INSTRUMENT_H
0003 #define Py_INTERNAL_INSTRUMENT_H
0004 
0005 
0006 #include "pycore_bitutils.h"      // _Py_popcount32
0007 #include "pycore_frame.h"
0008 
0009 #include "cpython/code.h"
0010 
0011 #ifdef __cplusplus
0012 extern "C" {
0013 #endif
0014 
0015 #define PY_MONITORING_TOOL_IDS 8
0016 
0017 /* Local events.
0018  * These require bytecode instrumentation */
0019 
0020 #define PY_MONITORING_EVENT_PY_START 0
0021 #define PY_MONITORING_EVENT_PY_RESUME 1
0022 #define PY_MONITORING_EVENT_PY_RETURN 2
0023 #define PY_MONITORING_EVENT_PY_YIELD 3
0024 #define PY_MONITORING_EVENT_CALL 4
0025 #define PY_MONITORING_EVENT_LINE 5
0026 #define PY_MONITORING_EVENT_INSTRUCTION 6
0027 #define PY_MONITORING_EVENT_JUMP 7
0028 #define PY_MONITORING_EVENT_BRANCH 8
0029 #define PY_MONITORING_EVENT_STOP_ITERATION 9
0030 
0031 #define PY_MONITORING_IS_INSTRUMENTED_EVENT(ev) \
0032     ((ev) < _PY_MONITORING_LOCAL_EVENTS)
0033 
0034 /* Other events, mainly exceptions */
0035 
0036 #define PY_MONITORING_EVENT_RAISE 10
0037 #define PY_MONITORING_EVENT_EXCEPTION_HANDLED 11
0038 #define PY_MONITORING_EVENT_PY_UNWIND 12
0039 #define PY_MONITORING_EVENT_PY_THROW 13
0040 #define PY_MONITORING_EVENT_RERAISE 14
0041 
0042 
0043 /* Ancillary events */
0044 
0045 #define PY_MONITORING_EVENT_C_RETURN 15
0046 #define PY_MONITORING_EVENT_C_RAISE 16
0047 
0048 
0049 typedef uint32_t _PyMonitoringEventSet;
0050 
0051 /* Tool IDs */
0052 
0053 /* These are defined in PEP 669 for convenience to avoid clashes */
0054 #define PY_MONITORING_DEBUGGER_ID 0
0055 #define PY_MONITORING_COVERAGE_ID 1
0056 #define PY_MONITORING_PROFILER_ID 2
0057 #define PY_MONITORING_OPTIMIZER_ID 5
0058 
0059 /* Internal IDs used to suuport sys.setprofile() and sys.settrace() */
0060 #define PY_MONITORING_SYS_PROFILE_ID 6
0061 #define PY_MONITORING_SYS_TRACE_ID 7
0062 
0063 
0064 PyObject *_PyMonitoring_RegisterCallback(int tool_id, int event_id, PyObject *obj);
0065 
0066 int _PyMonitoring_SetEvents(int tool_id, _PyMonitoringEventSet events);
0067 
0068 extern int
0069 _Py_call_instrumentation(PyThreadState *tstate, int event,
0070     _PyInterpreterFrame *frame, _Py_CODEUNIT *instr);
0071 
0072 extern int
0073 _Py_call_instrumentation_line(PyThreadState *tstate, _PyInterpreterFrame* frame,
0074                               _Py_CODEUNIT *instr, _Py_CODEUNIT *prev);
0075 
0076 extern int
0077 _Py_call_instrumentation_instruction(
0078     PyThreadState *tstate, _PyInterpreterFrame* frame, _Py_CODEUNIT *instr);
0079 
0080 _Py_CODEUNIT *
0081 _Py_call_instrumentation_jump(
0082     PyThreadState *tstate, int event,
0083     _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, _Py_CODEUNIT *target);
0084 
0085 extern int
0086 _Py_call_instrumentation_arg(PyThreadState *tstate, int event,
0087     _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg);
0088 
0089 extern int
0090 _Py_call_instrumentation_2args(PyThreadState *tstate, int event,
0091     _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg0, PyObject *arg1);
0092 
0093 extern void
0094 _Py_call_instrumentation_exc2(PyThreadState *tstate, int event,
0095     _PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg0, PyObject *arg1);
0096 
0097 extern int
0098 _Py_Instrumentation_GetLine(PyCodeObject *code, int index);
0099 
0100 extern PyObject _PyInstrumentation_MISSING;
0101 extern PyObject _PyInstrumentation_DISABLE;
0102 
0103 #ifdef __cplusplus
0104 }
0105 #endif
0106 #endif /* !Py_INTERNAL_INSTRUMENT_H */