mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Python: CG trace: Nicer logging
This commit is contained in:
@@ -176,7 +176,9 @@ def expr_from_instruction(instructions: List[Instruction], index: int) -> Byteco
|
|||||||
def expr_from_frame(frame: FrameType) -> BytecodeExpr:
|
def expr_from_frame(frame: FrameType) -> BytecodeExpr:
|
||||||
bytecode = dis.Bytecode(frame.f_code, current_offset=frame.f_lasti)
|
bytecode = dis.Bytecode(frame.f_code, current_offset=frame.f_lasti)
|
||||||
|
|
||||||
LOGGER.debug(f"bytecode: \n{bytecode.dis()}")
|
LOGGER.debug(
|
||||||
|
f"{frame.f_code.co_filename}:{frame.f_lineno}: bytecode: \n{bytecode.dis()}"
|
||||||
|
)
|
||||||
|
|
||||||
instructions = list(iter(bytecode))
|
instructions = list(iter(bytecode))
|
||||||
last_instruction_index = [inst.offset for inst in instructions].index(frame.f_lasti)
|
last_instruction_index = [inst.offset for inst in instructions].index(frame.f_lasti)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class Call:
|
|||||||
del d["bytecode_expr"]
|
del d["bytecode_expr"]
|
||||||
normal_fields = ", ".join(f"{k}={v!r}" for k, v in d.items())
|
normal_fields = ", ".join(f"{k}={v!r}" for k, v in d.items())
|
||||||
|
|
||||||
return f"{type(self).__name__}({normal_fields}, bytecode_expr≈{repr(str(self.bytecode_expr))})"
|
return f"{type(self).__name__}({normal_fields}, bytecode_expr≈{str(self.bytecode_expr)})"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_frame(cls, frame: FrameType):
|
def from_frame(cls, frame: FrameType):
|
||||||
|
|||||||
Reference in New Issue
Block a user