Skip to content

Commit 58fca32

Browse files
author
thientc
committed
fix coverage
1 parent 0649b00 commit 58fca32

File tree

5 files changed

+25
-16
lines changed

5 files changed

+25
-16
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ FUTAG запускает статический анализ во время с
4646

4747
### 2.2. Установка:
4848

49-
- Скачать последний релиз [futag-llvm.latest.tar.gz](https://github.com/ispras/Futag/releases/tag/latest) и разархивировать
49+
- Скачать последний релиз [futag-llvm.1.2.2.tar.xz](https://github.com/ispras/Futag/releases/tag/1.2.2) и разархивировать
5050

5151
- Установить зависимости:
5252
```bash
Binary file not shown.
215 Bytes
Binary file not shown.

src/python/futag-package/src/futag/generator.py

+20-12
Original file line numberDiff line numberDiff line change
@@ -2588,12 +2588,13 @@ def gen_targets(self, anonymous: bool = False):
25882588
(self.output_path / "result-report.json").as_posix(), "w"))
25892589

25902590
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+
)
25972598

25982599
target_file = open(bgen_args["source_path"], "a")
25992600

@@ -2613,7 +2614,7 @@ def compile_driver_worker(self, bgen_args):
26132614
output, errors = p.communicate()
26142615
if p.returncode:
26152616
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")
26172618
for c in compiler_cmd:
26182619
if c.find(self.tmp_output_path.as_posix()) >= 0:
26192620
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):
26302631

26312632
target_file.write(" ".join(new_compiler_cmd))
26322633
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")
26332642
target_file.close()
2634-
26352643

26362644
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):
26372645
"""
@@ -2706,8 +2714,6 @@ def compile_targets(self, workers: int = 4, keep_failed: bool = False, extra_inc
27062714
if pathlib.Path(iter[2:]).exists():
27072715
include_subdir.append("-I" + pathlib.Path(iter[2:]).absolute().as_posix() + "/")
27082716
os.chdir(current_location)
2709-
2710-
27112717

27122718
compiler_path = ""
27132719
if self.target_type == LIBFUZZER:
@@ -2766,17 +2772,19 @@ def compile_targets(self, workers: int = 4, keep_failed: bool = False, extra_inc
27662772
for dir in fuzz_driver_dirs:
27672773
for target_src in [t for t in dir.glob("*"+self.target_extension) if t.is_file()]:
27682774
target_path = dir.as_posix() + "/" + target_src.stem + ".out"
2775+
error_path = dir.as_posix() + "/" + target_src.stem + ".err"
27692776
generated_targets += 1
27702777
if self.target_type == LIBFUZZER:
27712778
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(" ")
27732780
else:
27742781
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(" ")
27762783

27772784
compile_cmd_list.append({
27782785
"compiler_cmd" : compiler_cmd,
27792786
"target_name": target_src.stem,
2787+
"error_path": error_path,
27802788
"source_path": target_src.as_posix(),
27812789
"binary_path": target_path,
27822790
"compiler_info": compiler_info,

src/python/futag-package/src/futag/sysmsg.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
BUILD_EX_PARAMS = ""
1919
INSTALL_PATH = ".futag-install"
2020
ANALYSIS_PATH = ".futag-analysis"
21-
COMPILER_FLAGS = "-fsanitize=address -g -O0"
22-
COMPILER_COVERAGE_FLAGS = "-fsanitize=address -g -O0 -fprofile-instr-generate -fcoverage-mapping"
23-
FUZZ_COMPILER_FLAGS = "-fsanitize=address,fuzzer -g -O0"
21+
DEBUG_FLAGS = "-g -O0 "
22+
COMPILER_FLAGS = "-fsanitize=address "
23+
COMPILER_COVERAGE_FLAGS = "-fprofile-instr-generate -fcoverage-mapping "
24+
FUZZ_COMPILER_FLAGS = "-fsanitize=address,fuzzer "
2425
FUZZ_DRIVER_PATH = "futag-fuzz-drivers"
2526
ANALYSIS_FILE_PATH=".futag-analysis/futag-analysis-result.json"
2627
CMAKE_PATH_ERROR="Please specify other directory for building with cmake."

0 commit comments

Comments
 (0)