Skip to content

Refactor in symex #3371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Nov 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cbmc/symex_bmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void symex_bmct::merge_goto(
symex_coverage.covered(prev_pc, state.source.pc);
}

bool symex_bmct::get_unwind(
bool symex_bmct::should_stop_unwind(
const symex_targett::sourcet &source,
const goto_symex_statet::call_stackt &context,
unsigned unwind)
Expand Down
28 changes: 11 additions & 17 deletions src/cbmc/symex_bmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,23 @@ class symex_bmct: public goto_symext
/// recursive call
std::vector<recursion_unwind_handlert> recursion_unwind_handlers;

//
// overloaded from goto_symext
//
virtual void symex_step(
const get_goto_functiont &get_goto_function,
statet &state);

virtual void merge_goto(
const statet::goto_statet &goto_state,
statet &state);

// for loop unwinding
virtual bool get_unwind(
void symex_step(const get_goto_functiont &get_goto_function, statet &state)
override;

void
merge_goto(const statet::goto_statet &goto_state, statet &state) override;

bool should_stop_unwind(
const symex_targett::sourcet &source,
const goto_symex_statet::call_stackt &context,
unsigned unwind);
unsigned unwind) override;

virtual bool get_unwind_recursion(
bool get_unwind_recursion(
const irep_idt &identifier,
const unsigned thread_nr,
unsigned unwind);
unsigned unwind) override;

virtual void no_body(const irep_idt &identifier);
void no_body(const irep_idt &identifier) override;

std::unordered_set<irep_idt> body_warnings;

Expand Down
75 changes: 10 additions & 65 deletions src/goto-symex/goto_symex.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,12 @@ class goto_symext
{
}

virtual ~goto_symext()
{
}
virtual ~goto_symext() = default;

typedef
std::function<const goto_functionst::goto_functiont &(const irep_idt &)>
get_goto_functiont;

/// \brief symex entire program starting from entry point
///
/// The state that goto_symext maintains has a large memory footprint.
/// This method deallocates the state as soon as symbolic execution
/// has completed, so use it if you don't care about having the state
/// around afterwards.
virtual void symex_from_entry_point_of(
const goto_functionst &goto_functions,
symbol_tablet &new_symbol_table);

/// \brief symex entire program starting from entry point
///
/// The state that goto_symext maintains has a large memory footprint.
Expand All @@ -115,7 +103,7 @@ class goto_symext
virtual void resume_symex_from_saved_state(
const get_goto_functiont &get_goto_function,
const statet &saved_state,
symex_target_equationt *const saved_equation,
symex_target_equationt *saved_equation,
symbol_tablet &new_symbol_table);

//// \brief symex entire program starting from entry point
Expand All @@ -142,38 +130,6 @@ class goto_symext
const get_goto_functiont &,
symbol_tablet &);

/// Symexes from the first instruction and the given state, terminating as
/// soon as the last instruction is reached. This is useful to explicitly
/// symex certain ranges of a program, e.g. in an incremental decision
/// procedure.
/// \param state Symex state to start with.
/// \param goto_functions GOTO model to symex.
/// \param function_identifier The function with the instruction range
/// \param first Entry point in form of a first instruction.
/// \param limit Final instruction, which itself will not be symexed.
virtual void symex_instruction_range(
statet &,
const goto_functionst &,
const irep_idt &function_identifier,
goto_programt::const_targett first,
goto_programt::const_targett limit);

/// Symexes from the first instruction and the given state, terminating as
/// soon as the last instruction is reached. This is useful to explicitly
/// symex certain ranges of a program, e.g. in an incremental decision
/// procedure.
/// \param state Symex state to start with.
/// \param get_goto_function retrieves a function body
/// \param function_identifier The function with the instruction range
/// \param first Entry point in form of a first instruction.
/// \param limit Final instruction, which itself will not be symexed.
virtual void symex_instruction_range(
statet &state,
const get_goto_functiont &get_goto_function,
const irep_idt &function_identifier,
goto_programt::const_targett first,
goto_programt::const_targett limit);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be squash with the preceding commit.


/// \brief Have states been pushed onto the workqueue?
///
/// If this flag is set at the end of a symbolic execution run, it means that
Expand Down Expand Up @@ -215,8 +171,6 @@ class goto_symext
const bool allow_pointer_unsoundness;

public:
// these bypass the target maps
virtual void symex_step_goto(statet &, bool taken);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the commit message could be made to include the names of functions being removed? These have likely been used elsewhere (Satabs comes to mind), and if we ever want to resurrect them, the git history is vital.


