Browse Source

- add a coccinelle example version of check_register.sh

Olivier Aumage 13 years ago
parent
commit
c2d5cbaaa5
2 changed files with 59 additions and 0 deletions
  1. 44 0
      tools/dev/starpu_check_register.cocci
  2. 15 0
      tools/dev/starpu_check_register.sh

+ 44 - 0
tools/dev/starpu_check_register.cocci

@@ -0,0 +1,44 @@
+@initialize:python@
+handles = {}
+
+
+@select@
+position p;
+identifier f =~ "^starpu_.*_data_register$";
+identifier e;
+@@
+<...
+f@p( &e, ... );
+...>
+@script:python@
+p << select.p;
+f << select.f;
+e << select.e;
+@@
+s = "%s(%s),%s:%s" % (f,e,p[0].file,p[0].line)
+# hack: 'clean' the string e from unwanted non printing characters, otherwise 'e' in select rule does not match 'e' in check rule
+e = "%s" % e
+handles[e]=s
+
+
+@check@
+position p;
+identifier select.e;
+@@
+<...
+starpu_data_unregister@p( e );
+...>
+@script:python@
+e << select.e;
+p << check.p;
+@@
+# hack: position p must be defined in the check rule even though it is not used, otherwise the 'check' python script is not run
+e = "%s" % e
+if e in handles:
+        del handles[e]
+
+
+@finalize:python@
+for s in handles.values():
+        print s
+

+ 15 - 0
tools/dev/starpu_check_register.sh

@@ -0,0 +1,15 @@
+#!/bin/bash
+# Note: expects Coccinelle's spatch command n the PATH
+# See: http://coccinelle.lip6.fr/
+stcolor=$(tput sgr0)
+redcolor=$(tput setaf 1)
+
+handles=$(spatch -very_quiet -sp_file tools/dev/starpu_check_register.cocci "$@")
+if test "x$handles" != "x" ; then
+	for handle in $handles; do
+		echo "$handle"
+		register=$(echo $handle|awk -F ',' '{print $1}')
+		location=$(echo $handle|awk -F ',' '{print $2}')
+		echo "data handle ${redcolor}${register}${stcolor} registered at location $location does not seem to be properly unregistered"
+	done
+fi