From 4aec70690d7289f7f3a7f588c6cbebd718f95534 Mon Sep 17 00:00:00 2001
From: George Joseph <gjoseph@digium.com>
Date: Wed, 25 Oct 2017 11:26:06 -0600
Subject: [PATCH] ast_coredumper:  Add gzipping of binaries and display of
 signal info

The --tarball-coredump option now creates a gzipped tarball of
coredumps processed, their results txt files and copies of
/etc/os-release, /usr/sbin/asterisk, /usr/lib(64)/libasterisk* and
/usr/lib(64)/asterisk as those files are needed to properly examine
the coredump.  The file will be named
/tmp/asterisk.<timestamp>.coredumps.tar.gz or
/tmp/asterisk-<uniqueid>.coredumps.tar.gz if --tarball-uniqueid was
specified.

Added dumps of *_siginfo to the top of the txt files so you can
tell what signal was invoked.

Change-Id: Ib9ee6d83592d4b1bc90cb3419a05376a88d1ded9
---
 contrib/scripts/ast_coredumper | 41 ++++++++++++++++++++++++++++------
 1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/contrib/scripts/ast_coredumper b/contrib/scripts/ast_coredumper
index 81e94e9458..e5fc44eb3e 100755
--- a/contrib/scripts/ast_coredumper
+++ b/contrib/scripts/ast_coredumper
@@ -63,9 +63,15 @@ DESCRIPTION
 		from the existing coredumps.
 
 	--tarball-coredumps
-		Creates a gzipped tarball of all coredumps processed.
-		The tarball name will be:
-		/tmp/asterisk.<timestamp>.coredumps.tar.gz
+		Creates a gzipped tarball of coredumps processed, their
+		results txt files and copies of /etc/os-release,
+		/usr/sbin/asterisk, /usr/lib(64)/libasterisk* and
+		/usr/lib(64)/asterisk as those files are needed to properly
+		examine the coredump.  The file will be named
+		/tmp/asterisk.<timestamp>.coredumps.tar.gz or
+		/tmp/asterisk-<uniqueid>.coredumps.tar.gz if
+		--tarball-uniqueid was specified.
+		WARNING:  This file could 1gb in size!
 
 	--delete-coredumps-after
 		Deletes all processed coredumps regardless of whether
@@ -377,12 +383,25 @@ for i in ${!COREDUMPS[@]} ; do
 done
 
 if $tarball_coredumps ; then
-	tf=/tmp/asterisk-$df.coredumps.tar
-	echo "Creating $tf.gz"
+	tf=/tmp/asterisk-$df.coredumps.tar.gz
+	echo "Creating $tf"
+	dest=/tmp/asterisk-$df
+	rm -rf $dest 2>/dev/null || :
+	libdir=usr/lib
+	[ -d /usr/lib64 ] && libdir+=64
+	mkdir -p $dest/tmp $dest/$libdir/asterisk $dest/etc $dest/usr/sbin
 	for i in ${!COREDUMPS[@]} ; do
-		tar -uvf $tf "${COREDUMPS[@]}" 2>/dev/null
+		ln -s "${COREDUMPS[@]}" $dest/"${COREDUMPS[@]}"
+		cp "${COREDUMPS[@]}"*.txt $dest/tmp/
 	done
-	gzip $tf
+	cp /etc/os-release $dest/etc/
+	cp -a /$libdir/libasterisk* $dest/$libdir/
+	cp -a /$libdir/asterisk/* $dest/$libdir/asterisk/
+	cp -a /usr/sbin/asterisk $dest/usr/sbin
+	rm -rf $tf
+	tar -chzf $tf --transform="s/^[.]/$df/" -C $dest .
+	rm -rf $dest
+	echo "Created $tf"
 fi
 
 if $delete_coredumps_after ; then
@@ -431,21 +450,29 @@ class DumpAsteriskCommand(gdb.Command):
             pass
         print("!@!@!@! thread1.txt !@!@!@!\n")
         try:
+            gdb.execute("p $_siginfo", from_tty)
+            gdb.execute("info signal $_siginfo.si_signo")
             gdb.execute("thread apply 1 bt full", from_tty)
         except:
             pass
         print("!@!@!@! brief.txt !@!@!@!\n")
         try:
+            gdb.execute("p $_siginfo", from_tty)
+            gdb.execute("info signal $_siginfo.si_signo")
             gdb.execute("thread apply all bt", from_tty)
         except:
             pass
         print("!@!@!@! full.txt !@!@!@!\n")
         try:
+            gdb.execute("p $_siginfo", from_tty)
+            gdb.execute("info signal $_siginfo.si_signo")
             gdb.execute("thread apply all bt full", from_tty)
         except:
             pass
         print("!@!@!@! locks.txt !@!@!@!\n")
         try:
+            gdb.execute("p $_siginfo", from_tty)
+            gdb.execute("info signal $_siginfo.si_signo")
             gdb.execute("show_locks", from_tty)
         except:
             pass
-- 
GitLab