Skip to content

Commit 98c4526

Browse files
author
Daniel Kroening
committed
Merge branch 'master' of github.com:diffblue/cbmc
2 parents 71991f0 + 12c051b commit 98c4526

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1414
-131
lines changed

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ matrix:
1313
packages:
1414
- libwww-perl
1515
- g++-5
16+
- libubsan0
1617
before_install:
1718
- mkdir bin ; ln -s /usr/bin/gcc-5 bin/gcc
19+
# env: COMPILER=g++-5 SAN_FLAGS="-fsanitize=undefined -fno-sanitize-recover -fno-omit-frame-pointer"
1820
env: COMPILER=g++-5
1921
- os: linux
2022
compiler: clang
@@ -26,8 +28,10 @@ matrix:
2628
packages:
2729
- libwww-perl
2830
- clang-3.7
31+
- libubsan0
2932
before_install:
3033
- mkdir bin ; ln -s /usr/bin/clang-3.7 bin/gcc
34+
# env: COMPILER=clang++-3.7 SAN_FLAGS="-fsanitize=undefined -fno-sanitize-recover=undefined,integer -fno-omit-frame-pointer"
3135
env: COMPILER=clang++-3.7
3236
- os: osx
3337
compiler: gcc
@@ -42,5 +46,5 @@ script:
4246
- if [ -L bin/gcc ] ; then export PATH=$PWD/bin:$PATH ; fi ;
4347
make -C src minisat2-download &&
4448
make -C src CXX=$COMPILER CXXFLAGS="-Wall -O2 -g -Werror -Wno-deprecated-register -pedantic -Wno-sign-compare" -j2 &&
45-
make -C regression test &&
46-
make -C src CXX=$COMPILER CXXFLAGS="-Wall -O2 -g -Werror -Wno-deprecated-register -pedantic -Wno-sign-compare" -j2 aa-symex.dir cegis.dir clobber.dir memory-models.dir musketeer.dir
49+
env UBSAN_OPTIONS=print_stacktrace=1 make -C regression test &&
50+
make -C src CXX=$COMPILER CXXFLAGS=$FLAGS -j2 aa-symex.dir cegis.dir clobber.dir memory-models.dir musketeer.dir

regression/ansi-c/function_return1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
main.c
33
--verbosity 2
4-
^file main.c line 3 function fun: function has return void but a return statement returning signed int$
4+
^main.c:3:1: warning: function has return void but a return statement returning signed int$
55
^SIGNAL=0$
66

77
--

regression/ansi-c/struct6/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ main.c
33

44
^EXIT=\(64\|1\)$
55
^SIGNAL=0$
6-
^file main.c line 2: incomplete type not permitted here$
6+
^main.c:2:1: error: incomplete type not permitted here$
77
^CONVERSION ERROR$
88
--

regression/ansi-c/struct7/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ main.c
33

44
^EXIT=\(64\|1\)$
55
^SIGNAL=0$
6-
^file main.c line 4: duplicate member x$
6+
^main.c:4:1: error: duplicate member .*$
77
^CONVERSION ERROR$
88
--
1.37 KB
Binary file not shown.

regression/cbmc-java/enum1/enum1.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
public enum enum1
2+
{
3+
VAL1, VAL2, VAL3, VAL4, VAL5;
4+
static
5+
{
6+
for(enum1 e : enum1.values())
7+
{
8+
System.out.println(e);
9+
}
10+
}
11+
public static void main(String[] args)
12+
{
13+
enum1 e=VAL5;
14+
assert(e==VAL5);
15+
}
16+
}

regression/cbmc-java/enum1/test.desc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
enum1.class
3+
--java-unwind-enum-static --unwind 3
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^Unwinding loop java::enum1.<clinit>:()V.0 iteration 5 (6 max) file enum1.java line 6 function java::enum1.<clinit>:()V bytecode_index 78 thread 0$
7+
--
8+
^warning: ignoring

src/ansi-c/c_typecheck_type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ void c_typecheck_baset::typecheck_compound_body(
918918
if(!members.insert(it->get_name()).second)
919919
{
920920
error().source_location=it->source_location();
921-
error() << "duplicate member " << it->get_name() << eom;
921+
error() << "duplicate member '" << it->get_name() << '\'' << eom;
922922
throw 0;
923923
}
924924
}

src/cbmc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SRC = cbmc_main.cpp cbmc_parse_options.cpp bmc.cpp cbmc_dimacs.cpp \
22
cbmc_languages.cpp counterexample_beautification.cpp \
33
bv_cbmc.cpp symex_bmc.cpp show_vcc.cpp cbmc_solvers.cpp \
44
xml_interface.cpp bmc_cover.cpp all_properties.cpp \
5-
fault_localization.cpp
5+
fault_localization.cpp symex_coverage.cpp
66

