Skip to content

Commit 2a7086a

Browse files
frontends: c: enable module only analysis (#1912)
* frontends: c: enable module only analysis Signed-off-by: David Korczynski <[email protected]> * nit Signed-off-by: David Korczynski <[email protected]> --------- Signed-off-by: David Korczynski <[email protected]>
1 parent 5216c4f commit 2a7086a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/fuzz_introspector/frontends/oss_fuzz.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def parse_args():
5252
return parser.parse_args()
5353

5454

55-
def process_c_project(target_dir, entrypoint, out):
55+
def process_c_project(target_dir, entrypoint, out, module_only=False):
5656
"""Process a project in C language"""
5757
source_files = {}
5858
source_files['c'] = frontend_c.capture_source_files_in_tree(
@@ -65,12 +65,19 @@ def process_c_project(target_dir, entrypoint, out):
6565
logger.info('Creating base project.')
6666
project = frontend_c.Project(source_codes)
6767

68+
if module_only:
69+
idx = 1
70+
target = os.path.join(out, 'report.yaml')
71+
project.dump_module_logic(target, '', target_dir)
72+
6873
if entrypoint != 'LLVMFuzzerTestOneInput':
6974
calltree_source = project.get_source_code_with_target(entrypoint)
7075
if calltree_source:
7176
calltree = project.extract_calltree(calltree_source, entrypoint)
7277
with open(os.path.join(out, 'targetCalltree.txt'), 'w') as f:
78+
f.write("Call tree\n")
7379
f.write(calltree)
80+
f.write("====================================")
7481
else:
7582
for idx, harness in enumerate(
7683
project.get_source_codes_with_harnesses()):
@@ -172,9 +179,9 @@ def process_jvm_project(target_dir, entrypoint, out):
172179
f.write(f'Call tree\n{calltree}')
173180

174181

175-
def analyse_folder(language, directory, entrypoint, out=''):
182+
def analyse_folder(language, directory, entrypoint, out='', module_only=False):
176183
if language == 'c':
177-
process_c_project(directory, entrypoint, out)
184+
process_c_project(directory, entrypoint, out, module_only)
178185
if language.lower() in ['cpp', 'c++']:
179186
process_cpp_project(directory, entrypoint, out)
180187
if language == 'go':

0 commit comments

Comments
 (0)