Skip to content

Commit 0208218

Browse files
Merge pull request diffblue#1861 from peterschrammel/goto-diff-properties
Show properties for goto-diff
2 parents b36a90a + df9aab5 commit 0208218

24 files changed

+380
-171
lines changed
775 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
public class Test {
2+
3+
private static Test static_test = null;
4+
private Test test = new Test();
5+
6+
public Test() {
7+
}
8+
9+
public int foo(int x) {
10+
if (x > 10) {
11+
return x;
12+
} else {
13+
return x * 10;
14+
}
15+
}
16+
17+
public void newfun() {
18+
}
19+
}
770 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
public class Test {
2+
3+
private static Test static_test = new Test();
4+
private Test test = null;
5+
6+
public Test() {
7+
}
8+
9+
public int foo(int x) {
10+
if (x > 10) {
11+
return x;
12+
} else {
13+
return x * 10;
14+
}
15+
}
16+
17+
public void obsolete() {
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
new.jar
3+
old.jar --json-ui --show-properties --cover location
4+
// Enable multi-line checking
5+
activate-multi-line-match
6+
EXIT=0
7+
SIGNAL=0
8+
"deletedFunctions": \[\n {\n "name": "java::Test\.obsolete:\(\)V",\n "properties": \[\n {\n "class": "coverage",\n "coveredLines": "18",\n "description": "block 1",\n "expression": "false",\n "name": "java::Test\.obsolete:\(\)V\.coverage\.1",\n "sourceLocation": {\n "bytecodeIndex": "0",\n "file": "Test\.java",\n "function": "java::Test\.obsolete:\(\)V",\n "line": "18"\n }\n }\n ],\n "sourceLocation": {\n "file": "Test\.java",\n "function": "java::Test\.obsolete:\(\)V",\n "line": "18"\n }\n }\n ],\n "modifiedFunctions": \[\n {\n "name": "java::Test\.<init>:\(\)V",\n "properties": \[\n {\n "class": "coverage",\n "coveredLines": "6",\n "description": "block 1",\n "expression": "false",\n "name": "java::Test\.<init>:\(\)V\.coverage\.1",\n "sourceLocation": {\n "bytecodeIndex": "1",\n "file": "Test\.java",\n "function": "java::Test\.<init>:\(\)V",\n "line": "6"\n }\n },\n {\n "class": "coverage",\n "coveredLines": "4",\n "description": "block 2",\n "expression": "false",\n "name": "java::Test\.<init>:\(\)V\.coverage\.2",\n "sourceLocation": {\n "bytecodeIndex": "3",\n "file": "Test\.java",\n "function": "java::Test\.<init>:\(\)V",\n "line": "4"\n }\n },\n {\n "class": "coverage",\n "coveredLines": "4",\n "description": "block 3",\n "expression": "false",\n "name": "java::Test\.<init>:\(\)V\.coverage\.3",\n "sourceLocation": {\n "bytecodeIndex": "5",\n "file": "Test\.java",\n "function": "java::Test\.<init>:\(\)V",\n "line": "4"\n }\n },\n {\n "class": "coverage",\n "coveredLines": "4,7",\n "description": "block 4",\n "expression": "false",\n "name": "java::Test\.<init>:\(\)V\.coverage\.4",\n "sourceLocation": {\n "bytecodeIndex": "6",\n "file": "Test\.java",\n "function": "java::Test\.<init>:\(\)V",\n "line": "4"\n }\n }\n ],\n "sourceLocation": {\n "file": "Test\.java",\n "function": "java::Test\.<init>:\(\)V",\n "line": "6"\n }\n },\n {\n "name": "java::Test\.<clinit>:\(\)V",\n "properties": \[\n {\n "class": "coverage",\n "coveredLines": "3",\n "description": "block 1",\n "expression": "false",\n "name": "java::Test\.<clinit>:\(\)V\.coverage\.1",\n "sourceLocation": {\n "bytecodeIndex": "1",\n "file": "Test\.java",\n "function": "java::Test\.<clinit>:\(\)V",\n "line": "3"\n }\n }\n ],\n "sourceLocation": {\n "file": "Test\.java",\n "function": "java::Test\.<clinit>:\(\)V",\n "line": "3"\n }\n }\n ],\n "newFunctions": \[\n {\n "name": "java::Test\.newfun:\(\)V",\n "properties": \[\n {\n "class": "coverage",\n "coveredLines": "18",\n "description": "block 1",\n "expression": "false",\n "name": "java::Test\.newfun:\(\)V\.coverage\.1",\n "sourceLocation": {\n "bytecodeIndex": "0",\n "file": "Test\.java",\n "function": "java::Test\.newfun:\(\)V",\n "line": "18"\n }\n }\n ],\n "sourceLocation": {\n "file": "Test\.java",\n "function": "java::Test\.newfun:\(\)V",\n "line": "18"\n }\n }\n ],\n
9+
--
10+
^warning: ignoring

src/cbmc/cbmc_parse_options.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,8 @@ int cbmc_parse_optionst::doit()
534534
if(cmdline.isset("show-claims") || // will go away
535535
cmdline.isset("show-properties")) // use this one
536536
{
537-
show_properties(goto_model, ui_message_handler.get_ui());
537+
show_properties(
538+
goto_model, get_message_handler(), ui_message_handler.get_ui());
538539
return CPROVER_EXIT_SUCCESS;
539540
}
540541

@@ -923,7 +924,7 @@ void cbmc_parse_optionst::help()
923924
" cbmc file.c ... source file names\n"
924925
"\n"
925926
"Analysis options:\n"
926-
" --show-properties show the properties, but don't run analysis\n" // NOLINT(*)
927+
HELP_SHOW_PROPERTIES
927928
" --symex-coverage-report f generate a Cobertura XML coverage report in f\n" // NOLINT(*)
928929
" --property id only check one specific property\n"
929930
" --stop-on-fail stop analysis once a failed property is detected\n" // NOLINT(*)

src/cbmc/cbmc_parse_options.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ class optionst;
5353
"(aig)(16)(32)(64)(LP64)(ILP64)(LLP64)(ILP32)(LP32)" \
5454
"(little-endian)(big-endian)" \
5555
OPT_SHOW_GOTO_FUNCTIONS \
56+
OPT_SHOW_PROPERTIES \
5657
"(show-loops)" \
5758
"(show-symbol-table)(show-parse-tree)(show-vcc)" \
58-
"(show-claims)(claim):(show-properties)" \
5959
"(drop-unused-functions)" \
6060
"(property):(stop-on-fail)(trace)" \
6161
"(error-label):(verbosity):(no-library)" \
@@ -72,7 +72,7 @@ class optionst;
7272
"(graphml-witness):" \
7373
"(localize-faults)(localize-faults-method):" \
7474
OPT_GOTO_TRACE \
75-
"(fixedbv)(floatbv)(all-claims)(all-properties)" // legacy, and will eventually disappear // NOLINT(whitespace/line_length)
75+
"(claim):(show-claims)(fixedbv)(floatbv)(all-claims)(all-properties)" // legacy, and will eventually disappear // NOLINT(whitespace/line_length)
7676
// clang-format on
7777

7878
class cbmc_parse_optionst:

src/clobber/clobber_parse_options.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ int clobber_parse_optionst::doit()
150150

151151
if(cmdline.isset("show-properties"))
152152
{
153-
show_properties(goto_model, get_ui());
153+
show_properties(goto_model, get_message_handler(), get_ui());
154154
return 0;
155155
}
156156

src/clobber/clobber_parse_options.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,27 @@ Author: Daniel Kroening, [email protected]
1919

2020
#include <analyses/goto_check.h>
2121
#include <goto-programs/show_goto_functions.h>
22+
#include <goto-programs/show_properties.h>
2223

2324
#include <java_bytecode/java_bytecode_language.h>
2425

2526
class goto_functionst;
2627
class optionst;
2728

29+
// clang-format off
2830
#define CLOBBER_OPTIONS \
2931
"(depth):(context-bound):(unwind):" \
3032
OPT_GOTO_CHECK \
3133
OPT_SHOW_GOTO_FUNCTIONS \
34+
OPT_SHOW_PROPERTIES \
3235
"(no-assertions)(no-assumptions)" \
3336
"(error-label):(verbosity):(no-library)" \
3437
"(version)" \
3538
"(string-abstraction)" \
36-
"(show-locs)(show-vcc)(show-properties)(show-trace)" \
39+
"(show-locs)(show-vcc)(show-trace)" \
3740
"(property):" \
3841
JAVA_BYTECODE_LANGUAGE_OPTIONS
42+
// clang-format on
3943

4044
class clobber_parse_optionst:
4145
public parse_options_baset,

src/goto-analyzer/goto_analyzer_parse_options.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
592592

593593
if(cmdline.isset("show-properties"))
594594
{
595-
show_properties(goto_model, get_ui());
595+
show_properties(goto_model, get_message_handler(), get_ui());
596596
return CPROVER_EXIT_SUCCESS;
597597
}
598598

@@ -815,6 +815,7 @@ void goto_analyzer_parse_optionst::help()
815815

816816
std::cout << " * *\n";
817817

818+
// clang-format off
818819
std::cout <<
819820
"* * Daniel Kroening, DiffBlue * *\n"
820821
"* * [email protected] * *\n"
@@ -898,8 +899,7 @@ void goto_analyzer_parse_optionst::help()
898899
" --show-parse-tree show parse tree\n"
899900
" --show-symbol-table show symbol table\n"
900901
HELP_SHOW_GOTO_FUNCTIONS
901-
// NOLINTNEXTLINE(whitespace/line_length)
902-
" --show-properties show the properties, but don't run analysis\n"
902+
HELP_SHOW_PROPERTIES
903903
"\n"
904904
"Program instrumentation options:\n"
905905
HELP_GOTO_CHECK
@@ -908,4 +908,5 @@ void goto_analyzer_parse_optionst::help()
908908
" --version show version and exit\n"
909909
HELP_TIMESTAMP
910910
"\n";
911+
// clang-format on
911912
}

src/goto-analyzer/goto_analyzer_parse_options.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Author: Daniel Kroening, [email protected]
109109

110110
#include <goto-programs/goto_model.h>
111111
#include <goto-programs/show_goto_functions.h>
112+
#include <goto-programs/show_properties.h>
112113

113114
#include <analyses/ai.h>
114115
#include <analyses/goto_check.h>
@@ -119,17 +120,19 @@ class bmct;
119120
class goto_functionst;
120121
class optionst;
121122

123+
// clang-format off
122124
#define GOTO_ANALYSER_OPTIONS \
123125
OPT_FUNCTIONS \
124126
"D:I:(std89)(std99)(std11)" \
125127
"(classpath):(cp):(main-class):" \
126128
"(16)(32)(64)(LP64)(ILP64)(LLP64)(ILP32)(LP32)" \
127129
"(little-endian)(big-endian)" \
128130
OPT_SHOW_GOTO_FUNCTIONS \
131+
OPT_SHOW_PROPERTIES \
129132
OPT_GOTO_CHECK \
130133
"(show-loops)" \
131134
"(show-symbol-table)(show-parse-tree)" \
132-
"(show-properties)(show-reachable-properties)(property):" \
135+
"(show-reachable-properties)(property):" \
133136
"(verbosity):(version)" \
134137
"(gcc)(arch):" \
135138
"(taint):(show-taint)" \
@@ -147,6 +150,7 @@ class optionst;
147150
"(location-sensitive)(concurrent)" \
148151
"(no-simplify-slicing)" \
149152
JAVA_BYTECODE_LANGUAGE_OPTIONS
153+
// clang-format on
150154

151155
class goto_analyzer_parse_optionst:
152156
public parse_options_baset,

src/goto-diff/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ target_link_libraries(goto-diff-lib
1313
linking
1414
big-int
1515
pointer-analysis
16+
goto-instrument-lib
1617
goto-programs
1718
assembler
1819
analyses

src/goto-diff/Makefile

+12
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ OBJ += ../ansi-c/ansi-c$(LIBEXT) \
1515
../goto-programs/goto-programs$(LIBEXT) \
1616
../assembler/assembler$(LIBEXT) \
1717
../pointer-analysis/pointer-analysis$(LIBEXT) \
18+
../goto-instrument/cover$(OBJEXT) \
19+
../goto-instrument/cover_basic_blocks$(OBJEXT) \
20+
../goto-instrument/cover_filter$(OBJEXT) \
21+
../goto-instrument/cover_instrument_branch$(OBJEXT) \
22+
../goto-instrument/cover_instrument_condition$(OBJEXT) \
23+
../goto-instrument/cover_instrument_decision$(OBJEXT) \
24+
../goto-instrument/cover_instrument_location$(OBJEXT) \
25+
../goto-instrument/cover_instrument_mcdc$(OBJEXT) \
26+
../goto-instrument/cover_instrument_other$(OBJEXT) \
27+
../goto-instrument/cover_util$(OBJEXT) \
28+
../goto-symex/adjust_float_expressions$(OBJEXT) \
29+
../goto-symex/rewrite_union$(OBJEXT) \
1830
../analyses/analyses$(LIBEXT) \
1931
../langapi/langapi$(LIBEXT) \
2032
../xmllang/xmllang$(LIBEXT) \

src/goto-diff/goto_diff.h

+29-15
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,57 @@ Author: Peter Schrammel
1919

2020
#include <ostream>
2121

22+
class optionst;
23+
2224
class goto_difft:public messaget
2325
{
2426
public:
25-
explicit goto_difft(
27+
goto_difft(
2628
const goto_modelt &_goto_model1,
2729
const goto_modelt &_goto_model2,
28-
message_handlert &_message_handler
29-
)
30-
:
31-
messaget(_message_handler),
32-
goto_model1(_goto_model1),
33-
goto_model2(_goto_model2),
34-
ui(ui_message_handlert::uit::PLAIN),
35-
total_functions_count(0)
36-
{}
30+
const optionst &_options,
31+
message_handlert &_message_handler)
32+
: messaget(_message_handler),
33+
goto_model1(_goto_model1),
34+
goto_model2(_goto_model2),
35+
options(_options),
36+
ui(ui_message_handlert::uit::PLAIN),
37+
total_functions_count(0)
38+
{
39+
}
3740

3841
virtual bool operator()()=0;
3942

4043
void set_ui(ui_message_handlert::uit _ui) { ui=_ui; }
4144

42-
virtual std::ostream &output_functions(std::ostream &out) const;
45+
virtual void output_functions() const;
4346

4447
protected:
4548
const goto_modelt &goto_model1;
4649
const goto_modelt &goto_model2;
50+
const optionst &options;
4751
ui_message_handlert::uit ui;
4852

4953
unsigned total_functions_count;
5054
typedef std::set<irep_idt> irep_id_sett;
5155
irep_id_sett new_functions, modified_functions, deleted_functions;
5256

53-
void convert_function_group(
57+
void output_function_group(
58+
const std::string &group_name,
59+
const irep_id_sett &function_group,
60+
const goto_modelt &goto_model) const;
61+
void output_function(
62+
const irep_idt &function_name,
63+
const goto_modelt &goto_model) const;
64+
65+
void convert_function_group_json(
5466
json_arrayt &result,
55-
const irep_id_sett &function_group) const;
56-
void convert_function(
67+
const irep_id_sett &function_group,
68+
const goto_modelt &goto_model) const;
69+
void convert_function_json(
5770
json_objectt &result,
58-
const irep_idt &function_name) const;
71+
const irep_idt &function_name,
72+
const goto_modelt &goto_model) const;
5973
};
6074

6175
#endif // CPROVER_GOTO_DIFF_GOTO_DIFF_H

0 commit comments

Comments
 (0)