From f7fc9a16455913bc97b969a653e06a00dfa9eb23 Mon Sep 17 00:00:00 2001 From: Scott Lagler Date: Tue, 21 Nov 2023 20:01:33 -0500 Subject: Fix address printing for BasicBlocks in repr --- python/basicblock.py | 4 ++-- python/highlevelil.py | 7 +++++++ python/lowlevelil.py | 7 +++++++ python/mediumlevelil.py | 7 +++++++ 4 files changed, 23 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/python/basicblock.py b/python/basicblock.py index 98cc79fa..64f2101b 100644 --- a/python/basicblock.py +++ b/python/basicblock.py @@ -68,9 +68,9 @@ class BasicBlock: def __repr__(self): arch = self.arch if arch: - return f"<{self.__class__.__name__}: {arch.name}@{self.start}-{self.end}>" + return f"<{self.__class__.__name__}: {arch.name}@{self.start:#x}-{self.end:#x}>" else: - return f"<{self.__class__.__name__}: {self.start}-{self.end}>" + return f"<{self.__class__.__name__}: {self.start:#x}-{self.end:#x}>" def __len__(self): return int(core.BNGetBasicBlockLength(self.handle)) diff --git a/python/highlevelil.py b/python/highlevelil.py index 5e5708b5..4795ff7f 100644 --- a/python/highlevelil.py +++ b/python/highlevelil.py @@ -3013,6 +3013,13 @@ class HighLevelILBasicBlock(basicblock.BasicBlock): else: return False + def __repr__(self): + arch = self.arch + if arch: + return f"<{self.__class__.__name__}: {arch.name}@{self.start}-{self.end}>" + else: + return f"<{self.__class__.__name__}: {self.start}-{self.end}>" + @property def instruction_count(self) -> int: return self.end - self.start diff --git a/python/lowlevelil.py b/python/lowlevelil.py index 4ab79621..3354dae4 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -5291,6 +5291,13 @@ class LowLevelILBasicBlock(basicblock.BasicBlock): else: return self._il_function[self.end + idx] + def __repr__(self): + arch = self.arch + if arch: + return f"<{self.__class__.__name__}: {arch.name}@{self.start}-{self.end}>" + else: + return f"<{self.__class__.__name__}: {self.start}-{self.end}>" + def _create_instance(self, handle): """Internal method by super to instantiate child instances""" return LowLevelILBasicBlock(handle, self._il_function, self.view) diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py index 1f122d2a..c1c4d231 100644 --- a/python/mediumlevelil.py +++ b/python/mediumlevelil.py @@ -3752,6 +3752,13 @@ class MediumLevelILBasicBlock(basicblock.BasicBlock): else: return False + def __repr__(self): + arch = self.arch + if arch: + return f"<{self.__class__.__name__}: {arch.name}@{self.start}-{self.end}>" + else: + return f"<{self.__class__.__name__}: {self.start}-{self.end}>" + def _create_instance( self, handle: core.BNBasicBlockHandle) -> 'MediumLevelILBasicBlock': """Internal method by super to instantiate child instances""" -- cgit v1.3.1