Go to the documentation of this file.
9 #ifndef CPROVER_GOTO_HARNESS_MEMORY_SNAPSHOT_HARNESS_GENERATOR_H
10 #define CPROVER_GOTO_HARNESS_MEMORY_SNAPSHOT_HARNESS_GENERATOR_H
102 std::pair<goto_programt::const_targett, size_t>
144 const size_t &candidate_distance,
145 const irep_idt &candidate_function_name,
165 const entry_goto_locationt &entry_goto_location,
175 const entry_source_locationt &entry_source_location,
182 const std::string &option,
183 const std::list<std::string> &values)
override;
239 const symbolt &snapshot_symbol,
262 const symbolt &called_function_symbol,
271 const symbolt &
function)
const;
278 template <
typename Adder>
281 if(expr.
id() == ID_symbol)
283 for(
const auto &operand : expr.
operands())
291 template <
typename Key>
303 template <
typename T>
305 const std::vector<std::pair<Key, T>> &input,
306 std::vector<std::pair<Key, T>> &output)
308 std::unordered_map<Key, T> searchable_input;
309 using valuet = std::pair<Key, T>;
311 for(
const auto &item : input)
313 searchable_input[item.first] = item.second;
315 auto associate_key_with_t =
317 if(searchable_input.count(key) != 0)
318 return valuet(key, searchable_input[key]);
322 auto push_to_output = [&output](
const valuet &value) {
323 output.push_back(value);
325 for(
const auto &item : input)
327 dfs(item, associate_key_with_t, push_to_output);
337 template <
typename Value,
typename Map,
typename Handler>
338 void dfs(Value &&node, Map &&key_to_t, Handler &&handle)
346 template <
typename Value,
typename Map,
typename Handler>
347 void dfs_inner(Value &&node, Map &&key_to_t, Handler &&handle)
349 const Key &key = node.first;
350 if(
seen.count(key) == 0)
354 for(
auto it = key_range.first; it != key_range.second; ++it)
356 auto maybe_value = key_to_t(it->second);
357 if(maybe_value.has_value())
358 dfs_inner(*maybe_value, key_to_t, handle);
382 #endif // CPROVER_GOTO_HARNESS_MEMORY_SNAPSHOT_HARNESS_GENERATOR_H
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
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...
A codet representing sequential composition of program statements.
entry_locationt()=default
void match_up(const size_t &candidate_distance, const irep_idt &candidate_function_name, const goto_programt::const_targett &candidate_instruction)
entry_goto_locationt parse_goto_location(const std::string &cmdl_option)
Parse a command line option to extract the user specified entry goto location.
std::multimap< Key, Key > relationt
The type of an expression, extends irept.
const relationt & preorder_relation
std::list< instructiont > instructionst
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)
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,...
Wraps the information for source location match candidates.
entry_source_locationt(irep_idt file_name, unsigned line_number)
Base class for all expressions.
std::string memory_snapshot_file
data to store the command-line options
void validate_options(const goto_modelt &goto_model) override
Check that user options make sense: On their own, e.g.
entry_source_locationt parse_source_location(const std::string &cmdl_option)
Parse a command line option to extract the user specified entry source location.
recursive_initialization_configt recursive_initialization_config
void dfs_inner(Value &&node, Map &&key_to_t, Handler &&handle)
entry_goto_locationt(irep_idt function_name)
Expression to hold a symbol (variable)
message_handlert & message_handler
Generates a harness which first assigns global variables with values from a given memory snapshot and...
User provided goto location: function name and (maybe) location number; the structure wraps this opti...
code_blockt add_assignments_to_globals(const symbol_tablet &snapshot, goto_modelt &goto_model) const
For each global symbol in the snapshot symbol table either: 1) add code_assignt assigning a value fro...
optionalt< unsigned > location_number
memory_snapshot_harness_generatort(message_handlert &message_handler)
static optionalt< smt_termt > get_identifier(const exprt &expr, const std::unordered_map< exprt, smt_identifier_termt, irep_hash > &expression_handle_identifiers, const std::unordered_map< exprt, smt_identifier_termt, irep_hash > &expression_identifiers)
Wraps the information needed to identify the entry point.
#define PRECONDITION(CONDITION)
goto_programt::const_targett start_instruction
entry_goto_locationt(irep_idt function_name, unsigned location_number)
const symbolt & fresh_symbol_copy(const symbolt &snapshot_symbol, symbol_tablet &symbol_table) const
Introduce a new symbol into symbol_table with the same name and type as snapshot_symbol.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
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.
const irep_idt & id() const
goto_programt::const_targett instruction
std::unordered_set< irep_idt > variables_to_havoc
void dfs(Value &&node, Map &&key_to_t, Handler &&handle)
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...
std::string initial_source_location_line
nonstd::optional< T > optionalt
void get_memory_snapshot(const std::string &file, symbol_tablet &snapshot) const
Parse the snapshot JSON file and initialise the symbol table.
User provided source location: file name and line number; the structure wraps this option with a pars...
std::string initial_goto_location_line
A collection of goto functions.
void generate(goto_modelt &goto_model, const irep_idt &harness_function_name) override
The main function of this harness, consists of the following:
entry_locationt entry_location
data to initialize the entry function
void collect_references(const exprt &expr, Adder &&add_reference) const
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_locationt(irep_idt function_name, goto_programt::const_targett start_instruction)
entry_goto_locationt()=delete
size_t pointer_depth(const typet &t) const
Recursively compute the pointer depth.
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...
instructionst::const_iterator const_targett
void sort(const std::vector< std::pair< Key, T >> &input, std::vector< std::pair< Key, T >> &output)
Simple structure for linearising posets.
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.
preordert(const relationt &preorder_relation)
entry_source_locationt()=delete