Skip to content

Commit 7bdaa49

Browse files
committed
Fix FI backend for Rust
Signed-off-by: Arthur Chan <[email protected]>
1 parent 9dbefee commit 7bdaa49

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/fuzz_introspector/data_loader.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def read_fuzzer_data_file_to_profile(
4646
data_dict_yaml = utils.data_file_read_yaml(cfg_file + ".yaml")
4747
logger.info(f"Finished loading {cfg_file}")
4848

49-
# Must be dictionary
49+
# Must be dictionary
5050
if data_dict_yaml is None or not isinstance(data_dict_yaml, dict):
5151
return None
5252

@@ -115,6 +115,7 @@ def load_all_profiles(
115115
profiles = []
116116
data_files = utils.get_all_files_in_tree_with_regex(
117117
target_folder, "fuzzerLogFile.*\.data$")
118+
print(data_files)
118119
logger.info(f" - found {len(data_files)} profiles to load")
119120
if parallelise:
120121
manager = multiprocessing.Manager()

src/fuzz_introspector/datatypes/fuzzer_profile.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(self,
5252
self.all_class_constructors: Dict[
5353
str, function_profile.FunctionProfile] = dict()
5454
self.branch_blockers: List[Any] = []
55-
55+
print("~~~~~~~~~~~~~~~~%s"%target_lang)
5656
self._target_lang = target_lang
5757
self.introspector_data_file = cfg_file
5858

@@ -100,6 +100,12 @@ def entrypoint_function(self):
100100
cname = self.fuzzer_source_file
101101
mname = self.entrypoint_method
102102
return f"[{cname}].{mname}"
103+
elif self.target_lang == "rust":
104+
# For rust, there is no entry function
105+
# Instead, it is wrapped by the fuzz_target
106+
# macro and we manually considered it as
107+
# function in the frontend.
108+
return "fuzz_target"
103109
else:
104110
return None
105111

@@ -131,7 +137,7 @@ def max_func_call_depth(self):
131137

132138
def has_entry_point(self) -> bool:
133139
"""Returns whether an entrypoint is identified"""
134-
if self.target_lang == "c-cpp":
140+
if self.target_lang == "c-cpp" or self.target_lang == "rust":
135141
return self.entrypoint_function in self.all_class_functions
136142

137143
elif self.target_lang == "python":
@@ -440,8 +446,8 @@ def _set_all_reached_functions(self) -> None:
440446
the fuzzer. This is based on identifying all functions reached by the
441447
fuzzer entrypoint function, e.g. LLVMFuzzerTestOneInput in C/C++.
442448
"""
443-
# Find C/CPP entry point
444-
if self._target_lang == "c-cpp":
449+
# Find C/CPP/Rust entry point
450+
if self._target_lang == "c-cpp" or self.target_lang == "rust":
445451
if self.entrypoint_function in self.all_class_functions:
446452
self.functions_reached_by_fuzzer = (self.all_class_functions[
447453
self.entrypoint_function].functions_reached)
@@ -485,7 +491,7 @@ def _set_all_unreached_functions(self) -> None:
485491
def _load_coverage(self, target_folder: str) -> None:
486492
"""Load coverage data for this profile"""
487493
logger.info(f"Loading coverage of type {self.target_lang}")
488-
if self.target_lang == "c-cpp":
494+
if self.target_lang == "c-cpp" or self.target_lang == "rust":
489495
if os.getenv('FI_KERNEL_COV', ''):
490496
self.coverage = code_coverage.load_kernel_cov(
491497
os.getenv('FI_KERNEL_COV'))

src/fuzz_introspector/html_helpers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ def html_get_table_of_contents(
204204
cov_index = "index.html"
205205
elif proj_profile.target_lang == "jvm":
206206
cov_index = "index.html"
207+
elif proj_profile.target_lang == "rust":
208+
cov_index = "report.html"
207209

208210
html_toc_string = ""
209211
html_toc_string += f"""<div class="left-sidebar">\

0 commit comments

Comments
 (0)