Skip to content

Commit b821fc0

Browse files
committed
Add capability to export goto-program in core-goto form to CBMC.
This allows CBMC to dump the goto-program when it is in core-goto form in a file on disk (when it is just before SYMEX, and all transformations have been applied).
1 parent b3049b1 commit b821fc0

File tree

2 files changed

+36
-21
lines changed

2 files changed

+36
-21
lines changed

src/cbmc/cbmc_parse_options.cpp

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,24 @@ Author: Daniel Kroening, [email protected]
2626
# include <util/unicode.h>
2727
#endif
2828

29-
#include <langapi/language.h>
29+
#include <goto-programs/initialize_goto_model.h>
30+
#include <goto-programs/link_to_library.h>
31+
#include <goto-programs/loop_ids.h>
32+
#include <goto-programs/process_goto_program.h>
33+
#include <goto-programs/read_goto_binary.h>
34+
#include <goto-programs/remove_skip.h>
35+
#include <goto-programs/remove_unused_functions.h>
36+
#include <goto-programs/set_properties.h>
37+
#include <goto-programs/show_goto_functions.h>
38+
#include <goto-programs/show_properties.h>
39+
#include <goto-programs/show_symbol_table.h>
40+
#include <goto-programs/write_goto_binary.h>
3041

3142
#include <ansi-c/c_preprocess.h>
3243
#include <ansi-c/cprover_library.h>
3344
#include <ansi-c/gcc_version.h>
34-
3545
#include <assembler/remove_asm.h>
36-
3746
#include <cpp/cprover_library.h>
38-
3947
#include <goto-checker/all_properties_verifier.h>
4048
#include <goto-checker/all_properties_verifier_with_fault_localization.h>
4149
#include <goto-checker/all_properties_verifier_with_trace_storage.h>
@@ -49,29 +57,14 @@ Author: Daniel Kroening, [email protected]
4957
#include <goto-checker/single_path_symex_only_checker.h>
5058
#include <goto-checker/stop_on_fail_verifier.h>
5159
#include <goto-checker/stop_on_fail_verifier_with_fault_localization.h>
52-
53-
#include <goto-programs/initialize_goto_model.h>
54-
#include <goto-programs/link_to_library.h>
55-
#include <goto-programs/loop_ids.h>
56-
#include <goto-programs/process_goto_program.h>
57-
#include <goto-programs/read_goto_binary.h>
58-
#include <goto-programs/remove_skip.h>
59-
#include <goto-programs/remove_unused_functions.h>
60-
#include <goto-programs/set_properties.h>
61-
#include <goto-programs/show_goto_functions.h>
62-
#include <goto-programs/show_properties.h>
63-
#include <goto-programs/show_symbol_table.h>
64-
6560
#include <goto-instrument/cover.h>
6661
#include <goto-instrument/full_slicer.h>
6762
#include <goto-instrument/nondet_static.h>
6863
#include <goto-instrument/reachability_slicer.h>
69-
7064
#include <goto-symex/path_storage.h>
71-
72-
#include <pointer-analysis/add_failed_symbols.h>
73-
65+
#include <langapi/language.h>
7466
#include <langapi/mode.h>
67+
#include <pointer-analysis/add_failed_symbols.h>
7568

7669
#include "c_test_input_generator.h"
7770

@@ -553,6 +546,26 @@ int cbmc_parse_optionst::doit()
553546
if(set_properties())
554547
return CPROVER_EXIT_SET_PROPERTIES_FAILED;
555548

549+
// At this point, our goto-model should be in core-goto form (all of the
550+
// transformations have been run and the program is ready to be given to the
551+
// solver).
552+
if(cmdline.isset("export-core-goto"))
553+
{
554+
auto core_goto_filename = cmdline.get_value("export-core-goto");
555+
auto success =
556+
!write_goto_binary(core_goto_filename, goto_model, ui_message_handler);
557+
558+
if(!success)
559+
{
560+
log.error() << "Unable to export goto-program in file "
561+
<< core_goto_filename << messaget::eom;
562+
return CPROVER_EXIT_INTERNAL_ERROR;
563+
}
564+
log.status() << "Exported goto-program in core-goto form at "
565+
<< core_goto_filename << messaget::eom;
566+
return CPROVER_EXIT_SUCCESS;
567+
}
568+
556569
if(
557570
options.get_bool_option("program-only") ||
558571
options.get_bool_option("show-vcc") ||
@@ -937,6 +950,7 @@ void cbmc_parse_optionst::help()
937950
" --show-symbol-table show loaded symbol table\n"
938951
HELP_SHOW_GOTO_FUNCTIONS
939952
HELP_VALIDATE
953+
" --export-core-goto f serialise goto-program in core-goto form in f\n" // NOLINT(*)
940954
"\n"
941955
"Program instrumentation options:\n"
942956
HELP_GOTO_CHECK

src/cbmc/cbmc_parse_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class optionst;
5959
"(verbosity):(no-library)" \
6060
"(nondet-static)" \
6161
"(version)" \
62+
"(export-core-goto):" \
6263
OPT_COVER \
6364
"(symex-coverage-report):" \
6465
"(mm):" \

0 commit comments

Comments
 (0)