|
1 | 1 | ..highlight::c |
2 | 2 |
|
3 | | -.._monitoring: |
| 3 | +.._c-api-monitoring: |
4 | 4 |
|
5 | 5 | Monitoring C API |
6 | 6 | ================ |
@@ -133,32 +133,60 @@ Managing the Monitoring State |
133 | 133 | Monitoring states can be managed with the help of monitoring scopes. A scope |
134 | 134 | would typically correspond to a python function. |
135 | 135 |
|
136 | | -..:c:function:: int PyMonitoring_EnterScope(PyMonitoringState *state_array, uint64_t *version, const uint8_t *event_types, Py_ssize_t length) |
| 136 | +..c:function::intPyMonitoring_EnterScope(PyMonitoringState *state_array, uint64_t *version, const uint8_t *event_types, Py_ssize_t length) |
137 | 137 |
|
138 | 138 | Enter a monitored scope. ``event_types`` is an array of the event IDs for |
139 | 139 | events that may be fired from the scope. For example, the ID of a ``PY_START`` |
140 | 140 | event is the value ``PY_MONITORING_EVENT_PY_START``, which is numerically equal |
141 | 141 | to the base-2 logarithm of ``sys.monitoring.events.PY_START``. |
142 | 142 | ``state_array`` is an array with a monitoring state entry for each event in |
143 | 143 | ``event_types``, it is allocated by the user but populated by |
144 | | -``PyMonitoring_EnterScope`` with information about the activation state of |
| 144 | +:c:func:`!PyMonitoring_EnterScope` with information about the activation state of |
145 | 145 | the event. The size of ``event_types`` (and hence also of ``state_array``) |
146 | 146 | is given in ``length``. |
147 | 147 |
|
148 | 148 | The ``version`` argument is a pointer to a value which should be allocated |
149 | 149 | by the user together with ``state_array`` and initialized to 0, |
150 | | - and then set only by``PyMonitoring_EnterScope`` itelf. It allows this |
| 150 | + and then set only by:c:func:`!PyMonitoring_EnterScope` itelf. It allows this |
151 | 151 | function to determine whether event states have changed since the previous call, |
152 | 152 | and to return quickly if they have not. |
153 | 153 |
|
154 | 154 | The scopes referred to here are lexical scopes: a function, class or method. |
155 | | -``PyMonitoring_EnterScope`` should be called whenever the lexical scope is |
| 155 | +:c:func:`!PyMonitoring_EnterScope` should be called whenever the lexical scope is |
156 | 156 | entered. Scopes can be reentered, reusing the same *state_array* and *version*, |
157 | 157 | in situations like when emulating a recursive Python function. When a code-like's |
158 | 158 | execution is paused, such as when emulating a generator, the scope needs to |
159 | 159 | be exited and re-entered. |
160 | 160 |
|
161 | | -
|
162 | | -.. :c:function:: int PyMonitoring_ExitScope(void) |
163 | | -
|
164 | | - Exit the last scope that was entered with ``PyMonitoring_EnterScope``. |
| 161 | + The macros for *event_types* are: |
| 162 | +
|
| 163 | + .. c:namespace:: NULL |
| 164 | +
|
| 165 | + .. The table is here to make the docs searchable, and to allow automatic |
| 166 | + links to the identifiers. |
| 167 | +
|
| 168 | + ================================================== ===================================== |
| 169 | + Macro Event |
| 170 | + ================================================== ===================================== |
| 171 | + .. c:macro:: PY_MONITORING_EVENT_BRANCH :monitoring-event:`BRANCH` |
| 172 | + .. c:macro:: PY_MONITORING_EVENT_CALL :monitoring-event:`CALL` |
| 173 | + .. c:macro:: PY_MONITORING_EVENT_C_RAISE :monitoring-event:`C_RAISE` |
| 174 | + .. c:macro:: PY_MONITORING_EVENT_C_RETURN :monitoring-event:`C_RETURN` |
| 175 | + .. c:macro:: PY_MONITORING_EVENT_EXCEPTION_HANDLED :monitoring-event:`EXCEPTION_HANDLED` |
| 176 | + .. c:macro:: PY_MONITORING_EVENT_INSTRUCTION :monitoring-event:`INSTRUCTION` |
| 177 | + .. c:macro:: PY_MONITORING_EVENT_JUMP :monitoring-event:`JUMP` |
| 178 | + .. c:macro:: PY_MONITORING_EVENT_LINE :monitoring-event:`LINE` |
| 179 | + .. c:macro:: PY_MONITORING_EVENT_PY_RESUME :monitoring-event:`PY_RESUME` |
| 180 | + .. c:macro:: PY_MONITORING_EVENT_PY_RETURN :monitoring-event:`PY_RETURN` |
| 181 | + .. c:macro:: PY_MONITORING_EVENT_PY_START :monitoring-event:`PY_START` |
| 182 | + .. c:macro:: PY_MONITORING_EVENT_PY_THROW :monitoring-event:`PY_THROW` |
| 183 | + .. c:macro:: PY_MONITORING_EVENT_PY_UNWIND :monitoring-event:`PY_UNWIND` |
| 184 | + .. c:macro:: PY_MONITORING_EVENT_PY_YIELD :monitoring-event:`PY_YIELD` |
| 185 | + .. c:macro:: PY_MONITORING_EVENT_RAISE :monitoring-event:`RAISE` |
| 186 | + .. c:macro:: PY_MONITORING_EVENT_RERAISE :monitoring-event:`RERAISE` |
| 187 | + .. c:macro:: PY_MONITORING_EVENT_STOP_ITERATION :monitoring-event:`STOP_ITERATION` |
| 188 | + ================================================== ===================================== |
| 189 | +
|
| 190 | +.. c:function:: int PyMonitoring_ExitScope(void) |
| 191 | +
|
| 192 | + Exit the last scope that was entered with :c:func:`!PyMonitoring_EnterScope`. |