Skip to content

Make goto_symext::language_mode protected #8646

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

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
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
22 changes: 0 additions & 22 deletions src/goto-checker/bmc_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ Author: Daniel Kroening, Peter Schrammel
#include <goto-symex/slice.h>
#include <goto-symex/symex_target_equation.h>

#include <linking/static_lifetime_init.h>

#include <solvers/decision_procedure.h>

#include <util/json_stream.h>
Expand Down Expand Up @@ -175,26 +173,6 @@ get_memory_model(const optionst &options, const namespacet &ns)
}
}

void setup_symex(
symex_bmct &symex,
const namespacet &ns,
const optionst &options,
ui_message_handlert &ui_message_handler)
{
messaget msg(ui_message_handler);
const symbolt *init_symbol;
if(!ns.lookup(INITIALIZE_FUNCTION, init_symbol))
symex.language_mode = init_symbol->mode;

msg.status() << "Starting Bounded Model Checking" << messaget::eom;

symex.last_source_location.make_nil();

symex.unwindset.parse_unwind(options.get_option("unwind"));
symex.unwindset.parse_unwindset(
options.get_list_option("unwindset"), ui_message_handler);
}

void slice(
symex_bmct &symex,
symex_target_equationt &symex_target_equation,
Expand Down
6 changes: 0 additions & 6 deletions src/goto-checker/bmc_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ void output_graphml(
std::unique_ptr<memory_model_baset>
get_memory_model(const optionst &options, const namespacet &);

void setup_symex(
symex_bmct &,
const namespacet &,
const optionst &,
ui_message_handlert &);

void slice(
symex_bmct &,
symex_target_equationt &symex_target_equation,
Expand Down
5 changes: 3 additions & 2 deletions src/goto-checker/multi_path_symex_only_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ multi_path_symex_only_checkert::multi_path_symex_only_checkert(
goto_model(goto_model),
ns(goto_model.get_symbol_table(), symex_symbol_table),
equation(ui_message_handler),
unwindset(goto_model),
symex(
ui_message_handler,
goto_model.get_symbol_table(),
Expand All @@ -37,7 +36,9 @@ multi_path_symex_only_checkert::multi_path_symex_only_checkert(
guard_manager,
unwindset)
{
setup_symex(symex, ns, options, ui_message_handler);
unwindset.parse_unwind(options.get_option("unwind"));
unwindset.parse_unwindset(
options.get_list_option("unwindset"), goto_model, ui_message_handler);
}

incremental_goto_checkert::resultt multi_path_symex_only_checkert::
Expand Down
5 changes: 3 additions & 2 deletions src/goto-checker/single_loop_incremental_symex_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ single_loop_incremental_symex_checkert::single_loop_incremental_symex_checkert(
goto_model(goto_model),
ns(goto_model.get_symbol_table(), symex_symbol_table),
equation(ui_message_handler),
unwindset(goto_model),
symex(
ui_message_handler,
goto_model.get_symbol_table(),
Expand All @@ -40,7 +39,9 @@ single_loop_incremental_symex_checkert::single_loop_incremental_symex_checkert(
ui_message_handler.get_ui()),
property_decider(options, ui_message_handler, equation, ns)
{
setup_symex(symex, ns, options, ui_message_handler);
unwindset.parse_unwind(options.get_option("unwind"));
unwindset.parse_unwindset(
options.get_list_option("unwindset"), goto_model, ui_message_handler);

// Freeze all symbols if we are using a prop_conv_solvert
prop_conv_solvert *prop_conv_solver = dynamic_cast<prop_conv_solvert *>(
Expand Down
11 changes: 4 additions & 7 deletions src/goto-checker/single_path_symex_only_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ single_path_symex_only_checkert::single_path_symex_only_checkert(
goto_model(goto_model),
ns(goto_model.get_symbol_table(), symex_symbol_table),
worklist(get_path_strategy(options.get_option("exploration-strategy"))),
symex_runtime(0),
unwindset(goto_model)
symex_runtime(0)
{
unwindset.parse_unwind(options.get_option("unwind"));
unwindset.parse_unwindset(
options.get_list_option("unwindset"), goto_model, ui_message_handler);
}

incremental_goto_checkert::resultt single_path_symex_only_checkert::
Expand Down Expand Up @@ -150,11 +152,6 @@ void single_path_symex_only_checkert::equation_output(
}
}

void single_path_symex_only_checkert::setup_symex(symex_bmct &symex)
{
::setup_symex(symex, ns, options, ui_message_handler);
}

void single_path_symex_only_checkert::update_properties(
propertiest &properties,
std::unordered_set<irep_idt> &updated_properties,
Expand Down
5 changes: 4 additions & 1 deletion src/goto-checker/single_path_symex_only_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ class single_path_symex_only_checkert : public incremental_goto_checkert
const symex_bmct &symex,
const symex_target_equationt &equation);

virtual void setup_symex(symex_bmct &symex);
virtual void setup_symex(symex_bmct &symex)
{
// deriving classes may do extra work here
}

/// Adds the initial goto-symex state as a path to the worklist
virtual void initialize_worklist();
Expand Down
9 changes: 9 additions & 0 deletions src/goto-checker/symex_bmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Author: Daniel Kroening, [email protected]

#include <goto-instrument/unwindset.h>

#include <linking/static_lifetime_init.h>

symex_bmct::symex_bmct(
message_handlert &mh,
const symbol_tablet &outer_symbol_table,
Expand All @@ -33,10 +35,17 @@ symex_bmct::symex_bmct(
options,
path_storage,
guard_manager),
last_source_location(source_locationt::nil()),
record_coverage(!options.get_option("symex-coverage-report").empty()),
unwindset(unwindset),
symex_coverage(ns)
{
const symbolt *init_symbol = outer_symbol_table.lookup(INITIALIZE_FUNCTION);
if(init_symbol)
language_mode = init_symbol->mode;

messaget msg{mh};
msg.status() << "Starting Bounded Model Checking" << messaget::eom;
}

/// show progress
Expand Down
2 changes: 1 addition & 1 deletion src/goto-checker/symex_bmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ class symex_bmct : public goto_symext

const bool record_coverage;

protected:
unwindsett &unwindset;

protected:
/// Callbacks that may provide an unwind/do-not-unwind decision for a loop
std::vector<loop_unwind_handlert> loop_unwind_handlers;

Expand Down
5 changes: 3 additions & 2 deletions src/goto-instrument/contracts/contracts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1493,8 +1493,9 @@ void code_contractst::apply_loop_contracts(
// unwind all transformed loops twice.
if(loop_contract_config.unwind_transformed_loops)
{
unwindsett unwindset{goto_model};
unwindset.parse_unwindset(loop_names, log.get_message_handler());
unwindsett unwindset;
unwindset.parse_unwindset(
loop_names, goto_model, log.get_message_handler());
goto_unwindt goto_unwind;
goto_unwind(goto_model, unwindset, goto_unwindt::unwind_strategyt::ASSUME);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1208,8 +1208,8 @@ void dfcc_instrumentt::apply_loop_contracts(
// If required, unwind all transformed loops to yield base and step cases
if(loop_contract_config.unwind_transformed_loops)
{
unwindsett unwindset{goto_model};
unwindset.parse_unwindset(to_unwind, log.get_message_handler());
unwindsett unwindset;
unwindset.parse_unwindset(to_unwind, goto_model, log.get_message_handler());
goto_unwindt goto_unwind;
goto_unwind(goto_model, unwindset, goto_unwindt::unwind_strategyt::ASSUME);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ void dfcc_libraryt::specialize(const std::size_t contract_assigns_size)
"dfcc_libraryt::specialize_functions can only be called once");

specialized = true;
unwindsett unwindset{goto_model};
std::list<std::string> loop_names;

for(const auto &entry : to_unwind)
Expand All @@ -452,7 +451,8 @@ void dfcc_libraryt::specialize(const std::size_t contract_assigns_size)
const auto &str = stream.str();
loop_names.push_back(str);
}
unwindset.parse_unwindset(loop_names, message_handler);
unwindsett unwindset;
unwindset.parse_unwindset(loop_names, goto_model, message_handler);
goto_unwindt goto_unwind;
goto_unwind(
goto_model, unwindset, goto_unwindt::unwind_strategyt::ASSERT_ASSUME);
Expand Down
7 changes: 5 additions & 2 deletions src/goto-instrument/goto_instrument_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,24 @@ int goto_instrument_parse_optionst::doit()

if(unwind_given || unwindset_given || unwindset_file_given)
{
unwindsett unwindset{goto_model};
unwindsett unwindset;

if(unwind_given)
unwindset.parse_unwind(cmdline.get_value("unwind"));

if(unwindset_file_given)
{
unwindset.parse_unwindset_file(
cmdline.get_value("unwindset-file"), ui_message_handler);
cmdline.get_value("unwindset-file"),
goto_model,
ui_message_handler);
}

if(unwindset_given)
{
unwindset.parse_unwindset(
cmdline.get_comma_separated_values("unwindset"),
goto_model,
ui_message_handler);
}

Expand Down
7 changes: 5 additions & 2 deletions src/goto-instrument/unwindset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ void unwindsett::parse_unwind(const std::string &unwind)

void unwindsett::parse_unwindset_one_loop(
std::string val,
abstract_goto_modelt &goto_model,
message_handlert &message_handler)
{
if(val.empty())
Expand Down Expand Up @@ -181,10 +182,11 @@ void unwindsett::parse_unwindset_one_loop(

void unwindsett::parse_unwindset(
const std::list<std::string> &unwindset,
abstract_goto_modelt &goto_model,
message_handlert &message_handler)
{
for(auto &element : unwindset)
parse_unwindset_one_loop(element, message_handler);
parse_unwindset_one_loop(element, goto_model, message_handler);
}

std::optional<unsigned>
Expand All @@ -211,6 +213,7 @@ unwindsett::get_limit(const irep_idt &loop_id, unsigned thread_nr) const

void unwindsett::parse_unwindset_file(
const std::string &file_name,
abstract_goto_modelt &goto_model,
message_handlert &message_handler)
{
std::ifstream file(widen_if_needed(file_name));
Expand All @@ -225,5 +228,5 @@ void unwindsett::parse_unwindset_file(
split_string(buffer.str(), ',', true, true);

for(auto &element : unwindset_elements)
parse_unwindset_one_loop(element, message_handler);
parse_unwindset_one_loop(element, goto_model, message_handler);
}
9 changes: 4 additions & 5 deletions src/goto-instrument/unwindset.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@ class unwindsett
// 2) a limit per loop, all threads
// 3) a limit for a particular thread.
// We use the most specific of the above.
explicit unwindsett(abstract_goto_modelt &goto_model) : goto_model(goto_model)
{
}
unwindsett() = default;

// global limit for all loops
void parse_unwind(const std::string &unwind);

// limit for instances of a loop
void parse_unwindset(
const std::list<std::string> &unwindset,
abstract_goto_modelt &goto_model,
message_handlert &message_handler);

// queries
Expand All @@ -49,11 +48,10 @@ class unwindsett
// read unwindset directives from a file
void parse_unwindset_file(
const std::string &file_name,
abstract_goto_modelt &goto_model,
message_handlert &message_handler);

protected:
abstract_goto_modelt &goto_model;

std::optional<unsigned> global_limit;

// Limit for all instances of a loop.
Expand All @@ -68,6 +66,7 @@ class unwindsett

void parse_unwindset_one_loop(
std::string loop_limit,
abstract_goto_modelt &goto_model,
message_handlert &message_handler);
};

Expand Down
3 changes: 0 additions & 3 deletions src/goto-symex/goto_symex.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,10 @@ class goto_symext
messaget::mstreamt &
print_callstack_entry(const symex_targett::sourcet &target);

public:

/// language_mode: ID_java, ID_C or another language identifier
/// if we know the source language in use, irep_idt() otherwise.
irep_idt language_mode;

protected:
/// The symbol table associated with the goto-program being executed.
/// This symbol table will not have objects that are dynamically created as
/// part of symbolic execution added to it; those object are stored in the
Expand Down
7 changes: 4 additions & 3 deletions unit/path_strategies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,10 @@ void _check_with_strategy(
propertiest properties(initialize_properties(goto_model));
std::unique_ptr<path_storaget> worklist = get_path_strategy(strategy);
guard_managert guard_manager;
unwindsett unwindset{goto_model};
unwindsett unwindset;
unwindset.parse_unwind(options.get_option("unwind"));
unwindset.parse_unwindset(
options.get_list_option("unwindset"), goto_model, ui_message_handler);

{
// Put initial state into the work list
Expand All @@ -428,7 +431,6 @@ void _check_with_strategy(
*worklist,
guard_manager,
unwindset);
setup_symex(symex, ns, options, ui_message_handler);

symex.initialize_path_storage_from_entry_point_of(
goto_symext::get_goto_function(goto_model),
Expand All @@ -451,7 +453,6 @@ void _check_with_strategy(
*worklist,
guard_manager,
unwindset);
setup_symex(symex, ns, options, ui_message_handler);

symex_symbol_table = symex.resume_symex_from_saved_state(
goto_symext::get_goto_function(goto_model),
Expand Down
Loading