]> granicus.if.org Git - zfs/commitdiff
zloop: check if core file is generated by zdb
authorGvozden Neskovic <neskovic@gmail.com>
Mon, 3 Oct 2016 22:42:13 +0000 (00:42 +0200)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 3 Oct 2016 22:42:13 +0000 (15:42 -0700)
Run `gdb` core file inspection with correct program.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Gvozden Neskovic <neskovic@gmail.com>
Closes #5215

scripts/zloop.sh

index 8125229a8cb1ebbba8da494f342d814eac16e902..580fcfe40a82d1a544ad1cea4b5bf0d4ef6bd73f 100755 (executable)
@@ -70,7 +70,8 @@ coreglob="$(egrep -o '^([^|%[:space:]]*)' /proc/sys/kernel/core_pattern)*"
 if [[ $coreglob = "*" ]]; then
         echo "Setting core file pattern..."
         echo "core" > /proc/sys/kernel/core_pattern
-        coreglob="$(egrep -o '^([^|%[:space:]]*)' /proc/sys/kernel/core_pattern)*"
+        coreglob="$(egrep -o '^([^|%[:space:]]*)' \
+            /proc/sys/kernel/core_pattern)*"
 fi
 
 function core_file
@@ -78,6 +79,17 @@ function core_file
         printf "%s" "$(ls -tr1 $coreglob 2> /dev/null | head -1)"
 }
 
+function core_prog
+{
+       prog=$ZTEST
+       core_id=$($GDB --batch -c $1 | grep "Core was generated by" | \
+           tr  \' ' ')
+       if [[ "$core_id" =~ "zdb "  ]]; then
+               prog=$ZDB
+       fi
+       printf "%s" "$prog"
+}
+
 function store_core
 {
        core="$(core_file)"
@@ -99,6 +111,7 @@ function store_core
 
                # check for core
                if [[ -f "$core" ]]; then
+                       coreprog=$(core_prog $core)
                        corestatus=$($GDB --batch --quiet \
                            -ex "set print thread-events off" \
                            -ex "printf \"*\n* Backtrace \n*\n\"" \
@@ -111,7 +124,7 @@ function store_core
                            -ex "thread apply all bt" \
                            -ex "printf \"*\n* Backtraces (full) \n*\n\"" \
                            -ex "thread apply all bt full" \
-                           -ex "quit" $ZTEST "$core" | grep -v "New LWP")
+                           -ex "quit" $coreprog "$core" | grep -v "New LWP")
 
                        # Dump core + logs to stored directory
                        echo "$corestatus" >>$dest/status