Commit 3544d5ce authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull coccinelle updates from Julia Lawall:
 "This simplifies and clarifies the handling of output generated by
  Coccinelle that is sent to standard error.

  By default, this goes to /dev/null. Remind the user of that and
  encourage them to provide another file name (Benjamin Philip)"

* tag 'cocci-7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux:
  Documentation: Coccinelle: document debug log handling
  scripts: coccicheck: warn on unset debug file
  scripts: coccicheck: simplify debug file handling
parents 98136160 e3a22b53
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -127,6 +127,18 @@ To enable verbose messages set the V= variable, for example::

   make coccicheck MODE=report V=1

By default, coccicheck will print debug logs to stdout and redirect stderr to
/dev/null. This can make coccicheck output difficult to read and understand.
Debug and error messages can instead be written to a debug file instead by
setting the ``DEBUG_FILE`` variable::

    make coccicheck MODE=report DEBUG_FILE="cocci.log"

Coccinelle cannot overwrite a debug file. Instead of repeatedly deleting a log
file, you could include the datetime in the debug file name::

    make coccicheck MODE=report DEBUG_FILE="cocci-$(date -Iseconds).log"

Coccinelle parallelization
--------------------------

@@ -208,11 +220,10 @@ 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::
An easier approach to debug running Coccinelle against SmPL patches is to ask
coccicheck to redirect stderr to a debug file. As mentioned in the examples, 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
+13 −8
Original line number Diff line number Diff line
@@ -138,7 +138,7 @@ run_cmd_parmap() {
	if [ $VERBOSE -ne 0 ] ; then
		echo "Running ($NPROC in parallel): $@"
	fi
	if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then
	if [ "$DEBUG_FILE" != "/dev/null" ]; then
                echo $@>>$DEBUG_FILE
                $@ 2>>$DEBUG_FILE
        else
@@ -259,14 +259,19 @@ coccinelle () {

}

if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ]; then
if [ "$DEBUG_FILE" = "" ]; then
    echo 'You have not explicitly specified the debug file to use.'
    echo 'Using default "/dev/null" as debug file.'
    echo 'Debug logs will be printed to stdout.'
    echo 'You can specify the debug file with "make coccicheck DEBUG_FILE=<debug_file>"'
    echo ''
    DEBUG_FILE="/dev/null"
fi

if [ -f $DEBUG_FILE ]; then
	echo "Debug file $DEBUG_FILE exists, bailing"
	exit
fi
else
	DEBUG_FILE="/dev/null"
fi

if [ "$COCCI" = "" ] ; then
    for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do