-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrv_main.h
executable file
·155 lines (125 loc) · 5.49 KB
/
rv_main.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#ifndef RV_MAIN_H
#define RV_MAIN_H
#include <set>
#include <vector>
#include <memory>
#include <rv_funcpair.h>
#include <rv_commands.h>
#include "rv_dbg.h"
class RVFuncPair;
class RVParse;
class RVDirectives;
class RVFuncCallCountAnalysis;
/*
RVMain
the main class of the RVT (Regression Verification Tool).
This calls is responsible for the whole verification cycle
of the RVT; parsing of both sides, loop-to-recursion conversion,
call graph, arguments and globals types collection,
AUF and FUF processing, semantic checks and output generation.
*/
class RVMain
{
private:
RVBoolStatus abandone_output(int f0_id);
protected:
static const std::string UNINITED;
std::string base_dir;
std::string semchk_dir;
std::string base_name;
std::string direct_fname;
std::string main_name;
std::string rel_fname;
std::string fuf_fname;
enum {UNSET, BY_USER, AUTOSET, SET_NO} m_fufSet;
bool frama;
int side0_unroll_threshold, side1_unroll_threshold;
int side0_unwind, side1_unwind;
bool seperate_basecase_proof;
int basecase_unwind_threshold;
int delta_dk;
int semchk_timeout;
//bool use_auf; /* = use automatically recognized uninterpreted functions. */
bool use_sem; /* = use semantic check (run decision procedure) to detect UFs */
int dk; /* The maximum value of ubs_depth_k during the excecution */
int ufs_look_back; /* how many calls back on the other side the UF searches
to find simmilar inputs to generate the same output. */
int max_records; /* max records in chanels and UF arrays */
int K; /* equivalence check bound (0 means infinite) */
bool loops_to_rec; /* replace loops by recursive functions. */
bool keep_all_code; /* keep unneeded funcs */
bool semchk_recursive;
bool arrays_to_uas;
RVDecisionParams decision_params;
bool test_ctool; /* Only parse side 0 and print it (debug only). */
int omega_total_bound; /* Omega bound on -dk value for whole program. */
bool unitrv; // Should we perform sem check with unitrv or cbmc.
int ubs_depth_k; /* how deep we unwind UBS arguments and return value. */
bool refined; //ofer: used in rv_decompose.cpp. Whether to keep equal but nonrecursive functions interpreted.
char completeness; // ofer: level of comppleteness, given by the user. Default is 0. in various locations we can try harder to prove equivalence on the expanse of run-time.
bool run_cil; // ofer: whether to call cil as preprocessing
bool mutual_term_check; // whether the current run checks mutual termination
bool m_bAbortIfUnknownCbmcErr; //whether abort execution if CBMC returns an uninterpretable result
bool m_c99; //whether to support C99 syntax.
SymbolVector read_only_globals[2];
std::string side0_fpath;
std::string side1_fpath;
int external_inputs; // ofer: saves the max. number of rv_getint/rv_getchar invocations. This is used to decide the size of the array that implements them in rv_inputs.c
std::ofstream* m_pLog;
RVDirectives* m_pDirectives;
std::vector<RVFuncCallCountAnalysis*> m_callChainCounter;
//Protected methods:
void init();
bool do_test_ctool(std::string& fname);
RVBoolStatus parse_side(const RVSide& side, std::string& side_fpath);
RVBoolStatus process_directives(void);
RVBoolStatus relate_globals_from_rel_file(void);
void relate_globals_of_same_name();
void sort_global_vectors(int side);
RVBoolStatus convert_loops_to_rec(bool is_basecase = false);
RVBoolStatus create_call_graph(int side, bool collect_arrays = false);
void filter_common_read_only_globals();
bool find_arrays();
bool do_last(const std::string& fname);
void preprocess(std::string& S0, std::string& S1);
std::string fullPath(const std::string& fname, const char *ext = NULL) const;
void prepareFuncCallCountAnalyses(const RVGlobLists& parser,
const std::vector<std::string>& mapf0,
const std::vector<std::string>& mapf1);
void prepareFuncCallCountForSide(const RVGlobLists& parser,
const RVSide& side,
const std::vector<std::string>& mapfside);
unsigned countMaxCallChainFromTo(const RVSide& side,
const std::string& from,
const std::string& callee);
public:
RVMain(void);
virtual ~RVMain() {}
RVIntStatus main(void);
RVBoolStatus eliminateGotoStatements();
void set_K(int k) {if (k > K) K = k;}
bool is_refined() const {return refined;}
char get_completeness() const { return completeness;}
bool is_checking_partial_equiv(void) const { return !mutual_term_check; }
RVDirectives& accessDirectives(void) const { return *m_pDirectives; }
///<summary>
///Counts how many <paramref name="callee" /> is called when execution
///starts from *<paramref name="pFromFunc" />. Recursive and non-recursive
///calls are counted separately. The maximum between the counts is returned
///<summary>
///<param name="side"> the side </param>
///<param name="pFromFunc">
///the execution start function;
///if NULL, RVMain::main_name is the starting function
///</param>
///<param name="callee">
///the name of the function whose calls are counted
///</param>
unsigned countMaxCallChain(const RVSide& side,
const std::string* pFromFunc,
const std::string& callee);
RVBoolStatus reprocessAfterGotoElimination();
void saveGotolessFiles( std::string side1_no_gotos, std::string side0_no_gotos );
RVBoolStatus reprocessGotolessFiles( std::string side1_no_gotos, std::string side0_no_gotos );
};
#endif /* RV_MAIN_H */