Go to the documentation of this file.
12 #ifndef CPROVER_GOTO_SYMEX_GOTO_SYMEX_H
13 #define CPROVER_GOTO_SYMEX_GOTO_SYMEX_H
124 const statet &saved_state,
176 std::unique_ptr<statet>
294 bool is_in_quantifier);
353 const exprt &original_guard,
354 const exprt &new_guard,
382 const std::string &msg,
477 const exprt &cleaned_lhs,
493 const irep_idt &function_identifier,
694 const std::string &aux_symbol_name,
820 _total_vccs != std::numeric_limits<unsigned>::max(),
821 "symex_threaded_step should have been executed at least once before "
822 "attempting to read total_vccs");
830 "symex_threaded_step should have been executed at least once before "
831 "attempting to read remaining_vccs");
852 bool is_backwards_goto);
870 #endif // CPROVER_GOTO_SYMEX_GOTO_SYMEX_H
Class that provides messages with a built-in verbosity 'level'.
virtual void symex_with_state(statet &state, const get_goto_functiont &get_goto_functions, symbol_tablet &new_symbol_table)
Symbolically execute the entire program starting from entry point.
exprt clean_expr(exprt expr, statet &state, bool write)
Clean up an expression.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
symbol_exprt cache_dereference(exprt &dereference_result, statet &state)
virtual void symex_step(const get_goto_functiont &get_goto_function, statet &state)
Called for each step in the symbolic execution This calls print_symex_step to print symex's current i...
void symex_assume_l2(statet &, const exprt &cond)
goto_symext::statet & state
std::vector< symbol_exprt > instruction_local_symbols
Variables that should be killed at the end of the current symex_step invocation.
void symex_unreachable_goto(statet &state)
Symbolically execute a GOTO instruction in the context of unreachable code.
Configuration used for a symbolic execution.
void kill_instruction_local_symbols(statet &state)
Kills any variables in instruction_local_symbols (these are currently always let-bound variables defi...
static unsigned dynamic_counter
A monotonically increasing index for each created dynamic object.
void try_filter_value_sets(goto_symex_statet &state, exprt condition, const value_sett &original_value_set, value_sett *jump_taken_value_set, value_sett *jump_not_taken_value_set, const namespacet &ns)
Try to filter value sets based on whether possible values of a pointer-typed symbol make the conditio...
optionalt< std::reference_wrapper< const array_exprt > > try_evaluate_constant_string(const statet &state, const exprt &content)
The type of an expression, extends irept.
exprt address_arithmetic(const exprt &, statet &, bool keep_array)
Transforms an lvalue expression by replacing any dereference operations it contains with explicit ref...
virtual void symex_printf(statet &state, const exprt &rhs)
Symbolically execute an OTHER instruction that does a CPP printf
bool constant_propagate_case_change(statet &state, symex_assignt &symex_assign, const function_application_exprt &f_l1, bool to_upper)
Attempt to constant propagate case changes, both upper and lower.
bool constant_propagate_delete(statet &state, symex_assignt &symex_assign, const function_application_exprt &f_l1)
Attempt to constant propagate deleting a substring from a string.
symex_target_equationt & target
The equation that this execution is building up.
virtual void resume_symex_from_saved_state(const get_goto_functiont &get_goto_function, const statet &saved_state, symex_target_equationt *saved_equation, symbol_tablet &new_symbol_table)
Performs symbolic execution using a state and equation that have already been used to symbolically ex...
Storage for symbolic execution paths to be resumed later.
path_storaget & path_storage
Symbolic execution paths to be resumed later.
Central data structure: state.
bool constant_propagate_trim(statet &state, symex_assignt &symex_assign, const function_application_exprt &f_l1)
Attempt to constant propagate trim operations.
bool ignore_assertions
If this flag is set to true then assertions will be temporarily ignored by the symbolic executions.
guard_managert & guard_manager
Used to create guards.
bool constant_propagate_set_char_at(statet &state, symex_assignt &symex_assign, const function_application_exprt &f_l1)
Attempt to constant propagate setting the char at the given index.
virtual void symex_function_call_post_clean(const get_goto_functiont &get_goto_function, statet &state, const exprt &cleaned_lhs, const symbol_exprt &function, const exprt::operandst &cleaned_arguments)
Symbolic execution of a function call by inlining.
virtual void symex_cpp_new(statet &state, const exprt &lhs, const side_effect_exprt &code)
Handles side effects of type 'new' for C++ and 'new array' for C++ and Java language modes.
const symbolt & get_new_string_data_symbol(statet &state, symex_assignt &symex_assign, const std::string &aux_symbol_name, const ssa_exprt &char_array, const array_exprt &new_char_array)
Installs a new symbol in the symbol table to represent the given character array, and assigns the cha...
virtual void initialize_path_storage_from_entry_point_of(const get_goto_functiont &get_goto_function, symbol_tablet &new_symbol_table)
Puts the initial state of the entry point function into the path storage.
goto_symex_statet statet
A type abbreviation for goto_symex_statet.
State type in value_set_domaint, used in value-set analysis and goto-symex.
Base class for all expressions.
void merge_gotos(statet &state)
Merge all branches joining at the current program point.
bool constant_propagate_delete_char_at(statet &state, symex_assignt &symex_assign, const function_application_exprt &f_l1)
Attempt to constant propagate deleting a character from a string.
void lift_let(statet &state, const let_exprt &let_expr)
Execute a single let expression, which should not have any nested let expressions (use lift_lets inst...
Functor for symex assignment.
virtual void symex_dead(statet &state)
Symbolically execute a DEAD instruction.
void symex_catch(statet &state)
Symbolically execute a CATCH instruction.
void trigger_auto_object(const exprt &, statet &)
Expression to hold a symbol (variable)
complexity_limitert complexity_module
void symex_throw(statet &state)
Symbolically execute a THROW instruction.
std::unique_ptr< statet > initialize_entry_point_state(const get_goto_functiont &get_goto_function)
Initialize the symbolic execution and the given state with the beginning of the entry point function.
virtual bool should_stop_unwind(const symex_targett::sourcet &source, const call_stackt &context, unsigned unwind)
Determine whether to unwind a loop.
virtual bool get_unwind_recursion(const irep_idt &identifier, unsigned thread_nr, unsigned unwind)
void assign_string_constant(statet &state, symex_assignt &symex_assign, const ssa_exprt &length, const constant_exprt &new_length, const ssa_exprt &char_array, const array_exprt &new_char_array)
Assign constant string length and string data given by a char array to given ssa variables.
std::size_t path_segment_vccs
Number of VCCs generated during the run of this goto_symext object.
messaget log
The messaget to write log messages to.
Expression providing an SSA-renamed symbol of expressions.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
This is unused by this implementation of guards, but can be used by other implementations of the same...
goto_instruction_codet representation of a function call statement.
virtual void symex_atomic_end(statet &state)
Symbolically execute an ATOMIC_END instruction.
void associate_array_to_pointer(statet &state, symex_assignt &symex_assign, const array_exprt &new_char_array, const address_of_exprt &string_data)
Generate array to pointer association primitive.
void parameter_assignments(const irep_idt &function_identifier, const goto_functionst::goto_functiont &goto_function, statet &state, const exprt::operandst &arguments)
Iterates over arguments and assigns them to the parameters, which are symbols whose name and type are...
virtual void merge_goto(const symex_targett::sourcet &source, goto_statet &&goto_state, statet &state)
Merge a single branch, the symbolic state of which is held in goto_state, into the current overall sy...
bool constant_propagate_string_concat(statet &state, symex_assignt &symex_assign, const function_application_exprt &f_l1)
Attempt to constant propagate string concatenation.
bool constant_propagate_integer_to_string(statet &state, symex_assignt &symex_assign, const function_application_exprt &f_l1)
Attempt to constant propagate converting an integer to a string.
const symbol_tablet & outer_symbol_table
The symbol table associated with the goto-program being executed.
void process_array_expr(statet &, exprt &)
Given an expression, find the root object and the offset into it.
virtual void dereference(exprt &, statet &, bool write)
Replace all dereference operations within expr with explicit references to the objects they may refer...
virtual void symex_goto(statet &state)
Symbolically execute a GOTO instruction.
virtual void symex_function_call_symbol(const get_goto_functiont &get_goto_function, statet &state, const exprt &lhs, const symbol_exprt &function, const exprt::operandst &arguments)
Symbolic execution of a call to a function call.
virtual void symex_cpp_delete(statet &state, const codet &code)
Symbolically execute an OTHER instruction that does a CPP delete
void constant_propagate_empty_string(statet &state, symex_assignt &symex_assign, const function_application_exprt &f_l1)
Create an empty string constant.
bool constant_propagate_string_substring(statet &state, symex_assignt &symex_assign, const function_application_exprt &f_l1)
Attempt to constant propagate getting a substring of a string.
virtual void symex_decl(statet &state)
Symbolically execute a DECL instruction.
bool constant_propagate_set_length(statet &state, symex_assignt &symex_assign, const function_application_exprt &f_l1)
Attempt to constant propagate setting the length of a string.
virtual void symex_allocate(statet &state, const exprt &lhs, const side_effect_exprt &code)
Symbolically execute an assignment instruction that has an allocate on the right hand side.
void initialize_auto_object(const exprt &, statet &)
virtual void symex_va_start(statet &, const exprt &lhs, const side_effect_exprt &)
virtual void symex_from_entry_point_of(const get_goto_functiont &get_goto_function, symbol_tablet &new_symbol_table)
Symbolically execute the entire program starting from entry point.
void validate(const validation_modet vm) const
void dereference_rec(exprt &expr, statet &state, bool write, bool is_in_quantifier)
If expr is a dereference_exprt, replace it with explicit references to the objects it may point to.
The main class for the forward symbolic simulator.
Callback object that goto_symext::dereference_rec provides to value_set_dereferencet to provide value...
void phi_function(const goto_statet &goto_state, statet &dest_state)
Merge the SSA assignments from goto_state into dest_state.
virtual void symex_input(statet &state, const codet &code)
Symbolically execute an OTHER instruction that does a CPP input.
virtual void symex_end_of_function(statet &)
Symbolically execute a END_FUNCTION instruction.
Application of (mathematical) function.
exprt make_auto_object(const typet &, statet &)
goto_symext(message_handlert &mh, const symbol_tablet &outer_symbol_table, symex_target_equationt &_target, const optionst &options, path_storaget &path_storage, guard_managert &guard_manager)
Construct a goto_symext to execute a particular program.
std::vector< exprt > operandst
nonstd::optional< T > optionalt
virtual void do_simplify(exprt &expr)
void symex_threaded_step(statet &state, const get_goto_functiont &get_goto_function)
Invokes symex_step and verifies whether additional threads can be executed.
virtual void symex_function_call(const get_goto_functiont &get_goto_function, statet &state, const goto_programt::instructiont &instruction)
Symbolically execute a FUNCTION_CALL instruction.
Container for data that varies per program point, e.g.
void symex_transition(goto_symext::statet &state)
Transition to the next instruction, which increments the internal program counter and initializes the...
Inheriting the interface of symex_targett this class represents the SSA form of the input program as ...
::goto_functiont goto_functiont
void havoc_rec(statet &state, const guardt &guard, const exprt &dest)
namespacet ns
Initialized just before symbolic execution begins, to point to both outer_symbol_table and the symbol...
virtual ~goto_symext()=default
A virtual destructor allowing derived classes to be cleaned up correctly.
renamedt< exprt, L2 > try_evaluate_pointer_comparisons(renamedt< exprt, L2 > condition, const value_sett &value_set, const irep_idt &language_mode, const namespacet &ns)
Try to evaluate pointer comparisons where they can be trivially determined using the value-set.
virtual bool check_break(const irep_idt &loop_id, unsigned unwind)
Defines condition for interrupting symbolic execution for a specific loop.
irep_idt language_mode
language_mode: ID_java, ID_C or another language identifier if we know the source language in use,...
void execute_next_instruction(const get_goto_functiont &get_goto_function, statet &state)
Executes the instruction state.source.pc Case-switches over the type of the instruction being execute...
unsigned atomic_section_counter
A monotonically increasing index for each encountered ATOMIC_BEGIN instruction.
symex_targett::assignment_typet assignment_typet
virtual void symex_assume(statet &state, const exprt &cond)
Symbolically execute an ASSUME instruction or simulate such an execution for a synthetic assumption.
virtual void vcc(const exprt &, const std::string &msg, statet &)
static get_goto_functiont get_goto_function(abstract_goto_modelt &goto_model)
Return a function to get/load a goto function from the given goto model Create a default delegate to ...
void lift_lets(statet &, exprt &)
Execute any let expressions in expr using symex_assignt::assign_symbol.
void validate(const namespacet &ns, const validation_modet vm) const
const symex_configt symex_config
The configuration to use for this symbolic execution.
bool constant_propagate_assignment_with_side_effects(statet &state, symex_assignt &symex_assign, const exprt &lhs, const exprt &rhs)
Attempt to constant propagate side effects of the assignment (if any)
messaget::mstreamt & print_callstack_entry(const symex_targett::sourcet &target)
std::function< const goto_functionst::goto_functiont &(const irep_idt &)> get_goto_functiont
The type of delegate functions that retrieve a goto_functiont for a particular function identifier.
instructionst::const_iterator const_targett
virtual void loop_bound_exceeded(statet &state, const exprt &guard)
static optionalt< std::reference_wrapper< const constant_exprt > > try_evaluate_constant(const statet &state, const exprt &expr)
Abstract interface to eager or lazy GOTO models.
Identifies source in the context of symbolic execution.
virtual void symex_atomic_begin(statet &state)
Symbolically execute an ATOMIC_BEGIN instruction.
void apply_goto_condition(goto_symex_statet ¤t_state, goto_statet &jump_taken_state, goto_statet &jump_not_taken_state, const exprt &original_guard, const exprt &new_guard, const namespacet &ns)
Propagate constants and points-to information implied by a GOTO condition.
virtual void no_body(const irep_idt &identifier)
Log a warning that a function has no body.
Operator to return the address of an object.
void symex_set_return_value(statet &state, const exprt &return_value)
Symbolically execute a SET_RETURN_VALUE instruction.
unsigned get_total_vccs() const
A constant literal expression.
void print_symex_step(statet &state)
Prints the route of symex as it walks through the code.
void symex_assert(const goto_programt::instructiont &, statet &)
bool constant_propagate_replace(statet &state, symex_assignt &symex_assign, const function_application_exprt &f_l1)
Attempt to constant proagate character replacement.
This class represents an instruction in the GOTO intermediate representation.
void symex_assign(statet &state, const exprt &lhs, const exprt &rhs)
Symbolically execute an ASSIGN instruction or simulate such an execution for a synthetic assignment.
void rewrite_quantifiers(exprt &, statet &)
Array constructor from list of elements.
virtual void symex_other(statet &state)
Symbolically execute an OTHER instruction.
virtual void symex_start_thread(statet &state)
Symbolically execute a START_THREAD instruction.
virtual void symex_output(statet &state, const codet &code)
Symbolically execute an OTHER instruction that does a CPP output.
Wrapper for expressions or types which have been renamed up to a given level.
An expression containing a side effect.
unsigned get_remaining_vccs() const
bool should_pause_symex
Set when states are pushed onto the workqueue If this flag is set at the end of a symbolic execution ...
Data structure for representing an arbitrary statement in a program.