@@ -2588,12 +2588,13 @@ def gen_targets(self, anonymous: bool = False):
2588
2588
(self .output_path / "result-report.json" ).as_posix (), "w" ))
2589
2589
2590
2590
def compile_driver_worker (self , bgen_args ):
2591
- p = Popen (
2592
- bgen_args ["compiler_cmd" ],
2593
- stdout = PIPE ,
2594
- stderr = PIPE ,
2595
- universal_newlines = True ,
2596
- )
2591
+ with open (bgen_args ["error_path" ], "w" ) as error_log_file :
2592
+ p = Popen (
2593
+ bgen_args ["compiler_cmd" ],
2594
+ stdout = PIPE ,
2595
+ stderr = error_log_file ,
2596
+ universal_newlines = True ,
2597
+ )
2597
2598
2598
2599
target_file = open (bgen_args ["source_path" ], "a" )
2599
2600
@@ -2613,7 +2614,7 @@ def compile_driver_worker(self, bgen_args):
2613
2614
output , errors = p .communicate ()
2614
2615
if p .returncode :
2615
2616
print (" " .join (bgen_args ["compiler_cmd" ]))
2616
- print ("\n -- [Futag] ERROR on target " , bgen_args ["target_name" ], ": \n " , errors )
2617
+ print ("\n -- [Futag] ERROR on target " , bgen_args ["target_name" ], "\n " )
2617
2618
for c in compiler_cmd :
2618
2619
if c .find (self .tmp_output_path .as_posix ()) >= 0 :
2619
2620
new_compiler_cmd .append (c .replace (self .tmp_output_path .as_posix (), self .failed_path .as_posix ()))
@@ -2630,8 +2631,15 @@ def compile_driver_worker(self, bgen_args):
2630
2631
2631
2632
target_file .write (" " .join (new_compiler_cmd ))
2632
2633
target_file .write ("\n */\n " )
2634
+
2635
+ error_log_file = open (bgen_args ["error_path" ], "r" )
2636
+ if error_log_file :
2637
+ target_file .write ("\n // Error log:" )
2638
+ target_file .write ("\n /* \n " )
2639
+ target_file .write ("" .join (error_log_file .readlines ()))
2640
+ error_log_file .close ()
2641
+ target_file .write ("\n */\n " )
2633
2642
target_file .close ()
2634
-
2635
2643
2636
2644
def compile_targets (self , workers : int = 4 , keep_failed : bool = False , extra_include : str = "" , extra_dynamiclink : str = "" , flags : str = FUZZ_COMPILER_FLAGS , coverage : bool = False ):
2637
2645
"""
@@ -2706,8 +2714,6 @@ def compile_targets(self, workers: int = 4, keep_failed: bool = False, extra_inc
2706
2714
if pathlib .Path (iter [2 :]).exists ():
2707
2715
include_subdir .append ("-I" + pathlib .Path (iter [2 :]).absolute ().as_posix () + "/" )
2708
2716
os .chdir (current_location )
2709
-
2710
-
2711
2717
2712
2718
compiler_path = ""
2713
2719
if self .target_type == LIBFUZZER :
@@ -2766,17 +2772,19 @@ def compile_targets(self, workers: int = 4, keep_failed: bool = False, extra_inc
2766
2772
for dir in fuzz_driver_dirs :
2767
2773
for target_src in [t for t in dir .glob ("*" + self .target_extension ) if t .is_file ()]:
2768
2774
target_path = dir .as_posix () + "/" + target_src .stem + ".out"
2775
+ error_path = dir .as_posix () + "/" + target_src .stem + ".err"
2769
2776
generated_targets += 1
2770
2777
if self .target_type == LIBFUZZER :
2771
2778
compiler_cmd = [compiler_path .as_posix ()] + compiler_flags_libFuzzer .split (" " ) + current_include + [extra_include ] + [
2772
- target_src .as_posix ()] + ["-o" ] + [target_path ] + static_lib + [ extra_dynamiclink ]
2779
+ target_src .as_posix ()] + ["-o" ] + [target_path ] + static_lib + extra_dynamiclink . split ( " " )
2773
2780
else :
2774
2781
compiler_cmd = [compiler_path .as_posix ()] + compiler_flags_aflplusplus .split (" " ) + current_include + [extra_include ] + [
2775
- target_src .as_posix ()] + ["-o" ] + [target_path ] + static_lib + [ extra_dynamiclink ]
2782
+ target_src .as_posix ()] + ["-o" ] + [target_path ] + static_lib + extra_dynamiclink . split ( " " )
2776
2783
2777
2784
compile_cmd_list .append ({
2778
2785
"compiler_cmd" : compiler_cmd ,
2779
2786
"target_name" : target_src .stem ,
2787
+ "error_path" : error_path ,
2780
2788
"source_path" : target_src .as_posix (),
2781
2789
"binary_path" : target_path ,
2782
2790
"compiler_info" : compiler_info ,
0 commit comments