From f6d43d5eda8a1bbc95fc5467beb4cc9723b85682 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Fri, 24 Sep 2021 10:33:40 -0400 Subject: Fix mlil/llil tokens, __repr__, and __str__ --- python/lowlevelil.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'python/lowlevelil.py') diff --git a/python/lowlevelil.py b/python/lowlevelil.py index b5c25188..8afbe418 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -519,23 +519,18 @@ class LowLevelILInstruction: return self.instr.source_operand @property - def tokens(self) -> Optional[TokenList]: + def tokens(self) -> TokenList: """LLIL tokens (read-only)""" count = ctypes.c_ulonglong() assert self.function.arch is not None, f"type(self.function): {type(self.function)} " tokens = ctypes.POINTER(core.BNInstructionTextToken)() - if (self.instr_index is not None) and (self.function.source_function is not None): - if not core.BNGetLowLevelILInstructionText(self.function.handle, self.function.source_function.handle, - self.function.arch.handle, self.instr_index, tokens, count): - return None - else: - # TODO: Special case LLIL_CALL_OUTPUT_SSA - if not core.BNGetLowLevelILExprText(self.function.handle, self.function.arch.handle, - self.expr_index, tokens, count): - return None - result = function.InstructionTextToken._from_core_struct(tokens, count.value) - core.BNFreeInstructionText(tokens, count.value) - return result + result = core.BNGetLowLevelILExprText(self.function.handle, self.function.arch.handle, + self.expr_index, tokens, count) + assert result, "core.BNGetLowLevelILExprText returned False" + try: + return function.InstructionTextToken._from_core_struct(tokens, count.value) + finally: + core.BNFreeInstructionText(tokens, count.value) @property def il_basic_block(self) -> 'LowLevelILBasicBlock': -- cgit v1.3.1