Skip to content

Commit 8234610

Browse files
authored
Merge pull request #4425 from diffblue/manual-fixes3
Further manual fixes
2 parents b5a998e + 8b3035f commit 8234610

File tree

8 files changed

+77
-74
lines changed

8 files changed

+77
-74
lines changed

doc/cprover-manual/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void __CPROVER_cover(_Bool condition);
8787
```
8888
8989
This statement defines a custom coverage criterion, for usage with the
90-
[test suite generation feature](cover.shtml).
90+
[test suite generation feature](../test-suite/).
9191
9292
#### \_\_CPROVER\_isnan, \_\_CPROVER\_isfinite, \_\_CPROVER\_isinf, \_\_CPROVER\_isnormal, \_\_CPROVER\_sign
9393

doc/cprover-manual/cbmc-tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ violates an assertion. Without unwinding assertions, or when using the
284284
`--depth` command line switch, CBMC does not prove the program correct,
285285
but it can be helpful to find program bugs. The various command line
286286
options that CBMC offers for loop unwinding are described in the section
287-
on [understanding loop unwinding](../../cbmc-unwinding/).
287+
on [understanding loop unwinding](../../cbmc/unwinding/).
288288

289289
### A Note About Compilers and the ANSI-C Library
290290

doc/cprover-manual/goto-cc-variants.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[CPROVER Manual TOC](../)
1+
[CPROVER Manual TOC](../../)
22

33
## Variants of goto-cc
44

doc/cprover-manual/goto-cc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The normal build system for the project may be used to build the
2020
software, but the outcome will be a model file with suitable detail for
2121
verification, as opposed to a flat executable program. Note that goto-cc
2222
comes in different variants depending on the compilation environment.
23-
These variants are described [here](goto-cc-variants.shtml).
23+
These variants are described [here](variants/).
2424

2525
### Example: Building wu-ftpd
2626

doc/cprover-manual/goto-harness.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ entry function for analysis, or further modify it with `goto-harness` or
9191
`goto-instrument` or other tools.
9292
9393
The example above demonstrates the most simple case, which is roughly the same
94-
as the entry point `cbmc` automically generates for functions. However, the
94+
as the entry point `cbmc` automatically generates for functions. However, the
9595
`function-call` harness can also non-deterministically initialise global
9696
variables, array and struct elements. Consider this more complicated example:
9797

doc/cprover-manual/jbmc-user-manual.md

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
\ingroup module_hidden
2-
\page jbmc-user-manual JBMC User Manual
1+
[CPROVER Manual TOC](../)
32

3+
# Verifying Java with JBMC
44

5-
\section jbmc-manual-intro Introduction
5+
## Introduction
66

77
JBMC is a bounded model checking tool for the Java language. It follows the
88
same principles as CBMC, thus the existing
9-
[documentation for CBMC](http://www.cprover.org/cprover-manual/cbmc.html)
9+
[documentation for CBMC](../cbmc/tutorial/)
1010
largely applies to JBMC.
1111

12-
In brief, JBMC creates a model from Java Bytecode (given as input as a .class
13-
file or a .jar) and performs static analysis and symbolic execution which allow
14-
us to prove or refute properties. These properties are either automatically
15-
generated (runtime errors), or provided by the user in the form of assertions.
12+
In brief, JBMC creates a model from Java Bytecode (given as input as a
13+
`.class` file or a `.jar`) and performs static analysis and symbolic
14+
execution which allow us to prove or refute properties. These properties
15+
are either automatically generated (runtime errors), or provided by the user
16+
in the form of assertions.
1617

1718
Using examples, the following section will guide you through the basic
1819
features of JBMC.
1920

21+
## JBMC tutorial
2022

21-
\section jbmc-tutorial JBMC tutorial
22-
23-
\subsection jbmc-manual-auto-assert Automatic assertions
23+
### Automatic assertions
2424

2525
Consider the following simplistic `ExampleArray.java` file which we have
2626
compiled into `tutorial/ExampleArray.class` and which queries the array of
@@ -40,11 +40,12 @@ input arguments at index 3:
4040

4141
Now let's run the following command to let JBMC tell us about potential errors
4242
in our program.
43-
44-
$ jbmc tutorial/ExampleArray.class
43+
```
44+
$ jbmc tutorial/ExampleArray.class
45+
```
4546

4647
The output contains the following:
47-
```c
48+
```plaintext
4849
[java::tutorial.ExampleArray.main:([Ljava/lang/String;)V.null-pointer-exception.1] line 7 Null pointer check: SUCCESS
4950
[java::tutorial.ExampleArray.main:([Ljava/lang/String;)V.array-index-out-of-bounds-low.1] line 7 Array index should be >= 0: SUCCESS
5051
[java::tutorial.ExampleArray.main:([Ljava/lang/String;)V.array-index-out-of-bounds-high.1] line 7 Array index should be < length: FAILURE
@@ -75,20 +76,21 @@ safe as follows:
7576
13| }
7677
```
7778
then when running JBMC on that corrected version:
78-
79-
$ jbmc tutorial/ExampleArraySafe.class
79+
```
80+
$ jbmc tutorial/ExampleArraySafe.class
81+
```
8082

