@@ -21,7 +21,8 @@ Author: Daniel Poetzl
21
21
22
22
#define MEMORY_SNAPSHOT_HARNESS_GENERATOR_OPTIONS \
23
23
" (memory-snapshot):" \
24
- " (initial-location):" // MEMORY_SNAPSHOT_HARNESS_GENERATOR_OPTIONS
24
+ " (initial-location):" \
25
+ " (havoc-variables):" // MEMORY_SNAPSHOT_HARNESS_GENERATOR_OPTIONS
25
26
26
27
// clang-format off
27
28
#define MEMORY_SNAPSHOT_HARNESS_GENERATOR_HELP \
@@ -48,30 +49,92 @@ class memory_snapshot_harness_generatort : public goto_harness_generatort
48
49
{
49
50
}
50
51
52
+ // / 1. load memory table from the snapshot
53
+ // / 2. add initial section to the initial location
54
+ // / 3. assign global variables their snapshot values (via the harness
55
+ // / function)
56
+ // / 4. insert call of the initial location (with nondet values) into the
57
+ // / harness function
58
+ // / 5. build symbol for the harness functions
59
+ // / 6. insert harness function into \p goto_model
60
+ // / \param goto_model: goto model to be modified
61
+ // / \param harness_function_name: name of the resulting harness function
51
62
void generate (goto_modelt &goto_model, const irep_idt &harness_function_name)
52
63
override ;
53
64
54
65
protected:
66
+ // / Collect the memory-snapshot specific cmdline options (one at a time)
67
+ // / \param option: memory-snapshot | initial-location | havoc-variables
68
+ // / \param values: list of arguments related to a given option
55
69
void handle_option (
56
70
const std::string &option,
57
71
const std::list<std::string> &values) override ;
58
72
73
+ // / Check that user options make sense:
74
+ // / On their own, e.g. location number cannot be specified without a function.
75
+ // / In relation to the input program, e.g. function name must be known via
76
+ // / the symbol table.
59
77
void validate_options () override ;
60
78
79
+ // / Parse the snapshot JSON file and initialise the symbol table
80
+ // / \param file: the snapshot JSON file
81
+ // / \param snapshot: the resulting symbol table build from the snapshot
61
82
void
62
83
get_memory_snapshot (const std::string &file, symbol_tablet &snapshot) const ;
63
84
85
+ // / Turn this:
86
+ // /
87
+ // / int foo() {
88
+ // / ..first_part..
89
+ // / i: //location_number=i
90
+ // / ..second_part..
91
+ // / }
92
+ // /
93
+ // / Into this:
94
+ // /
95
+ // / func_init_done;
96
+ // / __CPROVER_initialize() {
97
+ // / ...
98
+ // / func_init_done = false;
99
+ // / }
100
+ // / int foo() {
101
+ // / if (func_init_done) goto 1;
102
+ // / func_init_done = true;
103
+ // / goto i;
104
+ // / 1: ;
105
+ // / ..first_part..
106
+ // / i: //location_number=i
107
+ // / ..second_part..
108
+ // / }
109
+ // /
110
+ // / \param goto_model: Model where the modification takes place
64
111
void add_init_section (goto_modelt &goto_model) const ;
65
112
113
+ // / For each global symbol in the \p snapshot symbol table either:
114
+ // / 1) add \ref code_assignt assigning a value from the \p snapshot to the
115
+ // / symbol
116
+ // / 2) recursively initialise the symbol to a non-deterministic value of the
117
+ // / right type
118
+ // / \param snapshot: snapshot to load the symbols and their values from
119
+ // / \param goto_model: model to initialise the havoc-ing
120
+ // / \param code: block of code where the assignments are added
66
121
void add_assignments_to_globals (
67
122
const symbol_tablet &snapshot,
68
123
goto_modelt &goto_model,
69
124
code_blockt &code) const ;
70
125
126
+ // / Create as many non-deterministic arguments as there are arguments of the
127
+ // / \p called_function_symbol and add a function call with those arguments
128
+ // / \param called_function_symbol: the function to be called
129
+ // / \param code: the block of code where the function call is added
71
130
void add_call_with_nondet_arguments (
72
131
const symbolt &called_function_symbol,
73
132
code_blockt &code) const ;
74
133
134
+ // / Insert the \p function into the symbol table (and the goto functions map)
135
+ // / of the \p goto_model
136
+ // / \param goto_model: goto model where the insertion is to take place
137
+ // / \param function: symbol of the function to be inserted
75
138
void insert_function (goto_modelt &goto_model, const symbolt &function) const ;
76
139
77
140
std::string memory_snapshot;
0 commit comments