Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 committed Aug 25, 2023
1 parent 4d48313 commit e7ebb62
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Python/instrumentation.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,12 @@ de_instrument(PyCodeObject *code, int i, int event)
_Py_CODEUNIT *instr = &_PyCode_CODE(code)[i];
uint8_t *opcode_ptr = &instr->op.code;
int opcode = *opcode_ptr;
assert(opcode != ENTER_EXECUTOR);
if (opcode == ENTER_EXECUTOR) {
int oparg = instr->op.arg;
_PyExecutorObject *exec = code->co_executors->executors[oparg];
opcode_ptr = &exec->vm_data.opcode;
opcode = *opcode_ptr;
}
if (opcode == INSTRUMENTED_LINE) {
opcode_ptr = &code->_co_monitoring->lines[i].original_opcode;
opcode = *opcode_ptr;
Expand All @@ -575,6 +580,7 @@ de_instrument(PyCodeObject *code, int i, int event)
opcode_ptr = &code->_co_monitoring->per_instruction_opcodes[i];
opcode = *opcode_ptr;
}
assert(opcode != ENTER_EXECUTOR);
int deinstrumented = DE_INSTRUMENT[opcode];
if (deinstrumented == 0) {
return;
Expand Down Expand Up @@ -711,7 +717,21 @@ remove_tools(PyCodeObject * code, int offset, int event, int tools)
assert(event != PY_MONITORING_EVENT_LINE);
assert(event != PY_MONITORING_EVENT_INSTRUCTION);
assert(PY_MONITORING_IS_INSTRUMENTED_EVENT(event));
assert(opcode_has_event(_Py_GetBaseOpcode(code, offset)));
_Py_CODEUNIT co_instr = _PyCode_CODE(code)[offset];
uint8_t co_code = co_instr.op.code;
uint8_t co_arg = co_instr.op.arg;
if (co_code == ENTER_EXECUTOR) {
_PyExecutorObject *exec = code->co_executors->executors[co_arg];
assert(exec != NULL);
assert(exec->vm_data.opcode != ENTER_EXECUTOR);
co_code = _PyOpcode_Deopt[exec->vm_data.opcode];
co_arg = exec->vm_data.oparg;
}
else {
co_code = _Py_GetBaseOpcode(code, offset);
}
assert(co_code != ENTER_EXECUTOR);
assert(opcode_has_event(co_code));
_PyCoMonitoringData *monitoring = code->_co_monitoring;
if (monitoring && monitoring->tools) {
monitoring->tools[offset] &= ~tools;
Expand Down

0 comments on commit e7ebb62

Please sign in to comment.