Skip to content

Commit be59016

Browse files
committed
Python: Update IL Function repr()s
1 parent 2ae357a commit be59016

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

python/highlevelil.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2552,10 +2552,13 @@ def __del__(self):
25522552

25532553
def __repr__(self):
25542554
arch = self.source_function.arch
2555+
form = ""
2556+
if self.il_form == FunctionGraphType.HighLevelILSSAFormFunctionGraph:
2557+
form += " ssa form"
25552558
if arch:
2556-
return "<hlil func: %s@%#x>" % (arch.name, self.source_function.start)
2559+
return f"<HighLevelILFunction{form}: {arch.name}@{self.source_function.start:#x}>"
25572560
else:
2558-
return "<hlil func: %#x>" % self.source_function.start
2561+
return f"<HighLevelILFunction{form}: {self.source_function.start:#x}>"
25592562

25602563
def __eq__(self, other):
25612564
if not isinstance(other, self.__class__):

python/lowlevelil.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3311,12 +3311,17 @@ def __del__(self):
33113311
core.BNFreeLowLevelILFunction(self.handle)
33123312

33133313
def __repr__(self):
3314+
form = ""
3315+
if self.il_form == FunctionGraphType.LiftedILFunctionGraph:
3316+
form += " lifted il"
3317+
if self.il_form == FunctionGraphType.LowLevelILSSAFormFunctionGraph:
3318+
form += " ssa form"
33143319
if self.source_function is not None and self.source_function.arch is not None:
3315-
return f"<{self.__class__.__name__}: {self.source_function.arch.name}@{self.source_function.start:#x}>"
3320+
return f"<{self.__class__.__name__}{form}: {self.source_function.arch.name}@{self.source_function.start:#x}>"
33163321
elif self.source_function is not None:
3317-
return f"<{self.__class__.__name__}: {self.source_function.start:#x}>"
3322+
return f"<{self.__class__.__name__}{form}: {self.source_function.start:#x}>"
33183323
else:
3319-
return f"<{self.__class__.__name__}: anonymous>"
3324+
return f"<{self.__class__.__name__}{form}: anonymous>"
33203325

33213326
def __len__(self):
33223327
return int(core.BNGetLowLevelILInstructionCount(self.handle))

python/mediumlevelil.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3283,10 +3283,21 @@ def __del__(self):
32833283

32843284
def __repr__(self):
32853285
arch = self.source_function.arch
3286+
form = ""
3287+
if self.il_form in [
3288+
FunctionGraphType.MappedMediumLevelILFunctionGraph,
3289+
FunctionGraphType.MappedMediumLevelILSSAFormFunctionGraph,
3290+
]:
3291+
form += " mapped mlil"
3292+
if self.il_form in [
3293+
FunctionGraphType.MediumLevelILSSAFormFunctionGraph,
3294+
FunctionGraphType.MappedMediumLevelILSSAFormFunctionGraph,
3295+
]:
3296+
form += " ssa form"
32863297
if arch:
3287-
return f"<MediumLevelILFunction: {arch.name}@{self.source_function.start:#x}>"
3298+
return f"<MediumLevelILFunction{form}: {arch.name}@{self.source_function.start:#x}>"
32883299
else:
3289-
return f"<MediumLevelILFunction: {self.source_function.start:#x}>"
3300+
return f"<MediumLevelILFunction{form}: {self.source_function.start:#x}>"
32903301

32913302
def __len__(self):
32923303
return int(core.BNGetMediumLevelILInstructionCount(self.handle))

0 commit comments

Comments
 (0)