@@ -45,6 +45,17 @@ void bmct::do_unwind_module()
45
45
// this is a hook for hw-cbmc
46
46
}
47
47
48
+ // / Hook used by CEGIS to selectively freeze variables
49
+ // / in the SAT solver after the SSA formula is added to the solver.
50
+ // / Freezing variables is necessary to make use of incremental
51
+ // / solving with MiniSat SimpSolver.
52
+ // / Potentially a useful hook for other applications using
53
+ // / incremental solving.
54
+ void bmct::freeze_program_variables ()
55
+ {
56
+ // this is a hook for cegis
57
+ }
58
+
48
59
void bmct::error_trace ()
49
60
{
50
61
status () << " Building error trace" << eom;
@@ -131,6 +142,8 @@ void bmct::do_conversion()
131
142
forall_expr_list (it, bmc_constraints)
132
143
prop_conv.set_to_true (*it);
133
144
}
145
+ // hook for cegis to freeze synthesis program vars
146
+ freeze_program_variables ();
134
147
}
135
148
136
149
decision_proceduret::resultt
@@ -305,11 +318,10 @@ void bmct::show_program()
305
318
}
306
319
}
307
320
308
- safety_checkert::resultt bmct::run (
309
- const goto_functionst &goto_functions )
321
+
322
+ void bmct::get_memory_model ( )
310
323
{
311
324
const std::string mm=options.get_option (" mm" );
312
- std::unique_ptr<memory_model_baset> memory_model;
313
325
314
326
if (mm.empty () || mm==" sc" )
315
327
memory_model=util_make_unique<memory_model_sct>(ns);
@@ -321,9 +333,13 @@ safety_checkert::resultt bmct::run(
321
333
{
322
334
error () << " Invalid memory model " << mm
323
335
<< " -- use one of sc, tso, pso" << eom;
324
- return safety_checkert::resultt::ERROR ;
336
+ throw " invalid memory model " ;
325
337
}
338
+ }
326
339
340
+ void bmct::setup ()
341
+ {
342
+ get_memory_model ();
327
343
symex.set_message_handler (get_message_handler ());
328
344
symex.options =options;
329
345
@@ -337,11 +353,13 @@ safety_checkert::resultt bmct::run(
337
353
338
354
symex.last_source_location .make_nil ();
339
355
340
- try
341
- {
342
- // get unwinding info
343
356
setup_unwind ();
357
+ }
344
358
359
+ safety_checkert::resultt bmct::execute (const goto_functionst &goto_functions)
360
+ {
361
+ try
362
+ {
345
363
// perform symbolic execution
346
364
symex (goto_functions);
347
365
@@ -351,77 +369,12 @@ safety_checkert::resultt bmct::run(
351
369
memory_model->set_message_handler (get_message_handler ());
352
370
(*memory_model)(equation);
353
371
}
354
- }
355
-
356
- catch (const std::string &error_str)
357
- {
358
- messaget message (get_message_handler ());
359
- message.error ().source_location =symex.last_source_location ;
360
- message.error () << error_str << messaget::eom;
361
-
362
- return safety_checkert::resultt::ERROR;
363
- }
364
-
365
- catch (const char *error_str)
366
- {
367
- messaget message (get_message_handler ());
368
- message.error ().source_location =symex.last_source_location ;
369
- message.error () << error_str << messaget::eom;
370
-
371
- return safety_checkert::resultt::ERROR;
372
- }
373
-
374
- catch (const std::bad_alloc &)
375
- {
376
- error () << " Out of memory" << eom;
377
- return safety_checkert::resultt::ERROR;
378
- }
379
372
380
373
statistics () << " size of program expression: "
381
374
<< equation.SSA_steps .size ()
382
375
<< " steps" << eom;
383
376
384
- try
385
- {
386
- if (options.get_option (" slice-by-trace" )!=" " )
387
- {
388
- symex_slice_by_tracet symex_slice_by_trace (ns);
389
-
390
- symex_slice_by_trace.slice_by_trace
391
- (options.get_option (" slice-by-trace" ), equation);
392
- }
393
-
394
- if (equation.has_threads ())
395
- {
396
- // we should build a thread-aware SSA slicer
397
- statistics () << " no slicing due to threads" << eom;
398
- }
399
- else
400
- {
401
- if (options.get_bool_option (" slice-formula" ))
402
- {
403
- slice (equation);
404
- statistics () << " slicing removed "
405
- << equation.count_ignored_SSA_steps ()
406
- << " assignments" << eom;
407
- }
408
- else
409
- {
410
- if (options.get_list_option (" cover" ).empty ())
411
- {
412
- simple_slice (equation);
413
- statistics () << " simple slicing removed "
414
- << equation.count_ignored_SSA_steps ()
415
- << " assignments" << eom;
416
- }
417
- }
418
- }
419
-
420
- {
421
- statistics () << " Generated " << symex.total_vccs
422
- << " VCC(s), " << symex.remaining_vccs
423
- << " remaining after simplification" << eom;
424
- }
377
+ slice ();
425
378
426
379
// coverage report
427
380
std::string cov_out=options.get_option (" symex-coverage-report" );
@@ -473,13 +426,19 @@ safety_checkert::resultt bmct::run(
473
426
474
427
catch (const std::string &error_str)
475
428
{
476
- error () << error_str << eom;
429
+ messaget message (get_message_handler ());
430
+ message.error ().source_location =symex.last_source_location ;
431
+ message.error () << error_str << messaget::eom;
432
+
477
433
return safety_checkert::resultt::ERROR;
478
434
}
479
435
480
436
catch (const char *error_str)
481
437
{
482
- error () << error_str << eom;
438
+ messaget message (get_message_handler ());
439
+ message.error ().source_location =symex.last_source_location ;
440
+ message.error () << error_str << messaget::eom;
441
+
483
442
return safety_checkert::resultt::ERROR;
484
443
}
485
444
@@ -490,6 +449,56 @@ safety_checkert::resultt bmct::run(
490
449
}
491
450
}
492
451
452
+ void bmct::slice ()
453
+ {
454
+ if (options.get_option (" slice-by-trace" )!=" " )
455
+ {
456
+ symex_slice_by_tracet symex_slice_by_trace (ns);
457
+
458
+ symex_slice_by_trace.slice_by_trace
459
+ (options.get_option (" slice-by-trace" ),
460
+ equation);
461
+ }
462
+ // any properties to check at all?
463
+ if (equation.has_threads ())
464
+ {
465
+ // we should build a thread-aware SSA slicer
466
+ statistics () << " no slicing due to threads" << eom;
467
+ }
468
+ else
469
+ {
470
+ if (options.get_bool_option (" slice-formula" ))
471
+ {
472
+ ::slice (equation);
473
+ statistics () << " slicing removed "
474
+ << equation.count_ignored_SSA_steps ()
475
+ << " assignments" <<eom;
476
+ }
477
+ else
478
+ {
479
+ if (options.get_list_option (" cover" ).empty ())
480
+ {
481
+ simple_slice (equation);
482
+ statistics () << " simple slicing removed "
483
+ << equation.count_ignored_SSA_steps ()
484
+ << " assignments" <<eom;
485
+ }
486
+ }
487
+ }
488
+ statistics () << " Generated "
489
+ << symex.total_vccs <<" VCC(s), "
490
+ << symex.remaining_vccs
491
+ << " remaining after simplification" << eom;
492
+ }
493
+
494
+ safety_checkert::resultt bmct::run (
495
+ const goto_functionst &goto_functions)
496
+ {
497
+ setup ();
498
+
499
+ return execute (goto_functions);
500
+ }
501
+
493
502
safety_checkert::resultt bmct::decide (
494
503
const goto_functionst &goto_functions,
495
504
prop_convt &prop_conv)
@@ -502,6 +511,19 @@ safety_checkert::resultt bmct::decide(
502
511
return all_properties (goto_functions, prop_conv);
503
512
}
504
513
514
+ void bmct::show (const goto_functionst &goto_functions)
515
+ {
516
+ if (options.get_bool_option (" show-vcc" ))
517
+ {
518
+ show_vcc ();
519
+ }
520
+
521
+ if (options.get_bool_option (" program-only" ))
522
+ {
523
+ show_program ();
524
+ }
525
+ }
526
+
505
527
safety_checkert::resultt bmct::stop_on_fail (
506
528
const goto_functionst &goto_functions,
507
529
prop_convt &prop_conv)
0 commit comments