From 0c313d2f7451041e9cc952fe68fb500efef52fe1 Mon Sep 17 00:00:00 2001 From: Gvozden Neskovic Date: Tue, 4 Oct 2016 00:42:13 +0200 Subject: [PATCH] zloop: check if core file is generated by zdb Run `gdb` core file inspection with correct program. Reviewed-by: Brian Behlendorf Signed-off-by: Gvozden Neskovic Closes #5215 --- scripts/zloop.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/zloop.sh b/scripts/zloop.sh index 8125229a8..580fcfe40 100755 --- a/scripts/zloop.sh +++ b/scripts/zloop.sh @@ -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 -- 2.40.0