22
22
#include < util/unicode.h>
23
23
#include < util/memory_info.h>
24
24
#include < util/invariant.h>
25
+ #include < util/exit_codes.h>
25
26
26
27
#include < ansi-c/c_preprocess.h>
27
28
@@ -106,7 +107,7 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
106
107
if (config.set (cmdline))
107
108
{
108
109
usage_error ();
109
- exit (1 ); // should contemplate EX_USAGE from sysexits.h
110
+ exit (CPROVER_EXIT_USAGE_ERROR);
110
111
}
111
112
112
113
if (cmdline.isset (" program-only" ))
@@ -224,7 +225,7 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
224
225
{
225
226
error () << " --partial-loops and --unwinding-assertions "
226
227
<< " must not be given together" << eom;
227
- exit (1 ); // should contemplate EX_USAGE from sysexits.h
228
+ exit (CPROVER_EXIT_USAGE_ERROR);
228
229
}
229
230
230
231
// remove unused equations
@@ -415,7 +416,7 @@ int cbmc_parse_optionst::doit()
415
416
if (cmdline.isset (" version" ))
416
417
{
417
418
std::cout << CBMC_VERSION << ' \n ' ;
418
- return 0 ; // should contemplate EX_OK from sysexits.h
419
+ return CPROVER_EXIT_SUCCESS;
419
420
}
420
421
421
422
//
@@ -431,13 +432,13 @@ int cbmc_parse_optionst::doit()
431
432
catch (const char *error_msg)
432
433
{
433
434
error () << error_msg << eom;
434
- return 6 ; // should contemplate EX_SOFTWARE from sysexits.h
435
+ return CPROVER_EXIT_EXCEPTION;
435
436
}
436
437
437
438
catch (const std::string error_msg)
438
439
{
439
440
error () << error_msg << eom;
440
- return 6 ; // should contemplate EX_SOFTWARE from sysexits.h
441
+ return CPROVER_EXIT_EXCEPTION;
441
442
}
442
443
443
444
eval_verbosity ();
@@ -459,18 +460,20 @@ int cbmc_parse_optionst::doit()
459
460
{
460
461
error () << " This version of CBMC has no support for "
461
462
" hardware modules. Please use hw-cbmc." << eom;
462
- return 1 ; // should contemplate EX_USAGE from sysexits.h
463
+ return CPROVER_EXIT_USAGE_ERROR;
463
464
}
464
465
465
466
register_languages ();
466
467
467
468
if (cmdline.isset (" test-preprocessor" ))
468
- return test_c_preprocessor (get_message_handler ())?8 :0 ;
469
+ return test_c_preprocessor (get_message_handler ())
470
+ ? CPROVER_EXIT_PREPROCESSOR_TEST_FAILED
471
+ : CPROVER_EXIT_SUCCESS;
469
472
470
473
if (cmdline.isset (" preprocess" ))
471
474
{
472
475
preprocessing ();
473
- return 0 ; // should contemplate EX_OK from sysexits.h
476
+ return CPROVER_EXIT_SUCCESS;
474
477
}
475
478
476
479
if (cmdline.isset (" show-parse-tree" ))
@@ -479,7 +482,7 @@ int cbmc_parse_optionst::doit()
479
482
is_goto_binary (cmdline.args [0 ]))
480
483
{
481
484
error () << " Please give exactly one source file" << eom;
482
- return 6 ;
485
+ return CPROVER_EXIT_INCORRECT_TASK ;
483
486
}
484
487
485
488
std::string filename=cmdline.args [0 ];
@@ -494,7 +497,7 @@ int cbmc_parse_optionst::doit()
494
497
{
495
498
error () << " failed to open input file `"
496
499
<< filename << " '" << eom;
497
- return 6 ;
500
+ return CPROVER_EXIT_INCORRECT_TASK ;
498
501
}
499
502
500
503
std::unique_ptr<languaget> language=
@@ -504,7 +507,7 @@ int cbmc_parse_optionst::doit()
504
507
{
505
508
error () << " failed to figure out type of file `"
506
509
<< filename << " '" << eom;
507
- return 6 ;
510
+ return CPROVER_EXIT_INCORRECT_TASK ;
508
511
}
509
512
510
513
language->get_language_options (cmdline);
@@ -515,11 +518,11 @@ int cbmc_parse_optionst::doit()
515
518
if (language->parse (infile, filename))
516
519
{
517
520
error () << " PARSING ERROR" << eom;
518
- return 6 ;
521
+ return CPROVER_EXIT_INCORRECT_TASK ;
519
522
}
520
523
521
524
language->show_parse (std::cout);
522
- return 0 ;
525
+ return CPROVER_EXIT_SUCCESS ;
523
526
}
524
527
525
528
int get_goto_program_ret=get_goto_program (options);
@@ -531,11 +534,11 @@ int cbmc_parse_optionst::doit()
531
534
cmdline.isset (" show-properties" )) // use this one
532
535
{
533
536
show_properties (goto_model, ui_message_handler.get_ui ());
534
- return 0 ; // should contemplate EX_OK from sysexits.h
537
+ return CPROVER_EXIT_SUCCESS;
535
538
}
536
539
537
540
if (set_properties ())
538
- return 7 ; // should contemplate EX_USAGE from sysexits.h
541
+ return CPROVER_EXIT_SET_PROPERTIES_FAILED;
539
542
540
543
// get solver
541
544
cbmc_solverst cbmc_solvers (
@@ -554,7 +557,7 @@ int cbmc_parse_optionst::doit()
554
557
catch (const char *error_msg)
555
558
{
556
559
error () << error_msg << eom;
557
- return 1 ; // should contemplate EX_SOFTWARE from sysexits.h
560
+ return CPROVER_EXIT_USAGE_ERROR ; // should contemplate EX_SOFTWARE from sysexits.h
558
561
}
559
562
560
563
prop_convt &prop_conv=cbmc_solver->prop_conv ();
@@ -606,7 +609,7 @@ int cbmc_parse_optionst::get_goto_program(
606
609
if (cmdline.args .empty ())
607
610
{
608
611
error () << " Please provide a program to verify" << eom;
609
- return 6 ;
612
+ return CPROVER_EXIT_INCORRECT_TASK ;
610
613
}
611
614
612
615
try
@@ -616,24 +619,24 @@ int cbmc_parse_optionst::get_goto_program(
616
619
if (cmdline.isset (" show-symbol-table" ))
617
620
{
618
621
show_symbol_table (goto_model, ui_message_handler.get_ui ());
619
- return 0 ;
622
+ return CPROVER_EXIT_SUCCESS ;
620
623
}
621
624
622
625
if (process_goto_program (options))
623
- return 6 ;
626
+ return CPROVER_EXIT_INTERNAL_ERROR ;
624
627
625
628
// show it?
626
629
if (cmdline.isset (" show-loops" ))
627
630
{
628
631
show_loop_ids (ui_message_handler.get_ui (), goto_model);
629
- return 0 ;
632
+ return CPROVER_EXIT_SUCCESS ;
630
633
}
631
634
632
635
// show it?
633
636
if (cmdline.isset (" show-goto-functions" ))
634
637
{
635
638
show_goto_functions (goto_model, ui_message_handler.get_ui ());
636
- return 0 ;
639
+ return CPROVER_EXIT_SUCCESS ;
637
640
}
638
641
639
642
status () << config.object_bits_info () << eom;
@@ -642,24 +645,24 @@ int cbmc_parse_optionst::get_goto_program(
642
645
catch (const char *e)
643
646
{
644
647
error () << e << eom;
645
- return 6 ;
648
+ return CPROVER_EXIT_EXCEPTION ;
646
649
}
647
650
648
651
catch (const std::string e)
649
652
{
650
653
error () << e << eom;
651
- return 6 ;
654
+ return CPROVER_EXIT_EXCEPTION ;
652
655
}
653
656
654
657
catch (int )
655
658
{
656
- return 6 ;
659
+ return CPROVER_EXIT_EXCEPTION ;
657
660
}
658
661
659
662
catch (std::bad_alloc)
660
663
{
661
664
error () << " Out of memory" << eom;
662
- return 6 ;
665
+ return CPROVER_EXIT_INTERNAL_OUT_OF_MEMORY ;
663
666
}
664
667
665
668
return -1 ; // no error, continue
@@ -862,19 +865,19 @@ int cbmc_parse_optionst::do_bmc(bmct &bmc)
862
865
{
863
866
bmc.set_ui (ui_message_handler.get_ui ());
864
867
865
- int result= 6 ;
868
+ int result = CPROVER_EXIT_INTERNAL_ERROR ;
866
869
867
870
// do actual BMC
868
871
switch (bmc.run (goto_model.goto_functions ))
869
872
{
870
873
case safety_checkert::resultt::SAFE:
871
- result= 0 ;
874
+ result = CPROVER_EXIT_VERIFICATION_SAFE ;
872
875
break ;
873
876
case safety_checkert::resultt::UNSAFE:
874
- result= 10 ;
877
+ result = CPROVER_EXIT_VERIFICATION_UNSAFE ;
875
878
break ;
876
879
case safety_checkert::resultt::ERROR:
877
- result= 6 ;
880
+ result = CPROVER_EXIT_INTERNAL_ERROR ;
878
881
break ;
879
882
}
880
883
0 commit comments