Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
A little script which saved my soul one day I messed up with exceptions
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 19 Jul 2006 14:20:27 +0000 (14:20 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 19 Jul 2006 14:20:27 +0000 (14:20 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2633 48e7efb5-ca39-0410-a469-dd3cf9ba447f

tools/xbt_exception_checker [new file with mode: 0755]

diff --git a/tools/xbt_exception_checker b/tools/xbt_exception_checker
new file mode 100755 (executable)
index 0000000..3ebadcc
--- /dev/null
@@ -0,0 +1,43 @@
+#! /bin/bash
+
+# This little script parse a list of C files, and extract the TRY blocks of it.
+# Martin Quinson, 2006. 
+# Demerdierensiesich licence.
+
+# It can reveal usefull when you have a segfault on exception throwing. This
+# is often the symptom that something somewhere got out of a TRY block with
+# return, goto, break or such. This is forbiden because some extra cleanups
+# must be performed at the end of the block.
+
+# So, if it happens to you, you may find this script usefull: let it extract
+# all the TRY blocks of your project, and grep for the forbidden keywords
+# given above.
+
+# You obviously have to adapt it to your case. The proper solution would be
+# to accept the extra -I pathes from the command line. 
+# Patch welcome ;)
+
+for file in `find -name '*.c'` ; do
+
+base=`dirname $file`
+cmd="cat $file \
+      | cpp -I/home/mquinson/CVSIMPORT/gras/gras/include \
+            -I/home/mquinson/CVSIMPORT/gras/gras/src \
+           -I/home/mquinson/CVSIMPORT/gras/gras/src/include \
+           -I$base \
+           -D__XBT_EX_H__ -D_XBT_LOG_H_ \
+      | sed -n -e '/TRY/,/CATCH/p' \
+      | sed -e 's/^.*TRY.*$/----------------/' -e '/CATCH/d'"
+
+err=`eval $cmd 2>&1 >/dev/null`
+if [ -n "$err" ] ; then
+  echo "XXXXXXXXXX ERROR IN FILE $file"
+  echo $err
+fi
+
+if [ -n "`eval $cmd 2>/dev/null`" ] ; then
+  echo "XXX FILE $file"
+  eval "$cmd" 2>/dev/null
+fi
+
+done