Skip to content

Commit ab65b86

Browse files
author
kroening
committed
new version from Vincent
git-svn-id: svn+ssh://svn.cprover.org/srv/svn/cbmc/trunk@1854 6afb6bc1-c8e4-404c-8f48-9ae832c5b171
1 parent 68561f6 commit ab65b86

File tree

5 files changed

+628
-485
lines changed

5 files changed

+628
-485
lines changed

src/goto-instrument/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ SRC = main.cpp parseoptions.cpp document_claims.cpp languages.cpp \
55
weak_memory.cpp nondet_volatile.cpp interrupt.cpp \
66
mmio.cpp stack_depth.cpp nondet_static.cpp \
77
cfg_dominators.cpp natural_loops.cpp concurrency.cpp \
8-
is_threaded.cpp dump_c.cpp dot.cpp
8+
dump_c.cpp dot.cpp \
9+
fence.cpp weak_memory.cpp\
10+
event_graph.cpp goto2graph.cpp \
11+
is_threaded.cpp
912

1013
OBJ += ../ansi-c/ansi-c$(LIBEXT) \
1114
../linking/linking$(LIBEXT) \
@@ -18,7 +21,7 @@ OBJ += ../ansi-c/ansi-c$(LIBEXT) \
1821

1922
INCLUDES= -I .. -I ../util
2023

21-
LIBS =
24+
LIBS =
2225

2326
CLEANFILES = goto-instrument$(EXEEXT)
2427

src/goto-instrument/goto2graph.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,11 +920,15 @@ bool instrumentert::is_cfg_spurious(const event_grapht::critical_cyclet& cyc)
920920
this_interleaving.function_map = map;
921921
optionst no_option;
922922
null_message_handlert no_message;
923+
924+
#if 0
923925
bmct bmc(no_option, context, no_message);
924926

925927
bool is_spurious = bmc.run(this_interleaving);
928+
926929
DEBUG_MESSAGE("CFG:"<<is_spurious);
927930
return is_spurious;
931+
#endif
928932
}
929933

