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