9 #ifndef CPROVER_GOTO_HARNESS_MEMORY_SNAPSHOT_HARNESS_GENERATOR_H
10 #define CPROVER_GOTO_HARNESS_MEMORY_SNAPSHOT_HARNESS_GENERATOR_H
103 std::pair<goto_programt::const_targett, size_t>
145 const size_t &candidate_distance,
146 const irep_idt &candidate_function_name,
166 const entry_goto_locationt &entry_goto_location,
176 const entry_source_locationt &entry_source_location,
183 const std::string &option,
184 const std::list<std::string> &values)
override;
198 const std::string &file,
241 const symbolt &snapshot_symbol,
264 const symbolt &called_function_symbol,
273 const symbolt &
function)
const;
280 template <
typename Adder>
283 if(expr.
id() == ID_symbol)
285 for(
const auto &operand : expr.
operands())
293 template <
typename Key>
305 template <
typename T>
307 const std::vector<std::pair<Key, T>> &input,
308 std::vector<std::pair<Key, T>> &output)
310 std::unordered_map<Key, T> searchable_input;
311 using valuet = std::pair<Key, T>;
313 for(
const auto &item : input)
315 searchable_input[item.first] = item.second;
317 auto associate_key_with_t =
318 [&searchable_input](
const Key &key) -> std::optional<valuet> {
319 if(searchable_input.count(key) != 0)
320 return valuet(key, searchable_input[key]);
324 auto push_to_output = [&output](
const valuet &value) {
325 output.push_back(value);
327 for(
const auto &item : input)
329 dfs(item, associate_key_with_t, push_to_output);
339 template <
typename Value,
typename Map,
typename Handler>
340 void dfs(Value &&node, Map &&key_to_t, Handler &&handle)
348 template <
typename Value,
typename Map,
typename Handler>
349 void dfs_inner(Value &&node, Map &&key_to_t, Handler &&handle)
351 const Key &key = node.first;
352 if(
seen.count(key) == 0)
356 for(
auto it = key_range.first; it != key_range.second; ++it)
358 auto maybe_value = key_to_t(it->second);
359 if(maybe_value.has_value())
360 dfs_inner(*maybe_value, key_to_t, handle);
A codet representing sequential composition of program statements.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
A collection of goto functions.
instructionst::const_iterator const_targett
std::list< instructiont > instructionst
const irep_idt & id() const
Generates a harness which first assigns global variables with values from a given memory snapshot and...
void add_init_section(const symbol_exprt &func_init_done_var, goto_modelt &goto_model) const
Modify the entry-point function to start from the user-specified initial location.
entry_locationt entry_location
data to initialize the entry function
void insert_harness_function_into_goto_model(goto_modelt &goto_model, const symbolt &function) const
Insert the function into the symbol table (and the goto functions map) of the goto_model.
const symbolt & fresh_symbol_copy(const symbolt &snapshot_symbol, symbol_table_baset &symbol_table) const
Introduce a new symbol into symbol_table with the same name and type as snapshot_symbol.
entry_locationt initialize_entry_via_goto(const entry_goto_locationt &entry_goto_location, const goto_functionst &goto_functions)
Find and return the entry instruction (requested by the user as goto location: function name + locati...
entry_source_locationt parse_source_location(const std::string &cmdl_option)
Parse a command line option to extract the user specified entry source location.
entry_locationt initialize_entry_via_source(const entry_source_locationt &entry_source_location, const goto_functionst &goto_functions)
Find and return the entry instruction (requested by the user as source location: file name + line num...
code_blockt add_assignments_to_globals(const symbol_table_baset &snapshot, goto_modelt &goto_model) const
For each global symbol in the snapshot symbol table either: 1) add code_assignt assigning a value fro...
message_handlert & message_handler
memory_snapshot_harness_generatort(message_handlert &message_handler)
void handle_option(const std::string &option, const std::list< std::string > &values) override
Collect the memory-snapshot specific cmdline options (one at a time)
entry_goto_locationt parse_goto_location(const std::string &cmdl_option)
Parse a command line option to extract the user specified entry goto location.
void collect_references(const exprt &expr, Adder &&add_reference) const
void generate(goto_modelt &goto_model, const irep_idt &harness_function_name) override
The main function of this harness, consists of the following:
void add_call_with_nondet_arguments(const symbolt &called_function_symbol, code_blockt &code) const
Create as many non-deterministic arguments as there are arguments of the called_function_symbol and a...
recursive_initialization_configt recursive_initialization_config
std::string initial_goto_location_line
void get_memory_snapshot(const std::string &file, symbol_table_baset &snapshot) const
Parse the snapshot JSON file and initialise the symbol table.
std::string initial_source_location_line
void validate_options(const goto_modelt &goto_model) override
Check that user options make sense: On their own, e.g.
std::string memory_snapshot_file
data to store the command-line options
std::unordered_set< irep_idt > variables_to_havoc
size_t pointer_depth(const typet &t) const
Recursively compute the pointer depth.
Expression to hold a symbol (variable)
The symbol table base class interface.
The type of an expression, extends irept.
#define PRECONDITION(CONDITION)
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
User provided goto location: function name and (maybe) location number; the structure wraps this opti...
std::optional< unsigned > location_number
entry_goto_locationt()=delete
goto_programt::const_targett find_first_corresponding_instruction(const goto_programt::instructionst &instructions) const
Returns the first goto_programt::instructiont represented by this goto location, i....
entry_goto_locationt(irep_idt function_name, unsigned location_number)
entry_goto_locationt(irep_idt function_name)
Wraps the information needed to identify the entry point.
entry_locationt(irep_idt function_name, goto_programt::const_targett start_instruction)
entry_locationt()=default
goto_programt::const_targett start_instruction
User provided source location: file name and line number; the structure wraps this option with a pars...
std::pair< goto_programt::const_targett, size_t > find_first_corresponding_instruction(const goto_programt::instructionst &instructions) const
Returns the first goto_programt::instructiont represented by this source location,...
entry_source_locationt()=delete
entry_source_locationt(irep_idt file_name, unsigned line_number)
Simple structure for linearising posets.
void sort(const std::vector< std::pair< Key, T >> &input, std::vector< std::pair< Key, T >> &output)
const relationt & preorder_relation
preordert(const relationt &preorder_relation)
void dfs(Value &&node, Map &&key_to_t, Handler &&handle)
void dfs_inner(Value &&node, Map &&key_to_t, Handler &&handle)
std::multimap< Key, Key > relationt
Wraps the information for source location match candidates.
void match_up(const size_t &candidate_distance, const irep_idt &candidate_function_name, const goto_programt::const_targett &candidate_instruction)
goto_programt::const_targett instruction