Skip to content

Commit

Permalink
zloop: check if core file is generated by zdb
Browse files Browse the repository at this point in the history
Run `gdb` core file inspection with correct program.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Gvozden Neskovic <[email protected]>
Closes #5215
  • Loading branch information
ironMann authored and behlendorf committed Oct 3, 2016
1 parent 62a65a6 commit 0c313d2
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions scripts/zloop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,26 @@ 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
{
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)"
Expand All @@ -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\"" \
Expand All @@ -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
Expand Down

0 comments on commit 0c313d2

Please sign in to comment.