77
OBJ += ../ansi-c/ansi-c$(LIBEXT) \
88
../cpp/cpp$(LIBEXT) \

src/cbmc/bmc.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,15 @@ safety_checkert::resultt bmct::run(
528528
<< " remaining after simplification" << eom;
529529
}
530530

531+
// coverage report
532+
std::string cov_out=options.get_option("symex-coverage-report");
533+
if(!cov_out.empty() &&
534+
symex.output_coverage_report(goto_functions, cov_out))
535+
{
536+
error() << "Failed to write symex coverage report" << eom;
537+
return safety_checkert::ERROR;
538+
}
539+
531540
if(options.get_bool_option("show-vcc"))
532541
{
533542
show_vcc();

src/cbmc/bmc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class bmct:public safety_checkert
4343
ui(ui_message_handlert::PLAIN)
4444
{
4545
symex.constant_propagation=options.get_bool_option("propagation");
46+
symex.record_coverage=
47+
!options.get_option("symex-coverage-report").empty();
4648
}
4749

4850
virtual resultt run(const goto_functionst &goto_functions);

src/cbmc/cbmc_parse_options.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,11 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
434434
options.set_option("stop-on-fail", true);
435435
options.set_option("trace", true);
436436
}
437+
438+
if(cmdline.isset("symex-coverage-report"))
439+
options.set_option(
440+
"symex-coverage-report",
441+
cmdline.get_value("symex-coverage-report"));
437442
}
438443

439444
/*******************************************************************\
@@ -550,6 +555,8 @@ int cbmc_parse_optionst::doit()
550555
if(set_properties(goto_functions))
551556
return 7; // should contemplate EX_USAGE from sysexits.h
552557

558+
// unwinds <clinit> loops to number of enum elements
559+
// side effect: add this as explicit unwind to unwind set
553560
if(options.get_bool_option("java-unwind-enum-static"))
554561
remove_static_init_loops(symbol_table, goto_functions, options);
555562

@@ -1084,6 +1091,7 @@ void cbmc_parse_optionst::help()
10841091
"\n"
10851092
"Analysis options:\n"
10861093
" --show-properties show the properties, but don't run analysis\n" // NOLINT(*)
1094+
" --symex-coverage-report f generate a Cobertura XML coverage report in f\n"
10871095
" --property id only check one specific property\n"
10881096
" --stop-on-fail stop analysis once a failed property is detected\n" // NOLINT(*)
10891097
" --trace give a counterexample trace for failed properties\n" //NOLINT(*)

src/cbmc/cbmc_parse_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class optionst;
4646
"(error-label):(verbosity):(no-library)" \
4747
"(nondet-static)" \
4848
"(version)" \
49-
"(cover):" \
49+
"(cover):(symex-coverage-report):" \
5050
"(mm):" \
5151
"(i386-linux)(i386-macos)(i386-win32)(win32)(winx64)(gcc)" \
5252
"(ppc-macos)(unsigned-char)" \

src/cbmc/symex_bmc.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ symex_bmct::symex_bmct(
2929
symbol_tablet &_new_symbol_table,
3030
symex_targett &_target):
3131
goto_symext(_ns, _new_symbol_table, _target),
32-
max_unwind_is_set(false)
32+
record_coverage(false),
33+
max_unwind_is_set(false),
34+
symex_coverage(_ns)
3335
{
3436
}
3537

@@ -61,6 +63,10 @@ void symex_bmct::symex_step(
6163
last_source_location=source_location;
6264
}
6365

66+
if(record_coverage &&
67+
!state.guard.is_false())
68+
symex_coverage.covered(state.source.pc);
69+
6470
goto_symext::symex_step(goto_functions, state);
6571
}
6672

src/cbmc/symex_bmc.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Author: Daniel Kroening, [email protected]
1313

1414
#include <goto-symex/goto_symex.h>
1515

16+
#include "symex_coverage.h"
17+
1618
class symex_bmct:
1719
public goto_symext,
1820
public messaget
@@ -49,6 +51,15 @@ class symex_bmct:
4951
loop_limits[id]=limit;
5052
}
5153

54+
bool output_coverage_report(
55+
const goto_functionst &goto_functions,
56+
const std::string &path) const
57+
{
58+
return symex_coverage.generate_report(goto_functions, path);
59+
}
60+
61+
bool record_coverage;
62+
5263
protected:
5364
// We have
5465
// 1) a global limit (max_unwind)
@@ -85,6 +96,8 @@ class symex_bmct:
8596
virtual void no_body(const irep_idt &identifier);
8697

8798
std::unordered_set<irep_idt, irep_id_hash> body_warnings;
99+
100+
symex_coveraget symex_coverage;
88101
};
89102

90103
#endif // CPROVER_CBMC_SYMEX_BMC_H

0 commit comments

Comments
 (0)