8183
all the automatic assertions become valid, meaning that there is no
8284
possible inputs (argument values) for which they can be violated:
83-
```c
85+
```plaintext
8486
[java::tutorial.ExampleArraySafe.main:([Ljava/lang/String;)V.1] line 7 no uncaught exception: SUCCESS
8587
[java::tutorial.ExampleArraySafe.main:([Ljava/lang/String;)V.null-pointer-exception.1] line 8 Null pointer check: SUCCESS
8688
[java::tutorial.ExampleArraySafe.main:([Ljava/lang/String;)V.null-pointer-exception.2] line 9 Null pointer check: SUCCESS
8789
[java::tutorial.ExampleArraySafe.main:([Ljava/lang/String;)V.array-index-out-of-bounds-low.1] line 9 Array index should be >= 0: SUCCESS
8890
[java::tutorial.ExampleArraySafe.main:([Ljava/lang/String;)V.array-index-out-of-bounds-high.1] line 9 Array index should be < length: SUCCESS
8991
```
9092

91-
\subsection jbmc-manual-unwind Loop unwinding
93+
## Loop unwinding
9294

9395
As CBMC, JBMC needs to unwind loops up to a given value. Consider the `isPrime`
9496
method in the code below. Without specifying an unwind limit, JBMC will not
@@ -120,49 +122,49 @@ depends on an input):
120122
```
121123
To limit the number of times the for-loop is unwound, we use the `--unwind N`
122124
options, in which case the following call to JBMC:
123-
124-
$ jbmc tutorial/ExampleUnwind.class --function tutorial.ExampleUnwind.isPrime --unwind 10
125-
125+
```
126+
$ jbmc tutorial/ExampleUnwind.class --function tutorial.ExampleUnwind.isPrime --unwind 10
127+
```
126128
will terminate correctly. In this case, we will see `VERIFICATION SUCCESSFUL`,
127129
as no automatic assertions are violated.
128130

129131
Note that in that example, there are is no main function, so we give specify
130132
the desired entry point via the `--function` option.
131133

132134

133-
\subsection jbmc-manual-user-assert User assertions
135+
## User assertions
134136

135137
Elaborating on the example above, users may provide their own assertions, that
136138
JBMC will try to refute. On line 7, we check the assertion that all odd
137139
numbers greater than 1 are prime. To be sure that this always holds, we run
138140
JBMC on the example, with a reasonable `unwind` value:
139-
140-
$ jbmc tutorial/ExampleUnwind.class --function tutorial.ExampleUnwind.doSomething --unwind 10
141-
141+
```
142+
$ jbmc tutorial/ExampleUnwind.class --function tutorial.ExampleUnwind.doSomething --unwind 10
143+
```
142144
Unsurprisingly JBMC doesn't agree, and prints an assertion failure
143145
(truncated here for readability):
144-
```c
146+
```plaintext
145147
[...doSomething:(I)V.assertion.1] line 7 assertion at file tutorial/ExampleUnwind.java: FAILURE
146148
```
147149

148150
Rerunning the analysis with the `--trace` option, the following line appears
149151
somewhere in the trace output and tells us which input value JBMC found to
150152
trigger the violation (note that to see the original parameter names in the
151153
trace output, the Java source must be compiled in debug mode: `javac -g`):
152-
```c
154+
```plaintext
153155
INPUT inputVal: 15
154156
```
155157
The value chosen by JBMC is arbitrary, and could as well be 9
156158
or 2084569161.
157159

158-
\subsection jbmc-manual-library Java Library support
160+
## Java Library support
159161

160162
The examples above only involve primitive types. In order to analyse code
161163
involving Java Library classes, the core models (located in the same
162164
repository) need to be added to the classpath:
163-
164-
--cp <path_to_cbmc>/jbmc/src/java_bytecode/library/core-models.jar
165-
165+
```
166+
--cp <path_to_cbmc>/jbmc/src/java_bytecode/library/core-models.jar
167+
```
166168

167169
The core models library simulate the behavior of the Java Library and
168170
contains some commonly used classes, such as Object, Class, String, Enum.
@@ -185,21 +187,21 @@ from `java.lang.String`, e.g.
185187
```
186188
The following command line (note that the current directory is also added to
187189
the classpath):
188-
189-
$ jbmc tutorial/ExampleModels.class --cp <path_to_cbmc>/jbmc/src/java_bytecode/library/core-models.jar:.
190-
190+
```
191+
$ jbmc tutorial/ExampleModels.class --cp <path_to_cbmc>/jbmc/src/java_bytecode/library/core-models.jar:.
192+
```
191193
will flag this violation (truncated):
192-
```c
194+
```plaintext
193195
[java::tutorial.ExampleModels.stringOp:()V.assertion.1] line 8 assertion: FAILURE
194196
```
195197

196198
Again, the trace (when re-running with `--trace`) shows the string violating
197199
the condition in the assertion:
198-
```c
200+
```plaintext
199201
dynamic_object2={ 'a', 'b', '$', 'c', 'd' }
200202
```
201203

202-
\subsection jbmc-manual-exceptions Exceptions
204+
## Exceptions
203205

204206
In its analysis, JBMC can take into account exceptions thrown by user code or
205207
library classes, as well as runtime exceptions such as NullPointerException.
@@ -220,13 +222,12 @@ Consider the following code:
220222
```
221223

222224
When given the `--throw-runtime-exceptions` options:
223-
224-
$ jbmc tutorial/ExampleExceptions --tutorial.ExampleExceptions.strLength --throw-runtime-exceptions
225-
225+
```
226+
$ jbmc tutorial/ExampleExceptions --tutorial.ExampleExceptions.strLength --throw-runtime-exceptions
227+
```
226228
JBMC will signal that the `str.length()` call may throw a runtime exception
227229
and that this exception is not caught.
228-
229-
```c
230+
```plaintext
230231
[java::tutorial.ExampleExceptions.strLength:(Ljava/lang/String;)I.1] line 6 no uncaught exception: FAILURE
231232
```
232233
This could be fixed by adding a try-catch statement, or else checking that
@@ -243,9 +244,9 @@ VERIFICATION SUCCESSFUL
243244
```
244245

245246
When analyzing this function without runtime exception support:
246-
247-
$ jbmc tutorial/ExampleExceptions
248-
247+
```
248+
$ jbmc tutorial/ExampleExceptions
249+
```
249250
JBMC only reports the error as a null pointer check failure:
250251
```
251252
[...null-pointer-exception.1] line 6 Null pointer check: FAILURE
@@ -258,11 +259,11 @@ on violation. This behavior can be replicated in JBMC by using the
258259
then be reported like any other uncaught exception.
259260

260261

261-
\subsection jbmc-manual-further-doc Further documentation
262+
## Further documentation
262263

263264
JBMC has a wealth of other options that can either constrain the model (to
264265
cope with complexity issues), or output more relevant information. The list
265266
of all available options is printed by running:
266-
267-
$ jbmc --help
268-
267+
```
268+
$ jbmc --help
269+
```

doc/cprover-manual/properties.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -203,20 +203,22 @@ goto-instrument error_example.goto error_example_replaced.goto \
203203
cbmc error_example_replaced.goto
204204
```
205205

206-
Which gets us the output
206+
This generates the following output:
207207

208-
> ** Results:
209-
> error_example.c function api_error
210-
> [api_error.assertion.1] line 4 assertion false: FAILURE
211-
>
212-
> error_example.c function internal_error
213-
> [internal_error.assertion.1] line 5 assertion false: FAILURE
214-
>
215-
> ** 2 of 2 failed (2 iterations)
216-
> VERIFICATION FAILED
208+
```
209+
** Results:
210+
error_example.c function api_error
211+
[api_error.assertion.1] line 4 assertion false: FAILURE
212+
213+
error_example.c function internal_error
214+
[internal_error.assertion.1] line 5 assertion false: FAILURE
215+
216+
** 2 of 2 failed (2 iterations)
217+
VERIFICATION FAILED
218+
```
217219

218-
As opposed to the verification success we would have seen without the
219-
instrumentation step.
220+
Without the instrumentation step we would have seen
221+
"VERIFICATION SUCCESSFUL".
220222

221223
The havoc option takes further parameters `globals` and `params` with this
222224
syntax: `havoc[,globals:<regex>][,params:<regex>]` (where the square brackets
@@ -241,10 +243,10 @@ int do_something_with_complex(struct Complex *complex);
241243
And the command line
242244
243245
```
244-
goto-instrument in.goto out.goto
245-
--generate-function-body do_something_with_complex
246-
--generate-function-body-options
247-
'havoc,params:.*,globals:AGlobalComplex'
246+
goto-instrument in.goto out.goto
247+
--generate-function-body do_something_with_complex
248+
--generate-function-body-options
249+
'havoc,params:.*,globals:AGlobalComplex'
248250
```
249251
250252
The goto code equivalent of the following will be generated:
@@ -264,7 +266,7 @@ int do_something_with_complex(struct Complex *complex)
264266
```
265267

266268
A note on limitations: Because only static information is used for code
267-
generation, arrays of unknown size and pointers will not be affected by this;
269+
generation, arrays of unknown size and pointers will not be affected by this.
268270
Which means that for code like this:
269271

270272
```C

doc/cprover-manual/test-suite.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
### A Small Tutorial with a Case Study
66

77
We assume that CBMC is installed on your system. If not, follow
8-
[these instructions](../../installation/).
8+
[these instructions](../installation/).
99

1010
CBMC can be used to automatically generate test cases that satisfy a
1111
certain [code coverage](https://en.wikipedia.org/wiki/Code_coverage)
@@ -197,12 +197,12 @@ unwound enough times. For example, `climb_pid_run` needs to
197197
be called at least six times for evaluating the condition
198198
`climb_sum_err>MAX_CLIMB_SUM_ERR` in line 48 to *true*. This corresponds
199199
to Test 5. To learn more about loop unwinding take a look at [Understanding Loop
200-
Unwinding](../../cbmc-unwinding/).
200+
Unwinding](../cbmc/unwinding/).
201201

202202
In this tutorial, we present the automatic test suite generation
203203
functionality of CBMC, by applying the MC/DC code coverage criterion to
204204
a PID controller case study. In addition to `--cover mcdc`, other
205-
coverage criteria such as `branch`, `decision`, and `path`. are also
205+
coverage criteria such as `branch`, `decision`, and `path` are also
206206
available when calling CBMC.
207207

208208
### Coverage Criteria

0 commit comments

Comments
 (0)