Skip to content

Commit bcd321b

Browse files
authored
FI-datatype: Add handling of assert statements in FI (#2169)
* FI-datatype: Add handling of assert statements in FI Signed-off-by: Arthur Chan <[email protected]> * Fix formatting Signed-off-by: Arthur Chan <[email protected]> --------- Signed-off-by: Arthur Chan <[email protected]>
1 parent 8dc96de commit bcd321b

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/fuzz_introspector/datatypes/function_profile.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,22 @@ def __init__(self, elem: Dict[Any, Any]) -> None:
9191
except Exception:
9292
self.callsite = dict()
9393

94+
# Set assert statement handling if exist
95+
assert_stmts = elem.get('assertStmts', [])
96+
self.assert_list = []
97+
for stmt in assert_stmts:
98+
condition = stmt.get('condition', '')
99+
location = stmt.get('pos', {})
100+
if location and condition:
101+
self.assert_list.append({
102+
'condition':
103+
condition,
104+
'start_line':
105+
location.get('line_start', -1),
106+
'end_line':
107+
location.get('line_end', -1),
108+
})
109+
94110
# These are set later.
95111
self.hitcount: int = 0
96112
self.reached_by_fuzzers: List[str] = []
@@ -116,7 +132,8 @@ def to_dict(self, coverage: float = 0.0) -> Dict[str, Any]:
116132
'source_line_begin': self.function_linenumber,
117133
'source_line_end': self.function_line_number_end,
118134
'debug_summary': '', # No debug summary from new frontend yet
119-
'total_cyclomatic_complexity': self.total_cyclomatic_complexity
135+
'total_cyclomatic_complexity': self.total_cyclomatic_complexity,
136+
'assert_stmts': self.assert_list,
120137
}
121138

122139
@property

0 commit comments

Comments
 (0)