]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Rationalize backtrace logging
authorMichal Nowak <mnowak@isc.org>
Mon, 22 Jun 2020 13:56:50 +0000 (15:56 +0200)
committerMichal Nowak <mnowak@isc.org>
Mon, 20 Jul 2020 10:48:29 +0000 (12:48 +0200)
GDB backtrace generated via "thread apply all bt full" is too long for
standard output, lets save them to .txt file among other log files.

bin/tests/system/run.sh

index 03f7fa08fcdd10c94bb6dfe6259da8e385bfadca..98d388763de78f9cce32efcc6088e6806d12062b 100755 (executable)
@@ -253,28 +253,43 @@ else
     exit $status
 fi
 
+get_core_dumps() {
+    find "$systest/" \( -name 'core*' -or -name '*.core' \) ! -name '*.gz' ! -name '*.txt' | sort
+}
+
 if [ $status != 0 ]; then
     echofail "R:$systest:FAIL"
     # Do not clean up - we need the evidence.
 else
-    core_dumps="$(find $systest/ -name 'core*' -or -name '*.core' | sort | tr '\n' ' ')"
-    assertion_failures=$(find $systest/ -name named.run | xargs grep "assertion failure" | wc -l)
-    sanitizer_summaries=$(find $systest/ -name 'tsan.*' | wc -l)
+    core_dumps=$(get_core_dumps | tr '\n' ' ')
+    assertion_failures=$(find "$systest/" -name named.run -print0 | xargs -0 grep "assertion failure" | wc -l)
+    sanitizer_summaries=$(find "$systest/" -name 'tsan.*' | wc -l)
     if [ -n "$core_dumps" ]; then
         echoinfo "I:$systest:Test claims success despite crashes: $core_dumps"
         echofail "R:$systest:FAIL"
         # Do not clean up - we need the evidence.
-       find "$systest/" -name 'core*' -or -name '*.core' | while read -r coredump; do
+       get_core_dumps | while read -r coredump; do
                SYSTESTDIR="$systest"
-               echoinfo "D:$systest:backtrace from $coredump start"
-               binary=$(gdb --batch --core="$coredump" | sed -ne "s/Core was generated by \`//;s/ .*'.$//p;")
-               "$TOP/libtool" --mode=execute gdb \
-                              --batch \
-                              --command=run.gdb \
-                              --core="$coredump" \
-                              -- \
-                              "$binary"
-               echoinfo "D:$systest:backtrace from $coredump end"
+               echoinfo "D:$systest:backtrace from $coredump:"
+               echoinfo "D:$systest:--------------------------------------------------------------------------------"
+               binary=$(gdb --batch --core="$coredump" 2>/dev/null | sed -ne "s/Core was generated by \`//;s/ .*'.$//p;")
+               "${TOP}/libtool" --mode=execute gdb \
+                                         -batch \
+                                         -ex bt \
+                                         -core="$coredump" \
+                                         -- \
+                                         "$binary" 2>/dev/null | sed -n '/^Core was generated by/,$p' | cat_d
+               echoinfo "D:$systest:--------------------------------------------------------------------------------"
+               coredump_backtrace=$(basename "${coredump}")-backtrace.txt
+               echoinfo "D:$systest:full backtrace from $coredump saved in $coredump_backtrace"
+               "${TOP}/libtool" --mode=execute gdb \
+                                         -batch \
+                                         -command=run.gdb \
+                                         -core="$coredump" \
+                                         -- \
+                                         "$binary" > "$coredump_backtrace" 2>&1
+               echoinfo "D:$systest:core dump $coredump archived as $coredump.gz"
+               gzip -1 "${coredump}"
        done
     elif [ "$assertion_failures" -ne 0 ]; then
        SYSTESTDIR="$systest"
@@ -287,11 +302,9 @@ else
         echofail "R:$systest:FAIL"
     else
         echopass "R:$systest:PASS"
-        if $clean
-        then
+        if $clean; then
             ( cd $systest && $SHELL clean.sh "$@" )
-            if test -d ../../../.git
-            then
+            if test -d ../../../.git; then
                 git status -su --ignored $systest 2>/dev/null | \
                 sed -n -e 's|^?? \(.*\)|I:file \1 not removed|p' \
                 -e 's|^!! \(.*/named.run\)$|I:file \1 not removed|p' \