Skip to content

Commit ed8700e

Browse files
committed
GOTO trace: no timestamps for single-threaded programs
Avoid reading clock values when those won't be known to the solver as single-threaded source programs do not have partial-order constraints. Other back-ends were silent about this, but the incremental SMT back-end produced warnings (which the user could do nothing about).
1 parent 3bb84f7 commit ed8700e

File tree

3 files changed

+19
-60
lines changed

3 files changed

+19
-60
lines changed

src/goto-symex/build_goto_trace.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ void build_goto_trace(
220220
time_mapt time_map;
221221

222222
mp_integer current_time=0;
223+
bool has_threads = target.has_threads();
223224

224225
ssa_step_iteratort last_step_to_keep = target.SSA_steps.end();
225226
bool last_step_was_kept = false;
@@ -258,6 +259,9 @@ void build_goto_trace(
258259
else if(it->is_shared_read() || it->is_shared_write() ||
259260
it->is_atomic_end())
260261
{
262+
if(!has_threads)
263+
continue;
264+
261265
mp_integer time_before=current_time;
262266

263267
if(it->is_shared_read() || it->is_shared_write())

src/solvers/smt2_incremental/smt2_incremental_decision_procedure.cpp

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -436,36 +436,21 @@ exprt smt2_incremental_decision_proceduret::get(const exprt &expr) const
436436
}();
437437
if(!descriptor)
438438
{
439-
if(gather_dependent_expressions(expr).empty())
440-
{
441-
INVARIANT(
442-
objects_are_already_tracked(expr, object_map),
443-
"Objects in expressions being read should already be tracked from "
444-
"point of being set/handled.");
445-
descriptor = ::convert_expr_to_smt(
446-
expr,
447-
object_map,
448-
pointer_sizes_map,
449-
object_size_function.make_application,
450-
is_dynamic_object_function.make_application);
451-
}
452-
else
453-
{
454-
const auto symbol_expr = expr_try_dynamic_cast<symbol_exprt>(expr);
455-
INVARIANT(
456-
symbol_expr, "Unhandled expressions are expected to be symbols");
457-
// Note this case is currently expected to be encountered during trace
458-
// generation for -
459-
// * Steps which were removed via --slice-formula.
460-
// * Getting concurrency clock values.
461-
// The below implementation which returns the given expression was chosen
462-
// based on the implementation of `smt2_convt::get` in the non-incremental
463-
// smt2 decision procedure.
464-
log.warning()
465-
<< "`get` attempted for unknown symbol, with identifier - \n"
466-
<< symbol_expr->get_identifier() << messaget::eom;
467-
return expr;
468-
}
439+
INVARIANT_WITH_DIAGNOSTICS(
440+
gather_dependent_expressions(expr).empty(),
441+
"Unhandled expression",
442+
irep_pretty_diagnosticst{expr});
443+
444+
INVARIANT(
445+
objects_are_already_tracked(expr, object_map),
446+
"Objects in expressions being read should already be tracked from "
447+
"point of being set/handled.");
448+
descriptor = ::convert_expr_to_smt(
449+
expr,
450+
object_map,
451+
pointer_sizes_map,
452+
object_size_function.make_application,
453+
is_dynamic_object_function.make_application);
469454
}
470455
if(const auto array_type = type_try_dynamic_cast<array_typet>(expr.type()))
471456
{

unit/solvers/smt2_incremental/smt2_incremental_decision_procedure.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -510,26 +510,6 @@ TEST_CASE(
510510
test.sent_commands ==
511511
std::vector<smt_commandt>{smt_get_value_commandt{foo_term}});
512512
}
513-
SECTION("Get value of non-set symbol")
514-
{
515-
// smt2_incremental_decision_proceduret is used this way when cbmc is
516-
// invoked with the combination of `--trace` and `--slice-formula`.
517-
test.sent_commands.clear();
518-
const exprt bar =
519-
make_test_symbol("bar", signedbv_typet{16}).symbol_expr();
520-
REQUIRE(test.procedure.get(bar) == bar);
521-
REQUIRE(test.sent_commands.empty());
522-
}
523-
SECTION("Get value of type less symbol back")
524-
{
525-
// smt2_incremental_decision_proceduret is used this way as part of
526-
// building the goto trace, to get the partial order concurrency clock
527-
// values.
528-
test.sent_commands.clear();
529-
const symbol_exprt baz = symbol_exprt::typeless("baz");
530-
REQUIRE(test.procedure.get(baz) == baz);
531-
REQUIRE(test.sent_commands.empty());
532-
}
533513
SECTION("Get value of trivially solved expression")
534514
{
535515
test.sent_commands.clear();
@@ -542,16 +522,6 @@ TEST_CASE(
542522
test.sent_commands ==
543523
std::vector<smt_commandt>{smt_get_value_commandt{not_true_term}});
544524
}
545-
SECTION("Invariant violated due to expression in unexpected form.")
546-
{
547-
const mult_exprt unexpected{foo.symbol_expr(), from_integer(2, foo.type)};
548-
const cbmc_invariants_should_throwt invariants_throw;
549-
REQUIRE_THROWS_MATCHES(
550-
test.procedure.get(unexpected),
551-
invariant_failedt,
552-
invariant_failure_containing(
553-
"Unhandled expressions are expected to be symbols"));
554-
}
555525
SECTION("Error handling of mismatched response.")
556526
{
557527
test.sent_commands.clear();

0 commit comments

Comments
 (0)