[3.12] gh-109371: Fix monitoring with instruction events set (gh-109385) (#109542)

gh-109371: Fix monitoring with instruction events set (gh-109385)
(cherry picked from commit 412f5e85d6)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
This commit is contained in:
Miss Islington (bot) 2023-09-18 08:40:51 -07:00 committed by GitHub
parent 2401b980da
commit 9412a874a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 2 deletions

View file

@ -647,7 +647,7 @@ instrument(PyCodeObject *code, int i)
if (opcode == INSTRUMENTED_INSTRUCTION) {
opcode_ptr = &code->_co_monitoring->per_instruction_opcodes[i];
opcode = *opcode_ptr;
CHECK(!is_instrumented(opcode));
CHECK(opcode != INSTRUMENTED_INSTRUCTION && opcode != INSTRUMENTED_LINE);
CHECK(opcode == _PyOpcode_Deopt[opcode]);
}
CHECK(opcode != 0);
@ -1252,6 +1252,9 @@ initialize_tools(PyCodeObject *code)
if (opcode == INSTRUMENTED_LINE) {
opcode = code->_co_monitoring->lines[i].original_opcode;
}
if (opcode == INSTRUMENTED_INSTRUCTION) {
opcode = code->_co_monitoring->per_instruction_opcodes[i];
}
bool instrumented = is_instrumented(opcode);
if (instrumented) {
opcode = DE_INSTRUMENT[opcode];