@@ -903,26 +903,34 @@ instrumentation_cross_checks(PyInterpreterState *interp, PyCodeObject *code)
903
903
#endif
904
904
905
905
static inline uint8_t
906
- get_tools_for_instruction (PyCodeObject * code , int i , int event )
906
+ get_tools_for_instruction (PyCodeObject * code , PyInterpreterState * interp , int i , int event )
907
907
{
908
908
uint8_t tools ;
909
909
assert (event != PY_MONITORING_EVENT_LINE );
910
910
assert (event != PY_MONITORING_EVENT_INSTRUCTION );
911
- assert (instrumentation_cross_checks (PyThreadState_GET ()-> interp , code ));
912
- _PyCoMonitoringData * monitoring = code -> _co_monitoring ;
913
911
if (event >= PY_MONITORING_UNGROUPED_EVENTS ) {
914
912
assert (event == PY_MONITORING_EVENT_C_RAISE ||
915
913
event == PY_MONITORING_EVENT_C_RETURN );
916
914
event = PY_MONITORING_EVENT_CALL ;
917
915
}
918
- if (event < PY_MONITORING_INSTRUMENTED_EVENTS && monitoring -> tools ) {
919
- tools = monitoring -> tools [i ];
916
+ if (event < PY_MONITORING_INSTRUMENTED_EVENTS ) {
917
+ CHECK (is_version_up_to_date (code , interp ));
918
+ CHECK (instrumentation_cross_checks (interp , code ));
919
+ if (code -> _co_monitoring -> tools ) {
920
+ tools = code -> _co_monitoring -> tools [i ];
921
+ }
922
+ else {
923
+ tools = code -> _co_monitoring -> active_monitors .tools [event ];
924
+ }
920
925
}
921
926
else {
922
- tools = code -> _co_monitoring -> active_monitors .tools [event ];
927
+ if (code -> _co_monitoring ) {
928
+ tools = code -> _co_monitoring -> active_monitors .tools [event ];
929
+ }
930
+ else {
931
+ tools = interp -> monitors .tools [event ];
932
+ }
923
933
}
924
- CHECK (tools_is_subset_for_event (code , event , tools ));
925
- CHECK ((tools & code -> _co_monitoring -> active_monitors .tools [event ]) == tools );
926
934
return tools ;
927
935
}
928
936
@@ -937,9 +945,6 @@ call_instrumentation_vector(
937
945
assert (!_PyErr_Occurred (tstate ));
938
946
assert (args [0 ] == NULL );
939
947
PyCodeObject * code = _PyFrame_GetCode (frame );
940
- assert (code -> _co_instrumentation_version == tstate -> interp -> monitoring_version );
941
- assert (is_version_up_to_date (code , tstate -> interp ));
942
- assert (instrumentation_cross_checks (tstate -> interp , code ));
943
948
assert (args [1 ] == NULL );
944
949
args [1 ] = (PyObject * )code ;
945
950
int offset = (int )(instr - _PyCode_CODE (code ));
@@ -952,11 +957,11 @@ call_instrumentation_vector(
952
957
}
953
958
assert (args [2 ] == NULL );
954
959
args [2 ] = offset_obj ;
955
- uint8_t tools = get_tools_for_instruction (code , offset , event );
960
+ PyInterpreterState * interp = tstate -> interp ;
961
+ uint8_t tools = get_tools_for_instruction (code , interp , offset , event );
956
962
Py_ssize_t nargsf = nargs | PY_VECTORCALL_ARGUMENTS_OFFSET ;
957
963
PyObject * * callargs = & args [1 ];
958
964
int err = 0 ;
959
- PyInterpreterState * interp = tstate -> interp ;
960
965
while (tools ) {
961
966
int tool = most_significant_bit (tools );
962
967
assert (tool >= 0 && tool < 8 );
0 commit comments