Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

coccicheck: add support for DEBUG_FILE

Enable to capture stderr via a DEBUG_FILE variable passed to
coccicheck. You can now do:

$ rm -f cocci.err
$ export COCCI=scripts/coccinelle/free/kfree.cocci
$ make coccicheck MODE=report DEBUG_FILE=cocci.err
...
$ cat cocci.err

This will be come more useful once we add support to
use more things which would go into stderr, such as
profiling. That will be done separately in another
commit.

Expand Documentation/coccinelle.txt with details.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Acked-by: Nicolas Palix <nicolas.palix@imag.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>

authored by

Luis R. Rodriguez and committed by
Michal Marek
be1fa900 c930a1b2

+29 -1
+20
Documentation/coccinelle.txt
··· 157 157 The "report" mode is the default. You can select another one with the 158 158 MODE variable explained above. 159 159 160 + Debugging Coccinelle SmPL patches 161 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 162 + 163 + Using coccicheck is best as it provides in the spatch command line 164 + include options matching the options used when we compile the kernel. 165 + You can learn what these options are by using V=1, you could then 166 + manually run Coccinelle with debug options added. 167 + 168 + Alternatively you can debug running Coccinelle against SmPL patches 169 + by asking for stderr to be redirected to stderr, by default stderr 170 + is redirected to /dev/null, if you'd like to capture stderr you 171 + can specify the DEBUG_FILE="file.txt" option to coccicheck. For 172 + instance: 173 + 174 + rm -f cocci.err 175 + make coccicheck COCCI=scripts/coccinelle/free/kfree.cocci MODE=report DEBUG_FILE=cocci.err 176 + cat cocci.err 177 + 178 + DEBUG_FILE support is only supported when using coccinelle >= 1.2. 179 + 160 180 Additional flags 161 181 ~~~~~~~~~~~~~~~~~~ 162 182
+9 -1
scripts/coccicheck
··· 96 96 if [ $VERBOSE -ne 0 ] ; then 97 97 echo "Running ($NPROC in parallel): $@" 98 98 fi 99 - $@ 2>/dev/null 99 + if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then 100 + if [ -f $DEBUG_FILE ]; then 101 + echo "Debug file $DEBUG_FILE exists, bailing" 102 + exit 103 + fi 104 + else 105 + DEBUG_FILE="/dev/null" 106 + fi 107 + $@ 2>$DEBUG_FILE 100 108 if [[ $? -ne 0 ]]; then 101 109 echo "coccicheck failed" 102 110 exit $?