diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /Documentation/coccinelle.txt | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'Documentation/coccinelle.txt')
-rw-r--r-- | Documentation/coccinelle.txt | 54 |
1 files changed, 43 insertions, 11 deletions
diff --git a/Documentation/coccinelle.txt b/Documentation/coccinelle.txt index cd2b02837066..96b690348ba1 100644 --- a/Documentation/coccinelle.txt +++ b/Documentation/coccinelle.txt | |||
@@ -24,6 +24,9 @@ of many distributions, e.g. : | |||
24 | You can get the latest version released from the Coccinelle homepage at | 24 | You can get the latest version released from the Coccinelle homepage at |
25 | http://coccinelle.lip6.fr/ | 25 | http://coccinelle.lip6.fr/ |
26 | 26 | ||
27 | Information and tips about Coccinelle are also provided on the wiki | ||
28 | pages at http://cocci.ekstranet.diku.dk/wiki/doku.php | ||
29 | |||
27 | Once you have it, run the following command: | 30 | Once you have it, run the following command: |
28 | 31 | ||
29 | ./configure | 32 | ./configure |
@@ -33,6 +36,10 @@ as a regular user, and install it with | |||
33 | 36 | ||
34 | sudo make install | 37 | sudo make install |
35 | 38 | ||
39 | The semantic patches in the kernel will work best with Coccinelle version | ||
40 | 0.2.4 or later. Using earlier versions may incur some parse errors in the | ||
41 | semantic patch code, but any results that are obtained should still be | ||
42 | correct. | ||
36 | 43 | ||
37 | Using Coccinelle on the Linux kernel | 44 | Using Coccinelle on the Linux kernel |
38 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 45 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
@@ -41,20 +48,22 @@ A Coccinelle-specific target is defined in the top level | |||
41 | Makefile. This target is named 'coccicheck' and calls the 'coccicheck' | 48 | Makefile. This target is named 'coccicheck' and calls the 'coccicheck' |
42 | front-end in the 'scripts' directory. | 49 | front-end in the 'scripts' directory. |
43 | 50 | ||
44 | Four modes are defined: report, patch, context, and org. The mode to | 51 | Four modes are defined: patch, report, context, and org. The mode to |
45 | use is specified by setting the MODE variable with 'MODE=<mode>'. | 52 | use is specified by setting the MODE variable with 'MODE=<mode>'. |
46 | 53 | ||
54 | 'patch' proposes a fix, when possible. | ||
55 | |||
47 | 'report' generates a list in the following format: | 56 | 'report' generates a list in the following format: |
48 | file:line:column-column: message | 57 | file:line:column-column: message |
49 | 58 | ||
50 | 'patch' proposes a fix, when possible. | ||
51 | |||
52 | 'context' highlights lines of interest and their context in a | 59 | 'context' highlights lines of interest and their context in a |
53 | diff-like style.Lines of interest are indicated with '-'. | 60 | diff-like style.Lines of interest are indicated with '-'. |
54 | 61 | ||
55 | 'org' generates a report in the Org mode format of Emacs. | 62 | 'org' generates a report in the Org mode format of Emacs. |
56 | 63 | ||
57 | Note that not all semantic patches implement all modes. | 64 | Note that not all semantic patches implement all modes. For easy use |
65 | of Coccinelle, the default mode is "chain" which tries the previous | ||
66 | modes in the order above until one succeeds. | ||
58 | 67 | ||
59 | To make a report for every semantic patch, run the following command: | 68 | To make a report for every semantic patch, run the following command: |
60 | 69 | ||
@@ -68,9 +77,9 @@ To produce patches, run: | |||
68 | 77 | ||
69 | 78 | ||
70 | The coccicheck target applies every semantic patch available in the | 79 | The coccicheck target applies every semantic patch available in the |
71 | subdirectories of 'scripts/coccinelle' to the entire Linux kernel. | 80 | sub-directories of 'scripts/coccinelle' to the entire Linux kernel. |
72 | 81 | ||
73 | For each semantic patch, a changelog message is proposed. It gives a | 82 | For each semantic patch, a commit message is proposed. It gives a |
74 | description of the problem being checked by the semantic patch, and | 83 | description of the problem being checked by the semantic patch, and |
75 | includes a reference to Coccinelle. | 84 | includes a reference to Coccinelle. |
76 | 85 | ||
@@ -93,12 +102,35 @@ or | |||
93 | make coccicheck COCCI=<my_SP.cocci> MODE=report | 102 | make coccicheck COCCI=<my_SP.cocci> MODE=report |
94 | 103 | ||
95 | 104 | ||
105 | Using Coccinelle on (modified) files | ||
106 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
107 | |||
108 | To apply Coccinelle on a file basis, instead of a directory basis, the | ||
109 | following command may be used: | ||
110 | |||
111 | make C=1 CHECK="scripts/coccicheck" | ||
112 | |||
113 | To check only newly edited code, use the value 2 for the C flag, i.e. | ||
114 | |||
115 | make C=2 CHECK="scripts/coccicheck" | ||
116 | |||
117 | This runs every semantic patch in scripts/coccinelle by default. The | ||
118 | COCCI variable may additionally be used to only apply a single | ||
119 | semantic patch as shown in the previous section. | ||
120 | |||
121 | The "chain" mode is the default. You can select another one with the | ||
122 | MODE variable explained above. | ||
123 | |||
124 | In this mode, there is no information about semantic patches | ||
125 | displayed, and no commit message proposed. | ||
126 | |||
127 | |||
96 | Proposing new semantic patches | 128 | Proposing new semantic patches |
97 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 129 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
98 | 130 | ||
99 | New semantic patches can be proposed and submitted by kernel | 131 | New semantic patches can be proposed and submitted by kernel |
100 | developers. For sake of clarity, they should be organized in the | 132 | developers. For sake of clarity, they should be organized in the |
101 | subdirectories of 'scripts/coccinelle/'. | 133 | sub-directories of 'scripts/coccinelle/'. |
102 | 134 | ||
103 | 135 | ||
104 | Detailed description of the 'report' mode | 136 | Detailed description of the 'report' mode |
@@ -111,7 +143,7 @@ Example: | |||
111 | 143 | ||
112 | Running | 144 | Running |
113 | 145 | ||
114 | make coccicheck MODE=report COCCI=scripts/coccinelle/err_cast.cocci | 146 | make coccicheck MODE=report COCCI=scripts/coccinelle/api/err_cast.cocci |
115 | 147 | ||
116 | will execute the following part of the SmPL script. | 148 | will execute the following part of the SmPL script. |
117 | 149 | ||
@@ -149,7 +181,7 @@ identified. | |||
149 | Example: | 181 | Example: |
150 | 182 | ||
151 | Running | 183 | Running |
152 | make coccicheck MODE=patch COCCI=scripts/coccinelle/err_cast.cocci | 184 | make coccicheck MODE=patch COCCI=scripts/coccinelle/api/err_cast.cocci |
153 | 185 | ||
154 | will execute the following part of the SmPL script. | 186 | will execute the following part of the SmPL script. |
155 | 187 | ||
@@ -193,7 +225,7 @@ NOTE: The diff-like output generated is NOT an applicable patch. The | |||
193 | Example: | 225 | Example: |
194 | 226 | ||
195 | Running | 227 | Running |
196 | make coccicheck MODE=context COCCI=scripts/coccinelle/err_cast.cocci | 228 | make coccicheck MODE=context COCCI=scripts/coccinelle/api/err_cast.cocci |
197 | 229 | ||
198 | will execute the following part of the SmPL script. | 230 | will execute the following part of the SmPL script. |
199 | 231 | ||
@@ -228,7 +260,7 @@ diff -u -p /home/user/linux/crypto/ctr.c /tmp/nothing | |||
228 | Example: | 260 | Example: |
229 | 261 | ||
230 | Running | 262 | Running |
231 | make coccicheck MODE=org COCCI=scripts/coccinelle/err_cast.cocci | 263 | make coccicheck MODE=org COCCI=scripts/coccinelle/api/err_cast.cocci |
232 | 264 | ||
233 | will execute the following part of the SmPL script. | 265 | will execute the following part of the SmPL script. |
234 | 266 | ||