aboutsummaryrefslogtreecommitdiff
path: root/contrib/scripts/debug
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/scripts/debug')
-rwxr-xr-xcontrib/scripts/debug37
1 files changed, 37 insertions, 0 deletions
diff --git a/contrib/scripts/debug b/contrib/scripts/debug
new file mode 100755
index 0000000000..3de2c9a14c
--- /dev/null
+++ b/contrib/scripts/debug
@@ -0,0 +1,37 @@
+#!/bin/bash
+# /proc/sys/kernel/core_pattern should be core.%p.%E
+
+COREPID=$1
+
+COREFILES=`ls -1 *core.$COREPID* 2>/dev/null | wc -l`
+COREFILE=`ls -1 *core.$COREPID* 2>/dev/null | head -n 1`
+
+if [ $COREFILES -gt 1 ]; then
+ echo "Multiple files, using $COREFILE"
+fi
+
+
+if [ $COREFILES -eq 0 ]; then
+ SERVICENAME=$1
+ COREFILES=`ls -1 core.*.*$SERVICENAME 2>/dev/null | wc -l`
+ COREFILE=`ls -1 core.*.*$SERVICENAME 2>/dev/null | head -n 1`
+
+ if [ $COREFILES -gt 1 ]; then
+ echo "Multiple files, using $COREFILE"
+ fi
+fi
+
+if [ $COREFILES -eq 0 ]; then
+ echo "Core file for $1 not found"
+ exit 1
+fi
+
+echo "Using $COREFILE"
+
+EXECPATH=${COREFILE#*!}
+EXECPATH=`echo $EXECPATH | sed -e 's/!/\//g'`
+echo $EXECPATH
+echo ""
+echo ""
+
+gdb --core $COREFILE /$EXECPATH