Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a197cd6

Browse files
author
Joel Allred
committedNov 15, 2018
fixup! cosmetic fixes
1 parent dd0caeb commit a197cd6

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed
 

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

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,16 @@ public class ExampleArray {
3939
Now let's run the following command to let JBMC tell us about potential errors
4040
in our `query` method.
4141

42-
jbmc ExampleArray.class --function tutorial.ExampleArray.query
42+
$ jbmc ExampleArray.class --function tutorial.ExampleArray.query
4343

4444

4545
The output contains the following:
46-
47-
[java::tutorial.ExampleArray.query:([II)I.null-pointer-exception.1] line 6 Null pointer check: FAILURE
48-
[java::tutorial.ExampleArray.query:([II)I.array-index-out-of-bounds-low.1] line 6 Array index should be >= 0: FAILURE
49-
[java::tutorial.ExampleArray.query:([II)I.array-index-out-of-bounds-high.1] line 6 Array index should be < length: FAILURE
50-
[java::tutorial.ExampleArray.query:([II)I.1] line 6 no uncaught exception: SUCCESS
46+
```c
47+
[java::tutorial.ExampleArray.query:([II)I.null-pointer-exception.1] line 6 Null pointer check: FAILURE
48+
[java::tutorial.ExampleArray.query:([II)I.array-index-out-of-bounds-low.1] line 6 Array index should be >= 0: FAILURE
49+
[java::tutorial.ExampleArray.query:([II)I.array-index-out-of-bounds-high.1] line 6 Array index should be < length: FAILURE
50+
[java::tutorial.ExampleArray.query:([II)I.1] line 6 no uncaught exception: SUCCESS
51+
```
5152

5253
Three reported failures spring up:
5354
1. there is no null pointer check on the array passed as argument
@@ -74,13 +75,13 @@ public class ExampleArraySafe {
7475
```
7576
then the JBMC automatic assertions become valid, meaning that there is no
7677
possible inputs (argument values) for which they can be violated:
77-
78-
[java::tutorial.ExampleArraySafe.query:([II)I.1] line 6 no uncaught exception: SUCCESS
79-
[java::tutorial.ExampleArraySafe.query:([II)I.null-pointer-exception.1] line 9 Null pointer check: SUCCESS
80-
[java::tutorial.ExampleArraySafe.query:([II)I.null-pointer-exception.2] line 12 Null pointer check: SUCCESS
81-
[java::tutorial.ExampleArraySafe.query:([II)I.array-index-out-of-bounds-low.1] line 12 Array index should be >= 0: SUCCESS
82-
[java::tutorial.ExampleArraySafe.query:([II)I.array-index-out-of-bounds-high.1] line 12 Array index should be < length: SUCCESS
83-
78+
```c
79+
[java::tutorial.ExampleArraySafe.query:([II)I.1] line 6 no uncaught exception: SUCCESS
80+
[java::tutorial.ExampleArraySafe.query:([II)I.null-pointer-exception.1] line 9 Null pointer check: SUCCESS
81+
[java::tutorial.ExampleArraySafe.query:([II)I.null-pointer-exception.2] line 12 Null pointer check: SUCCESS
82+
[java::tutorial.ExampleArraySafe.query:([II)I.array-index-out-of-bounds-low.1] line 12 Array index should be >= 0: SUCCESS
83+
[java::tutorial.ExampleArraySafe.query:([II)I.array-index-out-of-bounds-high.1] line 12 Array index should be < length: SUCCESS
84+
```
8485

8586
\subsection jbmc-manual-unwind Loop unwinding
8687

@@ -116,9 +117,10 @@ public class ExampleUnwind {
116117
To limit the number of times the for-loop is unwound, we use the `--unwind N`
117118
options, in which case the following call to JBMC:
118119

119-
jbmc ExampleUnwind.class --function tutorial.ExampleUnwind.isPrime --unwind 10
120+
$ jbmc ExampleUnwind.class --function tutorial.ExampleUnwind.isPrime --unwind 10
120121

121-
will terminate (with `VERIFICATION SUCCESSFUL`).
122+
will terminate correctly. In this case, we will see `VERIFICATION SUCCESSFUL`,
123+
as no automatic assertions are violated.
122124

123125

124126
\subsection jbmc-manual-user-assert User assertions
@@ -128,20 +130,20 @@ JBMC will try do refute. On line 7, we check the assertion that all odd
128130
numbers greater than 1 are prime. To be sure that this always holds, we run
129131
JBMC on the example, with a reasonable `unwind` value:
130132

131-
jbmc ExampleUnwind.class --function tutorial.ExampleUnwind.doSomething --unwind 10
133+
$ jbmc ExampleUnwind.class --function tutorial.ExampleUnwind.doSomething --unwind 10
132134

133135
Unsurprisingly JBMC doesn't agree, and prints an assertion failure
134136
(truncated here for readability):
135-
136-
[...doSomething:(I)V.assertion.1] line 7 assertion at file tutorial/ExampleUnwind.java: FAILURE
137-
137+
```c
138+
[...doSomething:(I)V.assertion.1] line 7 assertion at file tutorial/ExampleUnwind.java: FAILURE
139+
```
138140

139141
Rerunning the analysis with the `--trace` option, the following line appears
140142
somewhere in the trace output and tells us which input value JBMC found to
141143
trigger the violation:
142-
143-
INPUT inputVal: 15
144-
144+
```c
145+
INPUT inputVal: 15
146+
```
145147
The value chosen by JBMC is arbitrary, and could as well be 9
146148
or 2084569161.
147149
Note that to see the original parameter names in the trace
@@ -178,16 +180,16 @@ public class ExampleModels {
178180
The following command line (note that the current directory is also added to
179181
the classpath):
180182

181-
jbmc ExampleModels.class --function tutorial.ExampleModels.stringOp --cp <path_to_cbmc>/jbmc/src/java_bytecode/library/core-models.jar:.
183+
$ jbmc ExampleModels.class --function tutorial.ExampleModels.stringOp --cp <path_to_cbmc>/jbmc/src/java_bytecode/library/core-models.jar:.
182184

183185
will flag this violation (truncated):
184-
185-
[java::tutorial.ExampleModels.stringOp:()V.assertion.1] line 8 assertion: FAILURE
186-
186+
```c
187+
[java::tutorial.ExampleModels.stringOp:()V.assertion.1] line 8 assertion: FAILURE
188+
```
187189
Again, the trace shows the string violating the condition in the assertion:
188-
189-
dynamic_object2={ 'a', 'b', '$', 'c', 'd' }
190-
190+
```c
191+
dynamic_object2={ 'a', 'b', '$', 'c', 'd' }
192+
```
191193
192194
\subsection jbmc-manual-exceptions Exceptions
193195
@@ -231,5 +233,5 @@ JBMC has a wealth of other options that can either constrain the model (to
231233
cope with complexity issues), or output more relevant information. The list
232234
of all available options is printed by running:
233235

234-
jbmc --help
236+
$ jbmc --help
235237

0 commit comments

Comments
 (0)
Please sign in to comment.