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