diff options
Diffstat (limited to 'contrib/scripts/debug')
-rwxr-xr-x | contrib/scripts/debug | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/contrib/scripts/debug b/contrib/scripts/debug new file mode 100755 index 000000000..3de2c9a14 --- /dev/null +++ b/contrib/scripts/debug | |||
@@ -0,0 +1,37 @@ | |||
1 | #!/bin/bash | ||
2 | # /proc/sys/kernel/core_pattern should be core.%p.%E | ||
3 | |||
4 | COREPID=$1 | ||
5 | |||
6 | COREFILES=`ls -1 *core.$COREPID* 2>/dev/null | wc -l` | ||
7 | COREFILE=`ls -1 *core.$COREPID* 2>/dev/null | head -n 1` | ||
8 | |||
9 | if [ $COREFILES -gt 1 ]; then | ||
10 | echo "Multiple files, using $COREFILE" | ||
11 | fi | ||
12 | |||
13 | |||
14 | if [ $COREFILES -eq 0 ]; then | ||
15 | SERVICENAME=$1 | ||
16 | COREFILES=`ls -1 core.*.*$SERVICENAME 2>/dev/null | wc -l` | ||
17 | COREFILE=`ls -1 core.*.*$SERVICENAME 2>/dev/null | head -n 1` | ||
18 | |||
19 | if [ $COREFILES -gt 1 ]; then | ||
20 | echo "Multiple files, using $COREFILE" | ||
21 | fi | ||
22 | fi | ||
23 | |||
24 | if [ $COREFILES -eq 0 ]; then | ||
25 | echo "Core file for $1 not found" | ||
26 | exit 1 | ||
27 | fi | ||
28 | |||
29 | echo "Using $COREFILE" | ||
30 | |||
31 | EXECPATH=${COREFILE#*!} | ||
32 | EXECPATH=`echo $EXECPATH | sed -e 's/!/\//g'` | ||
33 | echo $EXECPATH | ||
34 | echo "" | ||
35 | echo "" | ||
36 | |||
37 | gdb --core $COREFILE /$EXECPATH | ||