Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3752a25

Browse files
committed
Python: CG trace: Handle LOAD_DEREF
1 parent 61b1d3e commit 3752a25

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
def func(func_arg):
2+
print("func")
3+
4+
def func2():
5+
print("func2")
6+
return func_arg()
7+
8+
func2()
9+
10+
11+
def nop():
12+
print("nop")
13+
pass
14+
15+
16+
func(nop)
17+
18+
19+
"""
20+
Needs handling of LOAD_DEREF. Disassembled bytecode looks like:
21+
22+
6 8 LOAD_DEREF 0 (func_arg)
23+
10 CALL_FUNCTION 0
24+
12 RETURN_VALUE
25+
"""

python/tools/recorded-call-graph-metrics/src/cg_trace/bytecode_reconstructor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def expr_from_instruction(instructions: List[Instruction], index: int) -> Byteco
143143

144144
LOGGER.debug(f"expr_from_instruction: {inst} {index=}")
145145

146-
if inst.opname in ["LOAD_GLOBAL", "LOAD_FAST", "LOAD_NAME"]:
146+
if inst.opname in ["LOAD_GLOBAL", "LOAD_FAST", "LOAD_NAME", "LOAD_DEREF"]:
147147
return BytecodeVariableName(inst.argval)
148148

149149
elif inst.opname in ["LOAD_CONST"]:

0 commit comments

Comments
 (0)