930934
/*******************************************************************\

src/goto-instrument/parseoptions.cpp

Lines changed: 95 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ int goto_instrument_parseoptionst::doit()
186186

187187
if(cmdline.isset("interpreter"))
188188
{
189-
status("Starting interpeter");
189+
status("Starting interpreter");
190190
interpreter(context, goto_functions);
191191
return 0;
192192
}
@@ -225,13 +225,11 @@ int goto_instrument_parseoptionst::doit()
225225
return 0;
226226
}
227227

228-
// experimental: print structs
229228
if(cmdline.isset("show-struct-alignment"))
230229
{
231230
print_struct_alignment_problems(context, std::cout);
232231
return 0;
233232
}
234-
// end of experiment
235233

236234
if(cmdline.isset("show-locations"))
237235
{
@@ -426,6 +424,32 @@ void goto_instrument_parseoptionst::instrument_goto_program(
426424
if(cmdline.isset("error-label"))
427425
options.set_option("error-label", cmdline.getval("error-label"));
428426

427+
// unwind loops
428+
if(cmdline.isset("unwind"))
429+
{
430+
status("Unwinding loops");
431+
options.set_option("unwind", cmdline.getval("unwind"));
432+
}
433+
434+
// max number of variables in a cycle (default 0: no max)
435+
if(cmdline.isset("max-var"))
436+
options.set_option("max-var", cmdline.getval("max-var"));
437+
438+
// max number of transition by po (default 0: no limit)
439+
if(cmdline.isset("max-po-trans"))
440+
options.set_option("max-po-trans", cmdline.getval("max-po-trans"));
441+
442+
// strategy of instrumentation
443+
if(cmdline.isset("one-event-per-cycle"))
444+
options.set_option("event-strategy", 1);
445+
else if(cmdline.isset("minimum-interference"))
446+
options.set_option("event-strategy", 2);
447+
else if(cmdline.isset("my-events"))
448+
options.set_option("event-strategy", 3);
449+
else
450+
options.set_option("event-strategy", 0);
451+
452+
429453
namespacet ns(context);
430454

431455
// add generic checks, if needed
@@ -465,7 +489,7 @@ void goto_instrument_parseoptionst::instrument_goto_program(
465489
cmdline.isset("race-check") ||
466490
cmdline.isset("tso") ||
467491
cmdline.isset("pso") ||
468-
cmdline.isset("rso") ||
492+
cmdline.isset("rmo") ||
469493
cmdline.isset("power") ||
470494
cmdline.isset("isr") ||
471495
cmdline.isset("concurrency"))
@@ -506,71 +530,95 @@ void goto_instrument_parseoptionst::instrument_goto_program(
506530
goto_functions);
507531
}
508532

509-
//const unsigned unwind_loops=
510-
// cmdline.isset("unwind")?options.get_int_option("unwind"):0;
533+
const unsigned unwind_loops =
534+
( cmdline.isset("unwind")?options.get_int_option("unwind"):0 );
535+
const unsigned max_var =
536+
( cmdline.isset("max-var")?options.get_int_option("max-var"):0 );
537+
const unsigned max_po_trans =
538+
( cmdline.isset("max-po-trans")?options.get_int_option("max-po-trans"):0 );
511539

512540
if(cmdline.isset("tso"))
513541
{
514-
#if 0
515542
status("Adding weak memory (TSO) Instrumentation");
516543
weak_memory(
517544
TSO,
518545
value_set_analysis,
519546
context,
520547
goto_functions,
521-
cmdline.isset("one-partition"),
522-
cmdline.isset("one-event-per-cycle"),
523-
cmdline.isset("my-events"),
524-
unwind_loops);
525-
#endif
548+
cmdline.isset("scc"),
549+
options.get_int_option("event-strategy"),
550+
unwind_loops,
551+
!cmdline.isset("cfg-kill"),
552+
cmdline.isset("no-dependencies"),
553+
max_var,
554+
max_po_trans,
555+
!cmdline.isset("no-po-rendering"),
556+
cmdline.isset("render-cluster-file"),
557+
cmdline.isset("render-cluster-function"),
558+
cmdline.isset("cav11"));
526559
}
527560

528561
if(cmdline.isset("pso"))
529562
{
530-
#if 0
531563
status("Adding weak memory (PSO) Instrumentation");
532564
weak_memory(
533565
PSO,
534566
value_set_analysis,
535567
context,
536568
goto_functions,
537-
cmdline.isset("one-partition"),
538-
cmdline.isset("one-event-per-cycle"),
539-
cmdline.isset("my-events"),
540-
unwind_loops);
541-
#endif
569+
cmdline.isset("scc"),
570+
options.get_int_option("event-strategy"),
571+
unwind_loops,
572+
!cmdline.isset("cfg-kill"),
573+
cmdline.isset("no-dependencies"),
574+
max_var,
575+
max_po_trans,
576+
!cmdline.isset("no-po-rendering"),
577+
cmdline.isset("render-cluster-file"),
578+
cmdline.isset("render-cluster-function"),
579+
cmdline.isset("cav11"));
542580
}
543581

544582
if(cmdline.isset("rmo"))
545583
{
546-
#if 0
547584
status("Adding weak memory (RMO) Instrumentation");
548585
weak_memory(
549586
RMO,
550587
value_set_analysis,
551588
context,
552589
goto_functions,
553-
cmdline.isset("one-partition"),
554-
cmdline.isset("one-event-per-cycle"),
555-
cmdline.isset("my-events"),
556-
unwind_loops);
557-
#endif
590+
cmdline.isset("scc"),
591+
options.get_int_option("event-strategy"),
592+
unwind_loops,
593+
!cmdline.isset("cfg-kill"),
594+
cmdline.isset("no-dependencies"),
595+
max_var,
596+
max_po_trans,
597+
!cmdline.isset("no-po-rendering"),
598+
cmdline.isset("render-cluster-file"),
599+
cmdline.isset("render-cluster-function"),
600+
cmdline.isset("cav11"));
558601
}
559602

560603
if(cmdline.isset("power"))
561604
{
562-
#if 0
563605
status("Adding weak memory (Power) Instrumentation");
564606
weak_memory(
565607
POWER,
566608
value_set_analysis,
567609
context,
568610
goto_functions,
569-
cmdline.isset("one-partition"),
570-
cmdline.isset("one-event-per-cycle"),
571-
cmdline.isset("my-events"),
572-
unwind_loops);
573-
#endif
611+
cmdline.isset("scc"),
612+
options.get_int_option("event-strategy"),
613+
unwind_loops,
614+
!cmdline.isset("cfg-kill"),
615+
cmdline.isset("no-dependencies"),
616+
max_var,
617+
max_po_trans,
618+
!cmdline.isset("no-po-rendering"),
619+
cmdline.isset("render-cluster-file"),
620+
cmdline.isset("render-cluster-function"),
621+
cmdline.isset("cav11"));
574622
}
575623

576624
// Interrupt handler
@@ -602,7 +650,6 @@ void goto_instrument_parseoptionst::instrument_goto_program(
602650
context,
603651
goto_functions);
604652
}
605-
606653
}
607654

608655
// add failed symbols
@@ -691,9 +738,26 @@ void goto_instrument_parseoptionst::help()
691738
"\n"
692739
"Semantic transformations:\n"
693740
" --nondet-volatile makes reads from volatile variables non-deterministic\n"
741+
" --unwind <n> unwinds the loops <n> times\n"
694742
" --isr function instruments an interrupt service routine\n"
695743
" --mmio instruments memory-mapped I/O\n"
696744
" --nondet-static add nondeterministic initialization of variables with static lifetime\n"
745+
" --check-invariant function instruments invariant checking function\n"
746+
"\n"
747+
"Memory model instrumentations:\n"
748+
" --tso instruments weak memory models with buffers (TSO)\n"
749+
" --pso instruments weak memory models with buffers (PSO)\n"
750+
" --rmo instruments weak memory models with buffers (RMO)\n"
751+
" --power instruments weak memory models with buffers and cache (Power)\n"
752+
" --scc detects critical cycles per SCC (one thread per SCC)\n"
753+
" --one-event-per-cycle only instruments one event per cycle\n"
754+
" --minimum-interference instruments an optimal number of events\n"
755+
" --my-events only instruments the events whose ids appear in inst.evt\n"
756+
" --cfg-kill enables symbolic execution used to reduce spurious cycles\n"
757+
" --no-dependencies no dependency analysis\n"
758+
" --no-po-rendering no representation of the threads in the dot\n"
759+
" --render-cluster-file clusterises the dot into files of the program"
760+
" --render-cluster-function clusterises the dot into functions of the program"
697761
"\n"
698762
"Slicing:\n"
699763
" --reachability-slicer slice away instructions that can't reach assertions\n"

0 commit comments

Comments
 (0)