Skip to content

Commit

Permalink
Merge pull request #36 from quarkslab/fix_calls
Browse files Browse the repository at this point in the history
[python] Fix the Function.calls semantic
  • Loading branch information
RobinDavid authored Jan 3, 2025
2 parents baff1bc + ba67431 commit 1278e1f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions bindings/python/quokka/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,20 @@ def size(self) -> int:
@property
def calls(self) -> List[quokka.Chunk]:
"""Return the list of calls made by this chunk.
The semantic of a "call" is to jump or call to the **starting** chunk of a function.
Beware that this might lead to different results than the program call graph.
Note: The list is not deduplicated so a target may occur multiple time.
"""

calls = []
for inst_instance in self.program.references.resolve_calls(self, towards=False):
if isinstance(inst_instance, tuple):
calls.append(inst_instance[0])
else:
calls.append(inst_instance)
chunk = (
inst_instance[0] if isinstance(inst_instance, tuple) else inst_instance
)
# Check that the chunk is the **starting** chunk of a function
if chunk.start in self.program:
calls.append(chunk)

return calls

Expand Down

0 comments on commit 1278e1f

Please sign in to comment.