123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190(* Time-stamp: <modified the 30/06/2021 (at 10:22) by Erwan Jahier> *)letrdbg_tuning_file="my-rdbg-tuning.ml"letrdbg_cmds_file="rdbg-cmds.ml"letpversion()=Printf.fprintfstdout"%s (%s)\n"RdbgVersion.strRdbgVersion.sha;flushstdout;exit0(* exported *)letverbose=reffalseletlurette=reffalseletocamldebug=reffalseletsuts=ref[]letenvs=ref[]letoracles=ref[]letsuts_nd=ref[]letenvs_nd=ref[]letoracles_nd=ref[]lettest_length=ref100letmissing_vars_at_the_end=reffalseletoutput_file=(* what is the better default name ?? *)ref(Filename.basename(Sys.getcwd())^".rif")letinput_file=refNoneletno_rif=reffalseletoverwrite_output=reffalseletdrdbg=reffalseletgo=reffalseletoptions=ref[]letoptions_more=ref[]letarg_options=ref[]letemacs_mode=reffalseletdisplay_gnuplot=reffalseletdisplay_sim2chro=reffalseletdont_stop_on_oracle_error=reffalseletlog=reftrueletcov_file=ref"lurette.cov"letreset_cov_file=reffalseletluciole_mode=reffalseletsasa_mode=reffalseletsalut_mode=reffalseletcmd=ref""letmargin=ref6letusage=ref""letpspecos(c,ml)=(let(m1,oth)=matchmlwith|h::t->(h,t)|_->("",[])inlett2=String.make!margin' 'inletcl=String.lengthcinlett1=if(cl<!margin)thenString.make(!margin-cl)' 'else"\n"^t2inPrintf.fprintfos"%s%s%s"ct1m1;List.iter(functionx->Printf.fprintfos"\n%s%s"t2x)oth;Printf.fprintfos"\n";)lethelp()=letl=List.rev!optionsinPrintf.fprintfstdout"%s\n\n"!usage;List.iter(pspecstdout)l;exit0letmore()=letl=List.rev!options_moreinList.iter(pspecstdout)l;exit0typeopt_cat=Main|More|Lurettelet(mkopt:stringlist->?cat:opt_cat->?arg:string->Arg.spec->stringlist->unit)=funol?(cat=Main)?(arg="")seml->ifcat=Lurettethen()(* some args are meaningless from lurette *)elselettretoo=arg_options:=(o,se,"")::!arg_optionsinList.itertretool;letopt_str=(String.concat", "ol)^arginifcat=Mainthenoptions:=(opt_str,ml)::!optionselseoptions_more:=(opt_str,ml)::!options_morelet(mkoptab:unit->unit)=fun()->mkopt["-sut";"--sut"]~arg:" <string>"(Arg.String(funstr->(suts:=str::!suts)))["Add a sut "];mkopt["-sut-nd";"--sut-nd"]~arg:" <string>"(Arg.String(funstr->(suts_nd:=str::!suts_nd)))["Add a sut, but don't debug it"];mkopt["-env";"--env"]~arg:" <string>"(Arg.String(funstr->(envs:=str::!envs)))["Add an env"];mkopt["-env-nd";"--env-nd"]~arg:" <string>"(Arg.String(funstr->(envs_nd:=str::!envs_nd)))["Add an env, but don't debug it"];mkopt["-oracle";"--oracle"]~arg:" <string>"(Arg.String(funstr->(oracles:=str::!oracles)))["Add an oracle"];mkopt["-oracle-nd";"--oracle-nd"]~arg:" <string>"(Arg.String(funstr->(oracles_nd:=str::!oracles_nd)))["Add an oracle, but don't debug it"];mkopt["-lurette";"--lurette"]~cat:(if!lurettethenLuretteelseMain)(Arg.Unit(fun_->(lurette:=true)))["Use the lurette mode (i.e., runs everything without debugging)"];mkopt["-ocd";"--ocamldebug"]~cat:More(Arg.Unit(fun_->(lurette:=true;ocamldebug:=true)))["Run in lurette mode, but under the control of ocamldebug"];mkopt["-g";"--gnuplot"]~cat:More(Arg.Unit(fun()->display_gnuplot:=true))["in lurette mode only: Launch gnuplot to visualize the generated rif file"];mkopt["-s";"--sim2chro"]~cat:More(Arg.Unit(fun()->display_sim2chro:=true))["in lurette mode only: Launch sim2chro to visualize the generated rif file"];mkopt["-l";"--test-length";"--step-number"]~arg:" <int>"(Arg.Int(funi->(test_length:=i)))["in lurette mode only: Set test length (step number)"];mkopt["--missing-vars-last"]~cat:More(Arg.Unit(fun()->(missing_vars_at_the_end:=true)))["Launch the missing variables process (luciole or stdin) in last (i.e., after env, and sut)"];mkopt["--luciole"]~cat:More(Arg.Unit(fun()->(luciole_mode:=true)))["Launch luciole when variables are missing (stdin is used otherwise)"];mkopt["--sasa"]~cat:More(Arg.Unit(fun()->(sasa_mode:=true)))["Tell rdbg that one RP comes from sasa"];mkopt["--salut"]~cat:More(Arg.Unit(fun()->(salut_mode:=true)))["Tell rdbg that one RP comes from salut"];mkopt["-o";"-output";"--output";"-rif";"--rif"]~arg:" <string>"(Arg.String(funs->output_file:=s))["Set the output file name (currently, \""^!output_file^"\")"];mkopt["-in";"--input"]~cat:More(Arg.String(funstr->input_file:=Somestr))["Read rdbg command in a file and exits"];mkopt["-norif";"--no-rif"]~cat:More(Arg.Unit(fun()->no_rif:=true))["Do not print data in the rif file (useful when there are too many variables)";"nb: inhibits --sim2chro (which is fine when there are too many variables)"];mkopt["-orf";"--overwrite-rif-file"]~cat:More(Arg.Unit(fun()->overwrite_output:=true))["Overwrite \""^!output_file^"\" if it exists without trying to invent a new name"];mkopt["-dsoe";"--dont-stop-on-oracle-error"]~cat:More(Arg.Unit(fun_->dont_stop_on_oracle_error:=true))["Do not stop if one oracle is violated"];mkopt["-cv";"--cov-file"]~cat:More~arg:" <string>"(Arg.String(funs->cov_file:=s))["file name coverage info will be put into"];mkopt["-rcv";"--reset-cov-file"]~cat:More(Arg.Unit(fun_->reset_cov_file:=true))["Reset coverage file data"];mkopt["-no-log";"--no-log"]~cat:More(Arg.Unit(fun_->log:=false))["Do no generate a rdbg.log file and output everything on stdout"];mkopt["-e";"-emacs";"--emacs"]~cat:(if!lurettethenLuretteelseMain)(Arg.Unit(fun()->emacs_mode:=true))["Use emacs to open appropriate buffers while debugging"];mkopt["-v";"-verbose";"--verbose"]~cat:More(Arg.Unit(fun_->(verbose:=true)))["Echo the commands sent to rdbg-top"];mkopt["--debug"]~cat:More(Arg.Unit(fun()->drdbg:=true))["set on a verbose mode to (try to) understand what's going on"];mkopt["--ocaml-cmd";"-cmd"]~cat:More(Arg.String(funstr->cmd:=!cmd^str^"\n"))["Ocaml code to run before the session starts"];mkopt["-go"]~cat:More(Arg.Unit(fun()->go:=true))["just run, without session prompt"];mkopt["-h";"-help";"--help"](Arg.Unithelp)["Display this help message"];mkopt["-m";"-more";"--more"](Arg.Unitmore)["Display more options"];mkopt["--ocaml-version"]~cat:(if!lurettethenLuretteelseMore)(Arg.Unit(fun()->print_string(Sys.ocaml_version);flushstdout;exit0))["Print the current ocaml version it was compiled with and exit"];mkopt["-version";"--version"]~cat:More(Arg.Unit(pversion))["Print the current version and exit"]