18#include "llvm/Support/CommandLine.h"
24llvm::cl::OptionCategory
25 SearchCat(
"Search options",
"These options control the search heuristic.");
27cl::list<Searcher::CoreSearchType> CoreSearch(
29 cl::desc(
"Specify the search heuristic (default=random-path interleaved "
32 clEnumValN(Searcher::DFS,
"dfs",
"use Depth First Search (DFS)"),
33 clEnumValN(Searcher::BFS,
"bfs",
34 "use Breadth First Search (BFS), where scheduling decisions "
35 "are taken at the level of (2-way) forks"),
36 clEnumValN(Searcher::RandomState,
"random-state",
37 "randomly select a state to explore"),
38 clEnumValN(Searcher::RandomPath,
"random-path",
39 "use Random Path Selection (see OSDI'08 paper)"),
40 clEnumValN(Searcher::NURS_CovNew,
"nurs:covnew",
41 "use Non Uniform Random Search (NURS) with Coverage-New"),
42 clEnumValN(Searcher::NURS_MD2U,
"nurs:md2u",
43 "use NURS with Min-Dist-to-Uncovered"),
44 clEnumValN(Searcher::NURS_Depth,
"nurs:depth",
"use NURS with depth"),
45 clEnumValN(Searcher::NURS_RP,
"nurs:rp",
"use NURS with 1/2^depth"),
46 clEnumValN(Searcher::NURS_ICnt,
"nurs:icnt",
47 "use NURS with Instr-Count"),
48 clEnumValN(Searcher::NURS_CPICnt,
"nurs:cpicnt",
49 "use NURS with CallPath-Instr-Count"),
50 clEnumValN(Searcher::NURS_QC,
"nurs:qc",
"use NURS with Query-Cost")),
53cl::opt<bool> UseIterativeDeepeningTimeSearch(
54 "use-iterative-deepening-time-search",
56 "Use iterative deepening time search (experimental) (default=false)"),
60cl::opt<bool> UseBatchingSearch(
61 "use-batching-search",
62 cl::desc(
"Use batching searcher (keep running selected state for N "
63 "instructions/time, see --batch-instructions and --batch-time) "
68cl::opt<unsigned> BatchInstructions(
70 cl::desc(
"Number of instructions to batch when using "
71 "--use-batching-search. Set to 0 to disable (default=10000)"),
75cl::opt<std::string> BatchTime(
77 cl::desc(
"Amount of time to batch when using "
78 "--use-batching-search. Set to 0s to disable (default=5s)"),
86 if (CoreSearch.empty()) {
88 CoreSearch.push_back(Searcher::NURS_CovNew);
89 klee_warning(
"--use-merge enabled. Using NURS_CovNew as default searcher.");
91 CoreSearch.push_back(Searcher::RandomPath);
92 CoreSearch.push_back(Searcher::NURS_CovNew);
98 return (std::find(CoreSearch.begin(), CoreSearch.end(), Searcher::NURS_MD2U) != CoreSearch.end() ||
99 std::find(CoreSearch.begin(), CoreSearch.end(), Searcher::NURS_CovNew) != CoreSearch.end() ||
100 std::find(CoreSearch.begin(), CoreSearch.end(), Searcher::NURS_ICnt) != CoreSearch.end() ||
101 std::find(CoreSearch.begin(), CoreSearch.end(), Searcher::NURS_CPICnt) != CoreSearch.end() ||
102 std::find(CoreSearch.begin(), CoreSearch.end(), Searcher::NURS_QC) != CoreSearch.end());
109 case Searcher::DFS: searcher =
new DFSSearcher();
break;
110 case Searcher::BFS: searcher =
new BFSSearcher();
break;
111 case Searcher::RandomState: searcher =
new RandomSearcher(rng);
break;
112 case Searcher::RandomPath: searcher =
new RandomPathSearcher(processTree, rng);
break;
113 case Searcher::NURS_CovNew: searcher =
new WeightedRandomSearcher(WeightedRandomSearcher::CoveringNew, rng);
break;
114 case Searcher::NURS_MD2U: searcher =
new WeightedRandomSearcher(WeightedRandomSearcher::MinDistToUncovered, rng);
break;
115 case Searcher::NURS_Depth: searcher =
new WeightedRandomSearcher(WeightedRandomSearcher::Depth, rng);
break;
117 case Searcher::NURS_ICnt: searcher =
new WeightedRandomSearcher(WeightedRandomSearcher::InstCount, rng);
break;
118 case Searcher::NURS_CPICnt: searcher =
new WeightedRandomSearcher(WeightedRandomSearcher::CPInstCount, rng);
break;
119 case Searcher::NURS_QC: searcher =
new WeightedRandomSearcher(WeightedRandomSearcher::QueryCost, rng);
break;
129 if (CoreSearch.size() > 1) {
130 std::vector<Searcher *> s;
131 s.push_back(searcher);
133 for (
unsigned i = 1; i < CoreSearch.size(); i++)
139 if (UseBatchingSearch) {
144 if (UseIterativeDeepeningTimeSearch) {
157 os <<
"BEGIN searcher description\n";
159 os <<
"END searcher description\n";
Implementation of the region based merging.
Searcher * getNewSearcher(Searcher::CoreSearchType type, RNG &rng, PTree &processTree)
const InterpreterHandler & getHandler()
std::unique_ptr< PTree > processTree
RNG theRNG
The random number generator.
void setMergingSearcher(MergingSearcher *ms)
virtual llvm::raw_ostream & getInfoStream() const =0
RandomSearcher picks a state randomly.
virtual void printName(llvm::raw_ostream &os)=0
Prints name of searcher as a klee_message().
void klee_warning(char *name)
llvm::cl::opt< bool > UseMerge
bool userSearcherRequiresMD2U()
Searcher * constructUserSearcher(Executor &executor)
void initializeSearchOptions()