]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
coccicheck: add support for DEBUG_FILE
authorLuis R. Rodriguez <mcgrof@kernel.org>
Wed, 29 Jun 2016 22:14:54 +0000 (15:14 -0700)
committerMichal Marek <mmarek@suse.com>
Fri, 22 Jul 2016 10:13:39 +0000 (12:13 +0200)
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>
Documentation/coccinelle.txt
scripts/coccicheck

index 64daaf18874b4557ab71765f1e3d8f698c642c15..2516c5ef16916451d9292243fbcde090470d1bbb 100644 (file)
@@ -157,6 +157,26 @@ semantic patch as shown in the previous section.
 The "report" mode is the default. You can select another one with the
 MODE variable explained above.
 
+ Debugging Coccinelle SmPL patches
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Using coccicheck is best as it provides in the spatch command line
+include options matching the options used when we compile the kernel.
+You can learn what these options are by using V=1, you could then
+manually run Coccinelle with debug options added.
+
+Alternatively you can debug running Coccinelle against SmPL patches
+by asking for stderr to be redirected to stderr, by default stderr
+is redirected to /dev/null, if you'd like to capture stderr you
+can specify the DEBUG_FILE="file.txt" option to coccicheck. For
+instance:
+
+    rm -f cocci.err
+    make coccicheck COCCI=scripts/coccinelle/free/kfree.cocci MODE=report DEBUG_FILE=cocci.err
+    cat cocci.err
+
+DEBUG_FILE support is only supported when using coccinelle >= 1.2.
+
  Additional flags
 ~~~~~~~~~~~~~~~~~~
 
index 4b65a0fd50a118b7ef0563a6498fa6a896eefdec..3f0bb3f0fddc56edabff70147bf5153d7d2b5f7b 100755 (executable)
@@ -96,7 +96,15 @@ run_cmd_parmap() {
        if [ $VERBOSE -ne 0 ] ; then
                echo "Running ($NPROC in parallel): $@"
        fi
-       $@ 2>/dev/null
+       if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then
+               if [ -f $DEBUG_FILE ]; then
+                       echo "Debug file $DEBUG_FILE exists, bailing"
+                       exit
+               fi
+       else
+               DEBUG_FILE="/dev/null"
+       fi
+       $@ 2>$DEBUG_FILE
        if [[ $? -ne 0 ]]; then
                echo "coccicheck failed"
                exit $?