summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
authorDaniel Gottlieb <daniel.gottlieb@mongodb.com>2020-08-20 11:36:14 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-08-20 15:52:58 +0000
commit7ab67b9007176b6d80f0e460803c5ffc0737ae2e (patch)
tree9587c8b6d9f58b3621c2743bd55f551a69432f9b /buildscripts
parentc9438d647183f6e942acb695765e42e7bb7b1afe (diff)
downloadmongo-7ab67b9007176b6d80f0e460803c5ffc0737ae2e.tar.gz
SERVER-50282: Generate debugging setup script for spawnhosts that load artifacts with coredumps.
Diffstat (limited to 'buildscripts')
-rwxr-xr-xbuildscripts/setup_spawnhost_coredump79
1 files changed, 79 insertions, 0 deletions
diff --git a/buildscripts/setup_spawnhost_coredump b/buildscripts/setup_spawnhost_coredump
new file mode 100755
index 00000000000..fb8948c85a3
--- /dev/null
+++ b/buildscripts/setup_spawnhost_coredump
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+cd $HOME # workaround EVG-12829
+cat >> ~/.profile <<EOF
+# Coredumps generated by a toolchain built mongodb can be problematic when examined with the system
+# gdb.
+export PATH=/opt/mongodbtoolchain/gdb/bin:$PATH
+# As per below, put the user into the appropriate directory. This is where gdb is expected to be
+# invoked from.
+cd debug
+echo "Debuggable binaries:"
+ls -l mongo* | grep -v debug$
+for item in "mongo" "mongod" "mongos"; do
+ echo "\${item} core dumps:"
+ ls -l dump_\${item}.*
+done
+
+echo "Core dumps from unknown processes (crashed processes typically found here):"
+ls -l dump_* | grep -v mongo
+
+echo
+echo "To examine a core dump, type 'gdb ./<binary> ./<core file>'"
+EOF
+
+export PATH=/opt/mongodbtoolchain/gdb/bin:$PATH
+echo 'if [ -f ~/.profile ]; then
+ . ~/.profile
+fi' >> .bash_profile
+
+# Make a directory on the larger EBS volume. Soft-link it under the home directory. The smaller home
+# volume can have trouble particularly with coredumps from sharded timeouts.
+mkdir /data/debug
+ln -s /data/debug .
+cd debug
+
+# As the name suggests, pretty printers. Primarily for boost::optional<T>
+git clone git@github.com:ruediger/Boost-Pretty-Printer.git &
+
+# Discover and unarchive necessary files and source code. This will put mongo binaries and their
+# partner .debug files in the same top-level (`debug`) directory. Shared library files and their
+# debug symbols will be dumped into a `debug/lib` directory for tidiness. The mongo
+# `<reporoot>/src/` directory is soft linked as `debug/src`. The .gdbinit file assumes gdb is being
+# run from the `debug` directory.
+BIN_ARCHIVE=`ls /data/mci/artifacts-*compile/mongo-*.tgz`
+tar --wildcards --strip-components=2 -xzf $BIN_ARCHIVE '*/bin/mongod' '*/bin/mongos' '*/bin/mongo' '*/bin/mongobridge' &
+tar --wildcards --strip-components=1 -xzf $BIN_ARCHIVE '*/lib/*' &
+DBG_ARCHIVE=`ls /data/mci/artifacts-*compile/debugsymbols-*.tgz`
+tar --wildcards --strip-components=2 -xzf $DBG_ARCHIVE '*/bin/mongod.debug' '*/bin/mongos.debug' '*/bin/mongo.debug' '*/bin/mongobridge.debug' &
+tar --wildcards --strip-components=1 -xzf $DBG_ARCHIVE '*/lib/*' &
+SRC_DIR=`find /data/mci/ -maxdepth 1 | grep source`
+ln -s $SRC_DIR/.gdbinit .
+ln -s $SRC_DIR/src src
+ln -s $SRC_DIR/buildscripts buildscripts
+
+# Install pymongo to get the bson library for pretty-printers.
+/opt/mongodbtoolchain/v3/bin/pip3 install -r $SRC_DIR/etc/pip/dev-requirements.txt &
+
+COREDUMP_ARCHIVE=`ls /data/mci/artifacts-*/mongo-coredumps-*.tgz`
+tar -xzf $COREDUMP_ARCHIVE &
+echo "Waiting for background processes to complete."
+wait
+
+cat >> ~/.gdbinit <<EOF
+set auto-load safe-path /
+set solib-search-path ./lib/
+set pagination off
+set print object on
+set print static-members off
+set print pretty on
+
+python
+import sys
+sys.path.insert(0, './Boost-Pretty-Printer')
+import boost
+boost.register_printers(boost_version=(1,70,0))
+end
+EOF
+
+echo "dir $HOME/debug" >> ~/.gdbinit