@@ -22,6 +22,8 @@ Author: Daniel Poetzl
22
22
#include < util/symbol_table.h>
23
23
24
24
#include " goto_harness_generator_factory.h"
25
+ #include " recursive_initialization.h"
26
+
25
27
26
28
void memory_snapshot_harness_generatort::handle_option (
27
29
const std::string &option,
@@ -54,6 +56,10 @@ void memory_snapshot_harness_generatort::handle_option(
54
56
location_number = optionalt<unsigned >(safe_string2unsigned (start.back ()));
55
57
}
56
58
}
59
+ else if (option == " havoc-variables" )
60
+ {
61
+ variables_to_havoc.insert (values.begin (), values.end ());
62
+ }
57
63
else
58
64
{
59
65
throw invalid_command_line_argument_exceptiont (
@@ -157,18 +163,29 @@ void memory_snapshot_harness_generatort::add_init_section(
157
163
158
164
void memory_snapshot_harness_generatort::add_assignments_to_globals (
159
165
const symbol_tablet &snapshot,
166
+ goto_modelt &goto_model,
160
167
code_blockt &code) const
161
168
{
169
+ recursive_initialization_configt recursive_initialization_config;
170
+ auto recursive_initialization = util_make_unique<recursive_initializationt>(
171
+ recursive_initialization_config, goto_model);
172
+
162
173
for (const auto &pair : snapshot)
163
174
{
164
175
const symbolt &symbol = pair.second ;
165
176
166
177
if (!symbol.is_static_lifetime )
167
178
continue ;
168
179
169
- code_assignt code_assign (symbol.symbol_expr (), symbol.value );
170
-
171
- code.add (code_assign);
180
+ if (variables_to_havoc.count (symbol.base_name ) == 0 )
181
+ {
182
+ code_assignt code_assign (symbol.symbol_expr (), symbol.value );
183
+ code.add (code_assign);
184
+ }
185
+ else
186
+ {
187
+ recursive_initialization->initialize (symbol.symbol_expr (), 0 , {}, code);
188
+ }
172
189
}
173
190
}
174
191
@@ -282,7 +299,7 @@ void memory_snapshot_harness_generatort::generate(
282
299
283
300
code_blockt harness_function_body;
284
301
285
- add_assignments_to_globals (snapshot, harness_function_body);
302
+ add_assignments_to_globals (snapshot, goto_model, harness_function_body);
286
303
287
304
add_call_with_nondet_arguments (
288
305
*called_function_symbol, harness_function_body);
0 commit comments