@@ -26,16 +26,24 @@ Author: Daniel Kroening, kroening@kroening.com
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, kroening@kroening.com
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
@@ -252,6 +245,19 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
252245 options.set_option (" trace" , true );
253246 }
254247
248+ if (cmdline.isset (" export-symex-ready-goto" ))
249+ {
250+ options.set_option (
251+ " export-symex-ready-goto" , cmdline.get_value (" export-symex-ready-goto" ));
252+ if (options.get_option (" export-symex-ready-goto" ).empty ())
253+ {
254+ log.error ()
255+ << " ERROR: Please provide a filename to write the goto-binary to."
256+ << messaget::eom;
257+ exit (CPROVER_EXIT_INTERNAL_ERROR);
258+ }
259+ }
260+
255261 if (cmdline.isset (" localize-faults" ))
256262 options.set_option (" localize-faults" , true );
257263
@@ -553,6 +559,31 @@ int cbmc_parse_optionst::doit()
553559 if (set_properties ())
554560 return CPROVER_EXIT_SET_PROPERTIES_FAILED;
555561
562+ // At this point, our goto-model should be in symex-ready-goto form (all of
563+ // the transformations have been run and the program is ready to be given
564+ // to the solver).
565+ if (options.is_set (" export-symex-ready-goto" ))
566+ {
567+ auto symex_ready_goto_filename =
568+ options.get_option (" export-symex-ready-goto" );
569+
570+ bool success = !write_goto_binary (
571+ symex_ready_goto_filename, goto_model, ui_message_handler);
572+
573+ if (!success)
574+ {
575+ log.error () << " ERROR: Unable to export goto-program in file "
576+ << symex_ready_goto_filename << messaget::eom;
577+ return CPROVER_EXIT_INTERNAL_ERROR;
578+ }
579+ else
580+ {
581+ log.status () << " Exported goto-program in symex-ready-goto form at "
582+ << symex_ready_goto_filename << messaget::eom;
583+ return CPROVER_EXIT_SUCCESS;
584+ }
585+ }
586+
556587 if (
557588 options.get_bool_option (" program-only" ) ||
558589 options.get_bool_option (" show-vcc" ) ||
@@ -937,6 +968,7 @@ void cbmc_parse_optionst::help()
937968 " --show-symbol-table show loaded symbol table\n "
938969 HELP_SHOW_GOTO_FUNCTIONS
939970 HELP_VALIDATE
971+ " --export-symex-ready-goto f serialise goto-program in symex-ready-goto form in f\n " // NOLINT(*)
940972 " \n "
941973 " Program instrumentation options:\n "
942974 HELP_GOTO_CHECK
0 commit comments