Path: blob/main/Include/internal/pycore_instruments.h
12 views
1#ifndef Py_INTERNAL_INSTRUMENT_H2#define Py_INTERNAL_INSTRUMENT_H345#include "pycore_bitutils.h" // _Py_popcount326#include "pycore_frame.h"78#include "cpython/code.h"910#ifdef __cplusplus11extern "C" {12#endif1314#define PY_MONITORING_TOOL_IDS 81516/* Local events.17* These require bytecode instrumentation */1819#define PY_MONITORING_EVENT_PY_START 020#define PY_MONITORING_EVENT_PY_RESUME 121#define PY_MONITORING_EVENT_PY_RETURN 222#define PY_MONITORING_EVENT_PY_YIELD 323#define PY_MONITORING_EVENT_CALL 424#define PY_MONITORING_EVENT_LINE 525#define PY_MONITORING_EVENT_INSTRUCTION 626#define PY_MONITORING_EVENT_JUMP 727#define PY_MONITORING_EVENT_BRANCH 828#define PY_MONITORING_EVENT_STOP_ITERATION 92930#define PY_MONITORING_INSTRUMENTED_EVENTS 103132/* Other events, mainly exceptions */3334#define PY_MONITORING_EVENT_RAISE 1035#define PY_MONITORING_EVENT_EXCEPTION_HANDLED 1136#define PY_MONITORING_EVENT_PY_UNWIND 1237#define PY_MONITORING_EVENT_PY_THROW 13383940/* Ancilliary events */4142#define PY_MONITORING_EVENT_C_RETURN 1443#define PY_MONITORING_EVENT_C_RAISE 15444546typedef uint32_t _PyMonitoringEventSet;4748/* Tool IDs */4950/* These are defined in PEP 669 for convenience to avoid clashes */51#define PY_MONITORING_DEBUGGER_ID 052#define PY_MONITORING_COVERAGE_ID 153#define PY_MONITORING_PROFILER_ID 254#define PY_MONITORING_OPTIMIZER_ID 55556/* Internal IDs used to suuport sys.setprofile() and sys.settrace() */57#define PY_MONITORING_SYS_PROFILE_ID 658#define PY_MONITORING_SYS_TRACE_ID 7596061PyObject *_PyMonitoring_RegisterCallback(int tool_id, int event_id, PyObject *obj);6263int _PyMonitoring_SetEvents(int tool_id, _PyMonitoringEventSet events);6465extern int66_Py_call_instrumentation(PyThreadState *tstate, int event,67_PyInterpreterFrame *frame, _Py_CODEUNIT *instr);6869extern int70_Py_call_instrumentation_line(PyThreadState *tstate, _PyInterpreterFrame* frame,71_Py_CODEUNIT *instr, _Py_CODEUNIT *prev);7273extern int74_Py_call_instrumentation_instruction(75PyThreadState *tstate, _PyInterpreterFrame* frame, _Py_CODEUNIT *instr);7677_Py_CODEUNIT *78_Py_call_instrumentation_jump(79PyThreadState *tstate, int event,80_PyInterpreterFrame *frame, _Py_CODEUNIT *instr, _Py_CODEUNIT *target);8182extern int83_Py_call_instrumentation_arg(PyThreadState *tstate, int event,84_PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg);8586extern int87_Py_call_instrumentation_2args(PyThreadState *tstate, int event,88_PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg0, PyObject *arg1);8990extern void91_Py_call_instrumentation_exc0(PyThreadState *tstate, int event,92_PyInterpreterFrame *frame, _Py_CODEUNIT *instr);9394extern void95_Py_call_instrumentation_exc2(PyThreadState *tstate, int event,96_PyInterpreterFrame *frame, _Py_CODEUNIT *instr, PyObject *arg0, PyObject *arg1);9798extern int99_Py_Instrumentation_GetLine(PyCodeObject *code, int index);100101extern PyObject _PyInstrumentation_MISSING;102extern PyObject _PyInstrumentation_DISABLE;103104#ifdef __cplusplus105}106#endif107#endif /* !Py_INTERNAL_INSTRUMENT_H */108109110