From 1ccc6b984b7e176d780d3327c489931f506e95e4 Mon Sep 17 00:00:00 2001 From: Ruibo Lu Date: Fri, 19 Jan 2024 12:51:05 +0800 Subject: [PATCH] fix call subfunctions computation 1. use CodeBlockReference to get call numbers in block 2. improve the ability of multi ISAs Signed-off-by: Ruibo Lu --- ghidriff/structural_graph_diff.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ghidriff/structural_graph_diff.py b/ghidriff/structural_graph_diff.py index 0fa02e5..8aa5b46 100644 --- a/ghidriff/structural_graph_diff.py +++ b/ghidriff/structural_graph_diff.py @@ -80,9 +80,11 @@ def _get_compare_key2(sym: 'ghidra.program.model.symbol.Symbol', func: 'ghidra.p num_edges_of_blocks += block.getNumDestinations(monitor) num_basic_blocks += 1 - code_units = func.getProgram().getListing().getCodeUnits(block, True) - for code in code_units: - if code.getMnemonicString() == 'CALL': + refs_ = block.getDestinations(monitor) + # Use hasNext because 'ghidra.program.model.block.SimpleDestReferenceIterator' object is not iterable + while refs_.hasNext(): + ref_ = refs_.next() + if ref_.getFlowType().isCall(): num_call_subfunctions += 1 # ignore Ghidra generated function names