Skip to content

Commit

Permalink
[feat] Enable coverOnTheFly after approaching memory cup
Browse files Browse the repository at this point in the history
  • Loading branch information
misonijnik committed Nov 2, 2023
1 parent 7c002e7 commit ead7431
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/Core/Executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,13 @@ cl::opt<bool> EmitAllErrors(
cl::opt<bool> CoverOnTheFly(
"cover-on-the-fly", cl::init(false),
cl::desc("Generate tests cases for each new covered block or branch "
"(default=false, i.e. one per (error,instruction) pair)"),
"(default=false)"),
cl::cat(TestGenCat));

cl::opt<bool> MemoryTriggerCoverOnTheFly(
"mem-trigger-cof", cl::init(false),
cl::desc("Start on the fly tests generation after approaching memory cup"
"(default=false)"),
cl::cat(TestGenCat));

cl::opt<std::string> DelayCoverOnTheFly(
Expand Down Expand Up @@ -4082,6 +4088,14 @@ bool Executor::checkMemoryUsage() {
const auto mallocUsage = util::GetTotalMallocUsage() >> 20U;
const auto mmapUsage = memory->getUsedDeterministicSize() >> 20U;
const auto totalUsage = mallocUsage + mmapUsage;

if (MemoryTriggerCoverOnTheFly && 3 * totalUsage <= 2 * MaxMemory) {
klee_warning_once(0,
"enabling cover-on-the-fly (close to memory cap: %luMB)",
totalUsage);
coverOnTheFly = true;
}

atMemoryLimit = totalUsage > MaxMemory; // inhibit forking
if (!atMemoryLimit)
return true;
Expand Down

0 comments on commit ead7431

Please sign in to comment.