@@ -24,6 +24,7 @@ Author: Daniel Poetzl
24
24
#include < linking/static_lifetime_init.h>
25
25
26
26
#include " goto_harness_generator_factory.h"
27
+ #include " recursive_initialization.h"
27
28
28
29
void memory_snapshot_harness_generatort::handle_option (
29
30
const std::string &option,
@@ -56,6 +57,10 @@ void memory_snapshot_harness_generatort::handle_option(
56
57
location_number = optionalt<unsigned >(safe_string2unsigned (start.back ()));
57
58
}
58
59
}
60
+ else if (option == " havoc-variables" )
61
+ {
62
+ variables_to_havoc.insert (values.begin (), values.end ());
63
+ }
59
64
else
60
65
{
61
66
throw invalid_command_line_argument_exceptiont (
@@ -196,17 +201,28 @@ void memory_snapshot_harness_generatort::add_init_section(
196
201
}
197
202
198
203
code_blockt memory_snapshot_harness_generatort::add_assignments_to_globals (
199
- const symbol_tablet &snapshot) const
204
+ const symbol_tablet &snapshot,
205
+ goto_modelt &goto_model) const
200
206
{
207
+ recursive_initialization_configt recursive_initialization_config;
208
+ auto recursive_initialization = util_make_unique<recursive_initializationt>(
209
+ recursive_initialization_config, goto_model);
210
+
201
211
code_blockt code;
202
212
for (const auto &pair : snapshot)
203
213
{
204
214
const symbolt &symbol = pair.second ;
205
-
206
215
if (!symbol.is_static_lifetime )
207
216
continue ;
208
217
209
- code.add (code_assignt{symbol.symbol_expr (), symbol.value });
218
+ if (variables_to_havoc.count (symbol.base_name ) == 0 )
219
+ {
220
+ code.add (code_assignt{symbol.symbol_expr (), symbol.value });
221
+ }
222
+ else
223
+ {
224
+ recursive_initialization->initialize (symbol.symbol_expr (), 0 , {}, code);
225
+ }
210
226
}
211
227
return code;
212
228
}
@@ -312,7 +328,8 @@ void memory_snapshot_harness_generatort::generate(
312
328
313
329
add_init_section (goto_model);
314
330
315
- code_blockt harness_function_body = add_assignments_to_globals (snapshot);
331
+ code_blockt harness_function_body =
332
+ add_assignments_to_globals (snapshot, goto_model);
316
333
317
334
add_call_with_nondet_arguments (
318
335
*called_function_symbol, harness_function_body);
0 commit comments