File: debug-core-evergreen.sh

package info (click to toggle)
mongo-cxx-driver 4.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 13,832 kB
  • sloc: cpp: 61,365; python: 1,436; sh: 356; xml: 253; perl: 215; makefile: 21
file content (26 lines) | stat: -rwxr-xr-x 635 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env bash

set -o errexit
set -o pipefail

if ! which gdb >/dev/null; then
  echo "gdb not found. Will not search for core files"
  exit 0
fi

echo "Debugging core files"

cd build

shopt -s nullglob
for i in *.core; do
  echo "${i:?}"
  # find out which executable corresponds to the core dump
  # file <core> produces a string like:
  # ./core: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from './a.out'
  binary_path="$(file "${i:?}" | awk '{print $NF}' | awk -F "'" '{print $2}')"
  echo "core dump produced by ${binary_path:?}"
  echo "backtrace full" | gdb -q "${binary_path:?}" "${i:?}"
done

cd ..