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

Skip to content

Commit 79c2c68

Browse files
committed
Python: CG trace: Nicer logging
1 parent 0a7e6a9 commit 79c2c68

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ def expr_from_instruction(instructions: List[Instruction], index: int) -> Byteco
176176
def expr_from_frame(frame: FrameType) -> BytecodeExpr:
177177
bytecode = dis.Bytecode(frame.f_code, current_offset=frame.f_lasti)
178178

179-
LOGGER.debug(f"bytecode: \n{bytecode.dis()}")
179+
LOGGER.debug(
180+
f"{frame.f_code.co_filename}:{frame.f_lineno}: bytecode: \n{bytecode.dis()}"
181+
)
180182

181183
instructions = list(iter(bytecode))
182184
last_instruction_index = [inst.offset for inst in instructions].index(frame.f_lasti)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __str__(self):
5050
del d["bytecode_expr"]
5151
normal_fields = ", ".join(f"{k}={v!r}" for k, v in d.items())
5252

53-
return f"{type(self).__name__}({normal_fields}, bytecode_expr≈{repr(str(self.bytecode_expr))})"
53+
return f"{type(self).__name__}({normal_fields}, bytecode_expr≈{str(self.bytecode_expr)})"
5454

5555
@classmethod
5656
def from_frame(cls, frame: FrameType):

0 commit comments

Comments
 (0)