Skip to content

Commit be1fa90

Browse files
mcgrofMichal Marek
authored and
Michal Marek
committed
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 <[email protected]> Acked-by: Nicolas Palix <[email protected]> Signed-off-by: Michal Marek <[email protected]>
1 parent c930a1b commit be1fa90

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Diff for: Documentation/coccinelle.txt

+20
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,26 @@ semantic patch as shown in the previous section.
157157
The "report" mode is the default. You can select another one with the
158158
MODE variable explained above.
159159

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+
160180
Additional flags
161181
~~~~~~~~~~~~~~~~~~
162182

Diff for: scripts/coccicheck

+9-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,15 @@ run_cmd_parmap() {
9696
if [ $VERBOSE -ne 0 ] ; then
9797
echo "Running ($NPROC in parallel): $@"
9898
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
100108
if [[ $? -ne 0 ]]; then
101109
echo "coccicheck failed"
102110
exit $?

0 commit comments

Comments
 (0)