Skip to content

Commit 2e26d15

Browse files
committed
goto_instrument_parse_options: refactor and add new option
1 parent c589b9e commit 2e26d15

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Author: Daniel Kroening, [email protected]
1414
#include <fstream>
1515
#include <iostream>
1616
#include <memory>
17+
#include <sstream>
1718

1819
#include <util/config.h>
1920
#include <util/exception_utils.h>
@@ -96,7 +97,6 @@ Author: Daniel Kroening, [email protected]
9697
#include "interrupt.h"
9798
#include "k_induction.h"
9899
#include "mmio.h"
99-
#include "model_argc_argv.h"
100100
#include "nondet_static.h"
101101
#include "nondet_volatile.h"
102102
#include "points_to.h"
@@ -1054,10 +1054,38 @@ void goto_instrument_parse_optionst::instrument_goto_program()
10541054
{
10551055
unsigned max_argc=
10561056
safe_string2unsigned(cmdline.get_value("model-argc-argv"));
1057+
std::list<std::string> argv;
1058+
argv.resize(max_argc);
10571059

10581060
log.status() << "Adding up to " << max_argc << " command line arguments"
10591061
<< messaget::eom;
1060-
if(model_argc_argv(goto_model, max_argc, ui_message_handler))
1062+
1063+
if(model_argc_argv(
1064+
goto_model, argv, true /*model_argv*/, ui_message_handler))
1065+
throw 0;
1066+
}
1067+
1068+
if(cmdline.isset("add-cmd-line-arg"))
1069+
{
1070+
const std::list<std::string> &argv = cmdline.get_values("add-cmd-line-arg");
1071+
unsigned argc = 0;
1072+
1073+
std::stringstream ss;
1074+
ss << "[";
1075+
std::string sep = "";
1076+
for(auto const &arg : argv)
1077+
{
1078+
ss << sep << "\"" << arg << "\"";
1079+
argc++;
1080+
sep = ", ";
1081+
}
1082+
ss << "]";
1083+
1084+
log.status() << "Adding " << argc << " arguments: " << ss.str()
1085+
<< messaget::eom;
1086+
1087+
if(model_argc_argv(
1088+
goto_model, argv, false /*model_argv*/, ui_message_handler))
10611089
throw 0;
10621090
}
10631091

@@ -1842,7 +1870,7 @@ void goto_instrument_parse_optionst::help()
18421870
HELP_REMOVE_CALLS_NO_BODY
18431871
HELP_REMOVE_CONST_FUNCTION_POINTERS
18441872
" --add-library add models of C library functions\n"
1845-
" --model-argc-argv <n> model up to <n> command line arguments\n"
1873+
HELP_ARGC_ARGV
18461874
// NOLINTNEXTLINE(whitespace/line_length)
18471875
" --remove-function-body <f> remove the implementation of function <f> (may be repeated)\n"
18481876
HELP_REPLACE_CALLS

src/goto-instrument/goto_instrument_parse_options.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Author: Daniel Kroening, [email protected]
3232
#include "contracts/contracts.h"
3333
#include "generate_function_bodies.h"
3434
#include "insert_final_assert_false.h"
35+
#include "model_argc_argv.h"
3536
#include "nondet_volatile.h"
3637
#include "replace_calls.h"
3738

@@ -98,7 +99,8 @@ Author: Daniel Kroening, [email protected]
9899
"(interpreter)(show-reaching-definitions)" \
99100
"(list-symbols)(list-undefined-functions)" \
100101
"(z3)(add-library)(show-dependence-graph)" \
101-
"(horn)(skip-loops):(model-argc-argv):" \
102+
"(horn)(skip-loops):" \
103+
OPT_ARGC_ARGV \
102104
"(" FLAG_LOOP_CONTRACTS ")" \
103105
"(" FLAG_REPLACE_CALL "):" \
104106
"(" FLAG_ENFORCE_CONTRACT "):" \

0 commit comments

Comments
 (0)