db: export get_static_filter()
[smatch.git] / Documentation / smatch.txt
blob96acd56d4a8402e80e6ec22cd40b325ac6d70376
1 Smatch
3 1.  Building Smatch
4 2.  Using Smatch
5 3.  Smatch vs Sparse
8 Section 1:  Building Smatch
9 ---------------------------
11 Smatch requires sqlite3.  It requires the binaries and the C, Perl and
12 Python libraries for sqlite3.
14 apt-get install sqlite3 libsqlite3-dev libdbd-sqlite3-perl
16 Smatch is easy to build.  Just type `make`.  There isn't an install process
17 right now so just run it from the build directory.
20 Section 2:  Using Smatch
21 ------------------------
23 Smatch can be used with a cross function database. It's not mandatory to
24 build the database but it's a useful thing to do.  Building the database
25 for the kernel takes 2-3 hours on my computer.  For the kernel you build
26 the database with:
28         ~/progs/smatch/devel/smatch_scripts/build_kernel_data.sh
30 For projects other than the kernel you run Smatch with the options
31 "--call-tree --info --param-mapper --spammy" and finish building the
32 database by running the script:
34         ~/progs/smatch/devel/smatch_data/db/create_db.sh
36 Each time you rebuild the cross function database it becomes more accurate. I
37 normally rebuild the database every morning.
39 If you are running Smatch over the whole kernel you can use the following
40 command:
42         ~/progs/smatch/devel/smatch_scripts/test_kernel.sh
44 The test_kernel.sh script will create a .c.smatch file for every file it tests
45 and a combined warns.txt file with all the warnings.
47 If you are running Smatch just over one kernel file:
49         ~/progs/smatch/devel/smatch_scripts/kchecker drivers/whatever/file.c
51 You can also build a directory like this:
53         ~/progs/smatch/devel/smatch_scripts/kchecker drivers/whatever/
55 The kchecker script prints its warnings to stdout.
57 If you are building something else (which is not the Linux kernel) then use
58 something like:
60         make CHECK="~/progs/smatch/devel/smatch --full-path" \
61                 CC=~/progs/smatch/devel/smatch/cgcc | tee warns.txt
63 The makefile has to let people set the CC with an environment variable for that
64 to work, of course.
67 Section 3:  Smatch vs Sparse
68 ----------------------------
70 Smatch uses Sparse as a C parser.  I have made a few hacks to Sparse so I
71 have to distribute the two together.  Sparse is released under the MIT license
72 and Smatch is GPLv2+.  If you make changes to Sparse please send those to the
73 Sparse mailing list linux-sparse@vger.kernel.org and I will pick them up from
74 there.  Partly I do that for licensing reasons because I don't want to pull GPL
75 changes into the Sparse code I re-distribute.