/// language_mode: ID_java, ID_C or another language identifier
/// if we know the source language in use, irep_idt() otherwise.
Expand Down Expand Up @@ -263,13 +217,9 @@ class goto_symext
void initialize_auto_object(const exprt &, statet &);
void process_array_expr(exprt &);
exprt make_auto_object(const typet &, statet &);
virtual void dereference(exprt &, statet &, const bool write);
virtual void dereference(exprt &, statet &, bool write);

void dereference_rec(
exprt &,
statet &,
guardt &,
const bool write);
void dereference_rec(exprt &, statet &, guardt &, bool write);

void dereference_rec_address_of(
exprt &,
Expand All @@ -292,13 +242,13 @@ class goto_symext
virtual void symex_transition(
statet &,
goto_programt::const_targett to,
bool is_backwards_goto=false);
bool is_backwards_goto);

virtual void symex_transition(statet &state)
{
goto_programt::const_targett next=state.source.pc;
++next;
symex_transition(state, next);
symex_transition(state, next, false);
}

virtual void symex_goto(statet &);
Expand Down Expand Up @@ -334,7 +284,7 @@ class goto_symext

// determine whether to unwind a loop -- true indicates abort,
// with false we continue.
virtual bool get_unwind(
virtual bool should_stop_unwind(
const symex_targett::sourcet &source,
const goto_symex_statet::call_stackt &context,
unsigned unwind);
Expand Down Expand Up @@ -369,24 +319,20 @@ class goto_symext

virtual bool get_unwind_recursion(
const irep_idt &identifier,
const unsigned thread_nr,
unsigned thread_nr,
unsigned unwind);

void parameter_assignments(
const irep_idt function_identifier,
const irep_idt &function_identifier,
const goto_functionst::goto_functiont &,
statet &,
const exprt::operandst &arguments);

void locality(
const irep_idt function_identifier,
const irep_idt &function_identifier,
statet &,
const goto_functionst::goto_functiont &);

void add_end_of_function(
exprt &code,
const irep_idt &identifier);

nondet_symbol_exprt build_symex_nondet(typet &type);

// exceptions
Expand Down Expand Up @@ -471,7 +417,6 @@ class goto_symext
static unsigned nondet_count;
static unsigned dynamic_counter;

void read(exprt &);
void replace_nondet(exprt &);
void rewrite_quantifiers(exprt &, statet &);

Expand Down
4 changes: 2 additions & 2 deletions src/goto-symex/symex_builtin_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ void goto_symext::symex_allocate(
}
else
{
exprt nondet = build_symex_nondet(object_type);
code_assignt assignment(value_symbol.symbol_expr(), nondet);
const exprt nondet = build_symex_nondet(object_type);
const code_assignt assignment(value_symbol.symbol_expr(), nondet);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change works in here, given the comments that have been removed from the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes thanks, it wasn't caught while rebasing.

symex_assign(state, assignment);
}

Expand Down
9 changes: 3 additions & 6 deletions src/goto-symex/symex_dereference_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,10 @@ class symex_dereference_statet:
goto_symext &goto_symex;
goto_symext::statet &state;

virtual void get_value_set(
const exprt &expr,
value_setst::valuest &value_set);
void
get_value_set(const exprt &expr, value_setst::valuest &value_set) override;

virtual bool has_failed_symbol(
const exprt &expr,
const symbolt *&symbol);
bool has_failed_symbol(const exprt &expr, const symbolt *&symbol) override;
};

#endif // CPROVER_GOTO_SYMEX_SYMEX_DEREFERENCE_STATE_H
8 changes: 4 additions & 4 deletions src/goto-symex/symex_function_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bool goto_symext::get_unwind_recursion(
}

void goto_symext::parameter_assignments(
const irep_idt function_identifier,
const irep_idt &function_identifier,
const goto_functionst::goto_functiont &goto_function,
statet &state,
const exprt::operandst &arguments)
Expand Down Expand Up @@ -311,7 +311,7 @@ void goto_symext::symex_function_call_code(

state.source.is_set=true;
state.source.function = identifier;
symex_transition(state, goto_function.body.instructions.begin());
symex_transition(state, goto_function.body.instructions.begin(), false);
}

/// pop one call frame
Expand All @@ -323,7 +323,7 @@ void goto_symext::pop_frame(statet &state)
statet::framet &frame=state.top();

// restore program counter
symex_transition(state, frame.calling_location.pc);
symex_transition(state, frame.calling_location.pc, false);
state.source.function = frame.calling_location.function;

// restore L1 renaming
Expand Down Expand Up @@ -368,7 +368,7 @@ void goto_symext::symex_end_of_function(statet &state)
/// preserves locality of local variables of a given function by applying L1
/// renaming to the local identifiers
void goto_symext::locality(
const irep_idt function_identifier,
const irep_idt &function_identifier,
statet &state,
const goto_functionst::goto_functiont &goto_function)
{
Expand Down
Loading