@@ -305,11 +305,10 @@ void bmct::show_program()
305
305
}
306
306
}
307
307
308
- safety_checkert::resultt bmct::run (
309
- const goto_functionst &goto_functions )
308
+
309
+ void bmct::get_memory_model ( )
310
310
{
311
311
const std::string mm=options.get_option (" mm" );
312
- std::unique_ptr<memory_model_baset> memory_model;
313
312
314
313
if (mm.empty () || mm==" sc" )
315
314
memory_model=util_make_unique<memory_model_sct>(ns);
@@ -321,9 +320,13 @@ safety_checkert::resultt bmct::run(
321
320
{
322
321
error () << " Invalid memory model " << mm
323
322
<< " -- use one of sc, tso, pso" << eom;
324
- return safety_checkert::resultt::ERROR ;
323
+ throw " invalid memory model " ;
325
324
}
325
+ }
326
326
327
+ void bmct::setup ()
328
+ {
329
+ get_memory_model ();
327
330
symex.set_message_handler (get_message_handler ());
328
331
symex.options =options;
329
332
@@ -337,11 +340,13 @@ safety_checkert::resultt bmct::run(
337
340
338
341
symex.last_source_location .make_nil ();
339
342
340
- try
341
- {
342
- // get unwinding info
343
343
setup_unwind ();
344
+ }
344
345
346
+ safety_checkert::resultt bmct::execute (const goto_functionst &goto_functions)
347
+ {
348
+ try
349
+ {
345
350
// perform symbolic execution
346
351
symex (goto_functions);
347
352
@@ -351,77 +356,12 @@ safety_checkert::resultt bmct::run(
351
356
memory_model->set_message_handler (get_message_handler ());
352
357
(*memory_model)(equation);
353
358
}
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
359
380
360
statistics () << " size of program expression: "
381
361
<< equation.SSA_steps .size ()
382
362
<< " steps" << eom;
383
363
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
- }
364
+ slice ();
425
365
426
366
// coverage report
427
367
std::string cov_out=options.get_option (" symex-coverage-report" );
@@ -473,13 +413,19 @@ safety_checkert::resultt bmct::run(
473
413
474
414
catch (const std::string &error_str)
475
415
{
476
- error () << error_str << eom;
416
+ messaget message (get_message_handler ());
417
+ message.error ().source_location =symex.last_source_location ;
418
+ message.error () << error_str << messaget::eom;
419
+
477
420
return safety_checkert::resultt::ERROR;
478
421
}
479
422
480
423
catch (const char *error_str)
481
424
{
482
- error () << error_str << eom;
425
+ messaget message (get_message_handler ());
426
+ message.error ().source_location =symex.last_source_location ;
427
+ message.error () << error_str << messaget::eom;
428
+
483
429
return safety_checkert::resultt::ERROR;
484
430
}
485
431
@@ -490,6 +436,56 @@ safety_checkert::resultt bmct::run(
490
436
}
491
437
}
492
438
439
+ void bmct::slice ()
440
+ {
441
+ if (options.get_option (" slice-by-trace" )!=" " )
442
+ {
443
+ symex_slice_by_tracet symex_slice_by_trace (ns);
444
+
445
+ symex_slice_by_trace.slice_by_trace
446
+ (options.get_option (" slice-by-trace" ),
447
+ equation);
448
+ }
449
+ // any properties to check at all?
450
+ if (equation.has_threads ())
451
+ {
452
+ // we should build a thread-aware SSA slicer
453
+ statistics () << " no slicing due to threads" << eom;
454
+ }
455
+ else
456
+ {
457
+ if (options.get_bool_option (" slice-formula" ))
458
+ {
459
+ ::slice (equation);
460
+ statistics () << " slicing removed "
461
+ << equation.count_ignored_SSA_steps ()
462
+ << " assignments" <<eom;
463
+ }
464
+ else
465
+ {
466
+ if (options.get_list_option (" cover" ).empty ())
467
+ {
468
+ simple_slice (equation);
469
+ statistics () << " simple slicing removed "
470
+ << equation.count_ignored_SSA_steps ()
471
+ << " assignments" <<eom;
472
+ }
473
+ }
474
+ }
475
+ statistics () << " Generated "
476
+ << symex.total_vccs <<" VCC(s), "
477
+ << symex.remaining_vccs
478
+ << " remaining after simplification" << eom;
479
+ }
480
+
481
+ safety_checkert::resultt bmct::run (
482
+ const goto_functionst &goto_functions)
483
+ {
484
+ setup ();
485
+
486
+ return execute (goto_functions);
487
+ }
488
+
493
489
safety_checkert::resultt bmct::decide (
494
490
const goto_functionst &goto_functions,
495
491
prop_convt &prop_conv)
@@ -502,6 +498,19 @@ safety_checkert::resultt bmct::decide(
502
498
return all_properties (goto_functions, prop_conv);
503
499
}
504
500
501
+ void bmct::show (const goto_functionst &goto_functions)
502
+ {
503
+ if (options.get_bool_option (" show-vcc" ))
504
+ {
505
+ show_vcc ();
506
+ }
507
+
508
+ if (options.get_bool_option (" program-only" ))
509
+ {
510
+ show_program ();
511
+ }
512
+ }
513
+
505
514
safety_checkert::resultt bmct::stop_on_fail (
506
515
const goto_functionst &goto_functions,
507
516
prop_convt &prop_conv)
0 commit comments