Skip to content

Commit 1fcd29e

Browse files
frontends: python: add some more data collection (#301)
frontends: python: add some more data collection to make the report look proper
1 parent 50e1154 commit 1fcd29e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

frontends/python/main.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,16 @@ def translate_cg(cg_extended, fuzzer_filename):
162162
d['constantsTouched'] = []
163163
d['argNames'] = elem_dict['meta']['argNames'] if 'argNames' in elem_dict['meta'] else []
164164
d['argTypes'] = elem_dict['meta']['argTypes'] if 'argTypes' in elem_dict['meta'] else []
165-
d['BBCount'] = 0
166-
d['ICount'] = 0
167-
d['EdgeCount'] = 0
168-
d['CyclomaticComplexity'] = 0
165+
d['ICount'] = elem_dict['meta']['exprCount'] if 'exprCount' in elem_dict['meta'] else 0
166+
d['IfCount'] = elem_dict['meta']['ifCount'] if 'ifCount' in elem_dict['meta'] else 0
169167
d['functionsReached'] = elem_dict['all_reachables']
170168
d['functionUses'] = elem_dict['all_uses']
171169
d['BranchProfiles'] = []
170+
171+
# Set the following based on ifCount. This should be refined to be more accurrate.
172+
d['BBCount'] = d['IfCount']
173+
d['EdgeCount'] = int((d['IfCount']+1) * 1.4)
174+
d['CyclomaticComplexity'] = d['EdgeCount'] - d['BBCount'] + 2
172175
new_dict['All functions']['Elements'].append(d)
173176
return new_dict
174177

0 commit comments

Comments
 (0)