From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 910466C7D2; Thu, 11 Feb 2021 21:48:34 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 910466C7D2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1613069314; bh=DbEsLpTr2VYKQHMj0n1rPPuNyU3/9Lr0SCpuOnbLf/4=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=BTXK5l3q5YmkmQvQaIE1aJtwx1U1IkPmPRLe9+PhuC4uWwf6HHviy6vdjNq4VsXBo ps3h0hnIUp9phiO4zJndX/u/DMPI4otm9xmI2aMDupE1CCVjlyrYBwn10JtPQE975e Ex+fK9qc2eRO1Ov6fT28+rpLschWtioTMJ6i9EM4= Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 691796C7D2 for ; Thu, 11 Feb 2021 21:48:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 691796C7D2 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1lAH0v-0006U5-Gi; Thu, 11 Feb 2021 21:48:30 +0300 To: Sergey Ostanevich , Sergey Kaplun , Alexander Turenko , Nikita Pettik , Aleksandr Lyapunov , Serge Petrenko , Sergey Bronnikov Date: Thu, 11 Feb 2021 21:48:28 +0300 Message-Id: X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD981647AC6901E234B939F02D0E92C1ADFFCD11FC915E146DC182A05F5380850409F73A023D8531A049D8B39B30764393CB17D77A4B88444308F6117AA92684066 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE751DD1FEBB966604DEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637D4360D888D8F9BE48638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FC56A27CA748E123E1C41AEB91507A347BE35909B537A8ED4D389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B64854413538E1713FCC7F00164DA146DA6F5DAA56C3B73B23C77107234E2CFBA567F23339F89546C55F5C1EE8F4F765FCB835E6E385EA5AF075ECD9A6C639B01BBD4B6F7A4D31EC0BC0CAF46E325F83A522CA9DD8327EE4930A3850AC1BE2E7358734EF69C36C4A4DC4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0F05F538519369F3743B503F486389A921A5CC5B56E945C8DA X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CD27AC6BE5C1CDEA936640579A14572A42CC5C3D768B047509C2B6934AE262D3EE7EAB7254005DCEDBCB26E97D93E90E81E0A4E2319210D9B64D260DF9561598F01A9E91200F654B0CCA28C6D779E2CD78E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3454CC76E5F54B410C5C77B1AF5A64110521ECDCFB720F5901E56981CA31E0404042A47AF8272451C81D7E09C32AA3244C96161678EE42AF5524B396D5991AE34039C99C45E8D137E927AC49D2B05FCCD8 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojmjFTaBTEi1awWgWhOuugWA== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822E5A0A93F811A6901449DE04921D221C4A7C8D0F45F857DBFE9F1EFEE2F478337FB559BB5D741EB964C8C2C849690F8E70A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH] WIP: introduce tooling for coredumps X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Signed-off-by: Igor Munkin --- WARNING: This patch doesn't require full and precise review now. I chose those folks from core team, who either works with customer reports a lot or liked the ticket[1]. I hope I missed nobody, but if I did the patch is available in our ml. I've polished a bit two scripts I often use: * tarabrt.sh (so called tarcore.sh) -- this is the script collecting a tarball with the coredump the right way: with the binary, all loaded shared libs, Tarantool version (this is a separate exercise to get it from the binary built with -O2). Besides, I made the tarball struct unified so it can be easily processed with the second script. * gdb.sh -- the auxiliary script originally written by Sasha Tu, that needed to be adjusted to the customer artefacts every time. Since we will have a unified layout I enhanced it a bit to automatically load the coredump via gdb the right way. Check this out[2], try both scripts and reach me with your feedback! [1]: https://github.com/tarantool/tarantool/issues/5569 [2]: https://github.com/tarantool/tarantool/tree/imun/gh-5569-coredump-tooling tools/gdb.sh | 33 +++++++++++++++ tools/tarabrt.sh | 102 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100755 tools/gdb.sh create mode 100755 tools/tarabrt.sh diff --git a/tools/gdb.sh b/tools/gdb.sh new file mode 100755 index 000000000..4daac7106 --- /dev/null +++ b/tools/gdb.sh @@ -0,0 +1,33 @@ +#!/bin/sh +set -eu + +# Check that gdb is installed. +type gdb &> /dev/null + +VERSION=${PWD}/version + +[ -f "$VERSIONFILE" ] || (echo 'Invalid coredump location'; exit 1) + +REVISION=$(grep -oP 'Tarantool \d+\.\d+\.\d+-\d+-g\K[a-f0-9]+' "$VERSION") +cat < definition +# considering it is located in src/main.cc within Tarantool repo. +SUBPATH=$(gdb -batch ./tarantool -ex 'info line main' | \ + grep -oP 'Line \d+ of \"\K.+(?=\/src\/main\.cc\")') + +gdb ./tarantool \ + -ex "set sysroot $(realpath .)" \ + -ex "set substitute-path $SUBPATH sources" \ + -ex 'core coredump' diff --git a/tools/tarabrt.sh b/tools/tarabrt.sh new file mode 100755 index 000000000..92252899b --- /dev/null +++ b/tools/tarabrt.sh @@ -0,0 +1,102 @@ +#!/bin/sh +set -eu + +USAGE=$(cat < "${COREFILE}" +fi + +GDBERROR=$(cat < /dev/null || ([ -t 1 ] && echo "$GDBERROR") + +# Resolve hostname if possible. +HOSTNAME=$(timeout 2>/dev/null -s 9 1 hostname -f \ + || hostname 2>/dev/null \ + || echo hostname) + +# Proceed with collecting and packing artefacts. +TMPDIR=$(mktemp -d -p "${COREDIR}") +TARLIST=${TMPDIR}/tarlist +VERSION=${TMPDIR}/version +ARCHIVENAME=${COREDIR}/tarantool-core-${PID}-$(date +%Y%m%d%H%M -d @"${TIME}")-${HOSTNAME%%.*}.tar.gz + +# Dump the version to checkout the right commit later. +$BINARY --version > "$VERSION" + +# Collect the most important artefacts. +{ + echo "$BINARY" + echo "$COREFILE" + echo "$VERSION" +} >> "${TARLIST}" + +SEPARATOR1="Shared Object Library" +SEPARATOR2="Shared library is missing debugging information" +# XXX: This is kinda "postmortem ldd": the command below dumps the +# full list of the shared libraries the binary is linked against +# or those loaded via dlopen at the platform runtime. +# This is black woodoo magic. Do not touch. You are warned. +gdb -batch "${BINARY}" -c "${COREFILE}" -ex "info shared" -ex "quit" | \ + sed -n "/${SEPARATOR1}/,/${SEPARATOR2}/p;/${SEPARATOR2}/q" | \ + awk '{ print $NF }' | grep "^/" >> "${TARLIST}" + +# Pack everything listed in TARLIST file into a tarball. To unify +# the archive format BINARY, COREFILE, VERSION and TARLIST are +# renamed while packing. +tar -czhf "${ARCHIVENAME}" -P -T "${TARLIST}" \ + --transform="s|$BINARY|tarantool|" \ + --transform="s|$COREFILE|coredump|" \ + --transform="s|$TARLIST|checklist|" \ + --transform="s|$VERSION|version|" \ + --add-file="${TARLIST}" + +[ -t 1 ] && echo "Archive: ${ARCHIVENAME}" + +# Cleanup temporary files. +[ -f "${TARLIST}" ] && rm -f "${TARLIST}" +[ -f "${VERSION}" ] && rm -f "${VERSION}" +[ -d "${TMPDIR}" ] && rmdir "${TMPDIR}" -- 2.25.0