@@ -16,12 +16,27 @@ to the basic data structures and workflow needed for contributing to
16
16
17
17
## Initial setup
18
18
19
- Clone the [ CBMC repository] [ cbmc-repo ] and build it:
19
+ Clone the [ CBMC repository] [ cbmc-repo ] and build it. The build instructions are
20
+ written in a file called COMPILING.md in the top level of the repository. I
21
+ recommend that you build using CMake---this will place all of the CBMC tools in
22
+ a single directory, which you can add to your ` $PATH ` . For example, if you built
23
+ the codebase with the following two commands at the top level of the repository:
24
+
25
+ cmake -DCMAKE_CXX_FLAGS=-fcolor-diagnostics \
26
+ -DCMAKE_BUILD_TYPE=Debug \
27
+ -DWITH_JBMC=OFF \
28
+ -DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
29
+ -DCMAKE_C_COMPILER=/usr/bin/clang \
30
+ -B build -S .
31
+ cmake --build build
32
+
33
+ then all the CBMC binaries will be built into ` build/bin ` , and you can run the
34
+ following commands to make CBMC invokable from your terminal.
20
35
21
- git clone https://github.com/diffblue/cbmc.git
22
- cd cbmc/src
23
- make minisat2-download
24
- make
36
+ # Assuming you cloned CBMC into ~/code
37
+ export PATH=~/code/ cbmc/build/bin:$PATH
38
+ # Add to your shell's startup configuration file so that you don't have to run that command every time.
39
+ echo 'export PATH=~/code/cbmc/build/bin:$PATH' >> .bashrc
25
40
26
41
Ensure that [ graphviz] [ graphviz ] is installed on your system (in
27
42
particular, you should be able to run a program called ` dot ` ). Install
@@ -30,48 +45,29 @@ particular, you should be able to run a program called `dot`). Install
30
45
# In the src directory
31
46
doxygen doxyfile
32
47
# View the documentation in a web browser
33
- firefox doxy /html/index.html
48
+ firefox ~/code/cbmc/doc /html/index.html
34
49
35
50
If you've never used doxygen documentation before, get familiar with the
36
51
layout. Open the generated HTML page in a web browser; search for the
37
52
class ` goto_programt ` in the search bar, and jump to the documentation
38
53
for that class; and read through the copious documentation.
39
54
40
- The build writes executable programs into several of the source
41
- directories. In this tutorial, we'll be using binaries inside the
42
- ` cbmc ` , ` goto-instrument ` , and ` goto-cc ` directories. Add these
43
- directories to your ` $PATH ` :
44
-
45
- # Assuming you cloned CBMC into ~/code
46
- export PATH=~/code/cbmc/src/goto-instrument:~/code/cbmc/src/goto-cc:~/code/cbmc/src/cbmc:$PATH
47
- # Add to your shell's startup configuration file so that you don't have to run that command every time.
48
- echo 'export PATH=~/code/cbmc/src/goto-instrument:~/code/cbmc/src/goto-cc:~/code/cbmc/src/cbmc:$PATH' >> .bashrc
49
-
50
- Optional: install an image viewer that can read images on stdin.
51
- I use [ feh] [ feh ] .
52
-
53
55
[ cbmc-repo ] : https://github.com/diffblue/cbmc/
54
56
[ doxygen ] : http://www.stack.nl/~dimitri/doxygen/
55
57
[ graphviz ] : http://www.graphviz.org/
56
- [ feh ] : https://feh.finalrewind.org/
57
-
58
58
59
59
60
60
## Whirlwind tour of the tools
61
61
62
- CBMC's code is located under the ` cbmc ` directory. Even if you plan to
62
+ CBMC's code is located under the ` src ` directory. Even if you plan to
63
63
contribute only to CBMC, it is important to be familiar with several
64
64
other of cprover's auxiliary tools.
65
65
66
66
67
67
### Compiling with ` goto-cc `
68
68
69
- There should be an executable file called ` goto-cc ` in the ` goto-cc `
70
- directory; make a symbolic link to it called ` goto-gcc ` :
71
-
72
- cd cbmc/src/goto-cc
73
- ln -s "$(pwd)/goto-cc" goto-gcc
74
-
69
+ If you built using CMake on Unix, you should be able to run the
70
+ ` goto-gcc ` command.
75
71
Find or write a moderately-interesting C program; we'll call it ` main.c ` .
76
72
Run the following commands:
77
73
@@ -102,16 +98,10 @@ structured programming constructs.
102
98
103
99
Find or write a small C program (2 or 3 functions, each containing a few
104
100
varied statements). Compile it using ` goto-gcc ` as above into an object
105
- file called ` main ` . If you installed ` feh ` , try the following command
106
- to dump a control-flow graph:
107
-
108
- goto-instrument --dot main | tail -n +2 | dot -Tpng | feh -
109
-
110
- If you didn't install ` feh ` , you can write the diagram to the file and
111
- then view it:
101
+ file called ` main ` . You can write the diagram to a file and then view it:
112
102
113
- goto-instrument --dot main | tail -n +2 | dot -Tpng > main.png
114
- Now open main.png with an image viewer
103
+ goto-instrument --dot main.goto | tail -n +2 | dot -Tpng > main.png
104
+ open main.png
115
105
116
106
(the invocation of ` tail ` is used to filter out the first line of
117
107
` goto-instrument ` output. If ` goto-instrument ` writes more or less
@@ -148,7 +138,7 @@ At some point in that function, there will be a long sequence of `if` statements
148
138
** Task:** Add a ` --greet ` switch to ` goto-instrument ` , taking an optional
149
139
argument, with the following behaviour:
150
140
151
- $ goto-instrument --greet main
141
+ $ goto-instrument --greet main.goto
152
142
hello, world!
153
143
$ goto-instrument --greet Leperina main
154
144
hello, Leperina!
0 commit comments