Skip to content

Commit 6a7b97c

Browse files
authored
Merge pull request #7403 from tautschnig/cleanup/untimed-trace
GOTO trace: no timestamps for single-threaded programs
2 parents 41a3034 + f1a830b commit 6a7b97c

File tree

3 files changed

+15
-28
lines changed

3 files changed

+15
-28
lines changed

src/goto-symex/build_goto_trace.cpp

+4
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+
const 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

+4-14
Original file line numberDiff line numberDiff line change
@@ -477,20 +477,10 @@ exprt smt2_incremental_decision_proceduret::get(const exprt &expr) const
477477
}();
478478
if(!descriptor)
479479
{
480-
if(const auto symbol_expr = expr_try_dynamic_cast<symbol_exprt>(expr))
481-
{
482-
// Note this case is currently expected to be encountered during trace
483-
// generation for -
484-
// * Steps which were removed via --slice-formula.
485-
// * Getting concurrency clock values.
486-
// The below implementation which returns the given expression was chosen
487-
// based on the implementation of `smt2_convt::get` in the non-incremental
488-
// smt2 decision procedure.
489-
log.warning()
490-
<< "`get` attempted for unknown symbol, with identifier - \n"
491-
<< symbol_expr->get_identifier() << messaget::eom;
492-
return expr;
493-
}
480+
INVARIANT_WITH_DIAGNOSTICS(
481+
!can_cast_expr<symbol_exprt>(expr),
482+
"symbol expressions must have a known value",
483+
irep_pretty_diagnosticst{expr});
494484
return build_expr_based_on_getting_operands(expr, *this);
495485
}
496486
if(const auto array_type = type_try_dynamic_cast<array_typet>(expr.type()))

unit/solvers/smt2_incremental/smt2_incremental_decision_procedure.cpp

+7-14
Original file line numberDiff line numberDiff line change
@@ -505,25 +505,18 @@ TEST_CASE(
505505
test.sent_commands ==
506506
std::vector<smt_commandt>{smt_get_value_commandt{foo_term}});
507507
}
508-
SECTION("Get value of non-set symbol")
508+
SECTION("Invariant violation due to non-set symbol")
509509
{
510-
// smt2_incremental_decision_proceduret is used this way when cbmc is
511-
// invoked with the combination of `--trace` and `--slice-formula`.
512510
test.sent_commands.clear();
513511
const exprt bar =
514512
make_test_symbol("bar", signedbv_typet{16}).symbol_expr();
515-
REQUIRE(test.procedure.get(bar) == bar);
516-
REQUIRE(test.sent_commands.empty());
517-
}
518-
SECTION("Get value of type less symbol back")
519-
{
520-
// smt2_incremental_decision_proceduret is used this way as part of
521-
// building the goto trace, to get the partial order concurrency clock
522-
// values.
523-
test.sent_commands.clear();
524-
const symbol_exprt baz = symbol_exprt::typeless("baz");
525-
REQUIRE(test.procedure.get(baz) == baz);
526513
REQUIRE(test.sent_commands.empty());
514+
cbmc_invariants_should_throwt invariants_throw;
515+
REQUIRE_THROWS_MATCHES(
516+
test.procedure.get(bar),
517+
invariant_failedt,
518+
invariant_failure_containing(
519+
"symbol expressions must have a known value"));
527520
}
528521
SECTION("Get value of trivially solved expression")
529522
{

0 commit comments

Comments
 (0)