Skip to content

Commit efd8ffe

Browse files
committed
Add documentation and refactor incremental one loop changes
`check_break` is now documented in `goto_symex.h` as well (I removed the parameters that were not used anywhere).
1 parent 8fb9cd3 commit efd8ffe

File tree

6 files changed

+18
-34
lines changed

6 files changed

+18
-34
lines changed

regression/cbmc-incr-oneloop/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
default: tests.log
22

3+
# Note the `perl -e` serves the purpose of providing timeout
34
test:
45
@../test.pl -c "perl -e 'alarm shift @ARGV; exec @ARGV' 8 ../../../src/cbmc/cbmc --slice-formula"
56

src/goto-checker/symex_bmc_incremental_one_loop.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,14 @@ bool symex_bmc_incremental_one_loopt::should_stop_unwind(
100100
/// \return True if the back edge encountered during symbolic execution
101101
/// corresponds to the given loop (incr_loop_id)
102102
bool symex_bmc_incremental_one_loopt::check_break(
103-
const irep_idt &id,
104-
bool is_function,
105-
statet &state,
106-
const exprt &cond,
103+
const irep_idt &loop_id,
107104
unsigned unwind)
108105
{
109106
if(unwind < incr_min_unwind)
110107
return false;
111108

112109
// loop specified by incremental-loop
113-
return (id == incr_loop_id);
110+
return (loop_id == incr_loop_id);
114111
}
115112

116113
bool symex_bmc_incremental_one_loopt::from_entry_point_of(

src/goto-checker/symex_bmc_incremental_one_loop.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,7 @@ class symex_bmc_incremental_one_loopt : public symex_bmct
3838
std::unique_ptr<goto_symext::statet> state;
3939

4040
// returns true if the symbolic execution is to be interrupted for checking
41-
bool check_break(
42-
const irep_idt &id,
43-
bool is_function,
44-
goto_symext::statet &state,
45-
const exprt &cond,
46-
unsigned unwind) override;
41+
bool check_break(const irep_idt &loop_id, unsigned unwind) override;
4742

4843
bool should_stop_unwind(
4944
const symex_targett::sourcet &source,

src/goto-symex/goto_symex.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,15 @@ class goto_symext
168168
/// by the symbolic executions.
169169
bool ignore_assertions = false;
170170

171-
virtual bool check_break(
172-
const irep_idt &id,
173-
bool is_function,
174-
statet &state,
175-
const exprt &cond,
176-
unsigned unwind);
171+
/// \brief Defines condition for interrupting symbolic execution for a
172+
/// specific loop
173+
///
174+
/// False constant by default, over-ridden by incremental BMC implementation
175+
/// to allow breaking if the unwinding the user specified loop
176+
/// \param id: the loop identifier
177+
/// \param unwind: current unwinding counter
178+
/// \return true if the symbolic execution is to be interrupted for checking
179+
virtual bool check_break(const irep_idt &loop_id, unsigned unwind);
177180

178181
protected:
179182
/// The configuration to use for this symbolic execution

src/goto-symex/symex_goto.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ void goto_symext::symex_goto(statet &state)
287287
if(new_guard.is_true())
288288
{
289289
// we continue executing the loop
290-
if(check_break(loop_id, false, state, new_guard, unwind))
290+
if(check_break(loop_id, unwind))
291291
{
292292
should_pause_symex = true;
293293
}
@@ -584,12 +584,7 @@ void goto_symext::symex_unreachable_goto(statet &state)
584584
symex_transition(state);
585585
}
586586

587-
bool goto_symext::check_break(
588-
const irep_idt &id,
589-
bool is_function,
590-
statet &state,
591-
const exprt &cond,
592-
unsigned unwind)
587+
bool goto_symext::check_break(const irep_idt &loop_id, unsigned unwind)
593588
{
594589
// dummy implementation
595590
return false;

src/goto-symex/symex_target_equation.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,15 +333,8 @@ void symex_target_equationt::convert_without_assertions(
333333

334334
void symex_target_equationt::convert(decision_proceduret &decision_procedure)
335335
{
336-
convert_guards(decision_procedure);
337-
convert_assignments(decision_procedure);
338-
convert_decls(decision_procedure);
339-
convert_assumptions(decision_procedure);
336+
convert_without_assertions(decision_procedure);
340337
convert_assertions(decision_procedure);
341-
convert_goto_instructions(decision_procedure);
342-
convert_function_calls(decision_procedure);
343-
convert_io(decision_procedure);
344-
convert_constraints(decision_procedure);
345338
}
346339

347340
void symex_target_equationt::convert_assignments(
@@ -476,7 +469,7 @@ void symex_target_equationt::convert_assertions(
476469
{
477470
for(auto &step : SSA_steps)
478471
{
479-
// ignore already converted assertions in the error trace
472+
// hide already converted assertions in the error trace
480473
if(step.is_assert() && step.converted)
481474
step.hidden = true;
482475

@@ -503,7 +496,7 @@ void symex_target_equationt::convert_assertions(
503496

504497
for(auto &step : SSA_steps)
505498
{
506-
// ignore already converted assertions in the error trace
499+
// hide already converted assertions in the error trace
507500
if(step.is_assert() && step.converted)
508501
step.hidden = true;
509502

0 commit comments

Comments
 (0)