From 503ffe026b1e8ebfc8228383cef9eb8aeed43dad Mon Sep 17 00:00:00 2001 From: Vladislav Kalugin Date: Mon, 18 Sep 2023 19:42:22 +0300 Subject: [PATCH] Don't create files outside of project and add skipping flags --- server/src/KleeGenerator.cpp | 17 ++++++++++++++++- server/src/Paths.cpp | 2 +- server/src/building/ProjectBuildDatabse.cpp | 14 ++++++++++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/server/src/KleeGenerator.cpp b/server/src/KleeGenerator.cpp index 918d93a34..d4e833004 100644 --- a/server/src/KleeGenerator.cpp +++ b/server/src/KleeGenerator.cpp @@ -97,9 +97,21 @@ static std::string getUTBotClangCompilerPath(fs::path clientCompilerPath) { } } -static const std::unordered_set UNSUPPORTED_FLAGS_AND_OPTIONS_KLEE = { +static const std::unordered_set UNSUPPORTED_FLAGS_AND_OPTIONS_KLEE = { "--coverage", "-lgcov", + "-ftest-coverage", + "-fprofile-abs-path", + "-fprofile-dir", + "-fprofile-generate", + "-fprofile-info-section", + "-fprofile-note", + "-fprofile-prefix-path", + "-fprofile-prefix-map", + "-fprofile-update", + "-fprofile-filter-files", + "-fprofile-exclude-files", + "-fprofile-reproducible", "-fbranch-target-load-optimize", "-fcx-fortran-rules", "-fipa-cp-clone", @@ -114,6 +126,9 @@ static const std::unordered_set UNSUPPORTED_FLAGS_AND_OPTIONS_KLEE "-fno-tree-sinkclang-10", "-fpredictive-commoning", "-fprofile-dir", + "-fprofile-arcs", + "-p", + "-pg", "-freschedule-modulo-scheduled-loops", "-fsched2-use-superblocks", "-fsel-sched-reschedule-pipelined", diff --git a/server/src/Paths.cpp b/server/src/Paths.cpp index d31ce27a1..def0fd92c 100644 --- a/server/src/Paths.cpp +++ b/server/src/Paths.cpp @@ -114,7 +114,7 @@ namespace Paths { } fs::path getCCJsonFileFullPath(const std::string &filename, const fs::path &directory) { - fs::path path1 = fs::path(filename); + fs::path path1(filename); fs::path path2 = fs::weakly_canonical(directory / path1); return fs::exists(path2) ? path2 : path1; } diff --git a/server/src/building/ProjectBuildDatabse.cpp b/server/src/building/ProjectBuildDatabse.cpp index 5c4266c79..c4c9fc361 100644 --- a/server/src/building/ProjectBuildDatabse.cpp +++ b/server/src/building/ProjectBuildDatabse.cpp @@ -51,6 +51,7 @@ ProjectBuildDatabase::ProjectBuildDatabase(fs::path _buildCommandsJsonPath, fillTargetInfoParents(); createClangCompileCommandsJson(); } catch (const std::exception &e) { + LOG_S(ERROR) << e.what(); return; } } @@ -90,8 +91,17 @@ void ProjectBuildDatabase::initObjects(const nlohmann::json &compileCommandsJson continue; } - fs::path kleeFilePathTemplate = Paths::createNewDirForFile(sourceFile, projectContext.projectPath, - Paths::getUTBotFiles(projectContext)); + fs::path kleeFilePathTemplate; + if (Paths::isSubPathOf(projectContext.projectPath, sourceFile)) { + kleeFilePathTemplate = Paths::createNewDirForFile(sourceFile, projectContext.projectPath, + Paths::getUTBotFiles(projectContext)); + } else { + LOG_S(WARNING) + << "Source file " << sourceFile << " outside of project root " << projectContext.projectPath; + kleeFilePathTemplate = Paths::createNewDirForFile(sourceFile, fs::path("/"), + Paths::getUTBotFiles(projectContext) / "outside_of_project"); + } + fs::path kleeFile = Paths::addSuffix(kleeFilePathTemplate, "_klee"); objectInfo->kleeFilesInfo = std::make_shared(kleeFile);