summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
authorMatt Kneiser <matt.kneiser@mongodb.com>2022-05-31 16:47:41 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-05-31 17:34:45 +0000
commit42bdcc32e1403e3d291f0ad030434fe279c157cf (patch)
treee2697aeb5f943b853fbea0bbb47796b19658e961 /buildscripts
parent925582ab4786cc5a25b5b82540c4b9e9227f429d (diff)
downloadmongo-42bdcc32e1403e3d291f0ad030434fe279c157cf.tar.gz
SERVER-66769 Add Windows support to spawnhost setup script
(cherry picked from commit ad379f1338379fa96dcdf52f6c1a2f3b68f90dc7)
Diffstat (limited to 'buildscripts')
-rwxr-xr-xbuildscripts/setup_spawnhost_coredump163
1 files changed, 109 insertions, 54 deletions
diff --git a/buildscripts/setup_spawnhost_coredump b/buildscripts/setup_spawnhost_coredump
index e8f7a34271b..7710b75ef3b 100755
--- a/buildscripts/setup_spawnhost_coredump
+++ b/buildscripts/setup_spawnhost_coredump
@@ -2,15 +2,69 @@
cd $HOME # workaround EVG-12829
-# Communicate to users that logged in before the script started that nothing is ready.
-wall "The setup_spawnhost_coredump script has just started setting up the debugging environment."
-
-# Write this file that gets cat'ed on login to communicate to users logging in if this setup script is still running.
-echo '+-----------------------------------------------------------------+' > ~/.setup_spawnhost_coredump_progress
-echo '| The setup script is still setting up data files for inspection. |' >> ~/.setup_spawnhost_coredump_progress
-echo '+-----------------------------------------------------------------+' >> ~/.setup_spawnhost_coredump_progress
-
-cat >> ~/.profile <<EOF
+unameOut=$(uname -s)
+case "${unameOut}" in
+ Linux*) machine=Linux;;
+ Darwin*) machine=Mac;;
+ CYGWIN*) machine=Cygwin;;
+ *) machine="UNKNOWN:${unameOut}"
+esac
+
+if [[ "${machine}" = "Cygwin" ]]; then
+ out_dir="/cygdrive/c/setup_script_output.txt"
+ desktop_dir="/cygdrive/c/Users/Administrator/Desktop"
+
+ {
+ date
+ env
+
+ echo "----------------------"
+ echo -e "\n=> Setting _NT_SOURCE_PATH environment variable for debuggers to pick up source files."
+ src_dir_hash=$(readlink -f /cygdrive/z/data/mci/source-*)
+ full_src_dir="${src_dir_hash}/src"
+ echo "Source Path: [${full_src_dir}]"
+ set -x;
+ setx _NT_SOURCE_PATH "${full_src_dir}"
+ { set +x; } 2>/dev/null
+
+ echo -e "\n=> Setting _NT_SYMBOL_PATH environment variable for debuggers to pick up the symbols."
+ sym_parent_dir=$(readlink -f /cygdrive/z/data/mci/artifacts-*dist_test_debug)
+ sym_dir=$(readlink -f ${sym_parent_dir}/debugsymbols-mongodb*zip)
+ sym_extracted_dir="${sym_parent_dir}/extracted_symbols"
+ full_sym_dir="${sym_extracted_dir}/dist-test/bin"
+ echo "Symbols Dir: [${full_sym_dir}]"
+
+ echo -e "\n=> Extracting Symbol files."
+ set -x;
+ mkdir ${sym_extracted_dir}
+ unzip -n ${sym_dir} -d ${sym_extracted_dir}
+ setx _NT_SYMBOL_PATH "${full_sym_dir};srv*;"
+ { set +x; } 2>/dev/null
+
+ echo -e "\n=> Extracting Core Dump to Desktop."
+ full_dump_dir=$(readlink -f /cygdrive/z/data/mci/artifacts-* | grep -v dist_test)
+ full_dump_parent_dir=$(readlink -f ${full_dump_dir}/mongo-coredumps*tgz)
+ extracted_dump_dir="${full_dump_dir}/extracted_dump"
+ set -x;
+ mkdir ${extracted_dump_dir}
+ tar -xzvf ${full_dump_parent_dir} -C ${extracted_dump_dir}
+ cp ${extracted_dump_dir}/* ${desktop_dir}
+ { set +x; } 2>/dev/null
+ echo "Copied to Desktop."
+
+ } &> ${out_dir}
+
+ cp ${out_dir} ${desktop_dir}
+else
+ # Communicate to users that logged in before the script started that nothing is ready.
+ wall "The setup_spawnhost_coredump script has just started setting up the debugging environment."
+
+ # Write this file that gets cat'ed on login to communicate to users logging in if this setup script is still running.
+ echo '+-----------------------------------------------------------------------------------+' > ~/.setup_spawnhost_coredump_progress
+ echo '| The setup script is still setting up data files for inspection on a [${machine}] host. |' >> ~/.setup_spawnhost_coredump_progress
+ echo '+-----------------------------------------------------------------------------------+' >> ~/.setup_spawnhost_coredump_progress
+
+ cat >> ~/.profile <<EOF
cat ~/.setup_spawnhost_coredump_progress
# Coredumps generated by a toolchain built mongodb can be problematic when examined with the system
# gdb.
@@ -33,48 +87,48 @@ echo "To examine a core dump, type 'gdb ./<binary> ./<core file>'"
cat ~/.setup_spawnhost_coredump_progress
EOF
-echo 'if [ -f ~/.profile ]; then
+ 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-*archive_dist_test*/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-*archive_dist_test_debug/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/*' &
-UNITTEST_ARCHIVE=`ls /data/mci/artifacts-*run_unittests/mongo-unittests-*.tgz`
-tar --wildcards --strip-components=1 -xzf $UNITTEST_ARCHIVE 'bin/*' &
-tar --wildcards -xzf $UNITTEST_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
+ # 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-*archive_dist_test*/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-*archive_dist_test_debug/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/*' &
+ UNITTEST_ARCHIVE=`ls /data/mci/artifacts-*run_unittests/mongo-unittests-*.tgz`
+ tar --wildcards --strip-components=1 -xzf $UNITTEST_ARCHIVE 'bin/*' &
+ tar --wildcards -xzf $UNITTEST_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
@@ -90,10 +144,11 @@ boost.register_printers(boost_version=(1,70,0))
end
EOF
-echo "dir $HOME/debug" >> ~/.gdbinit
+ echo "dir $HOME/debug" >> ~/.gdbinit
-# Empty out the progress script that warns users about the set script still running when users log in.
-echo "" > ~/.setup_spawnhost_coredump_progress
-# Alert currently logged in users that this setup script has completed. Logging back in will ensure any
-# paths/environment variables will be set as intended.
-wall "The setup_spawnhost_coredump script has completed, please relogin to ensure the right environment variables are set."
+ # Empty out the progress script that warns users about the set script still running when users log in.
+ echo "" > ~/.setup_spawnhost_coredump_progress
+ # Alert currently logged in users that this setup script has completed. Logging back in will ensure any
+ # paths/environment variables will be set as intended.
+ wall "The setup_spawnhost_coredump script has completed, please relogin to ensure the right environment variables are set."
+fi