File: print_coredumps.sh

package info (click to toggle)
tango 10.0.2%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 89,936 kB
  • sloc: cpp: 201,786; sh: 1,645; python: 953; java: 800; perl: 467; javascript: 447; xml: 325; makefile: 272; sql: 72; ruby: 24
file content (29 lines) | stat: -rwxr-xr-x 1,167 bytes parent folder | download | duplicates (3)
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
27
28
29
#! /usr/bin/env bash

set -e

# taken from https://stackoverflow.com/a/246128
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

source "${SCRIPT_DIR}"/vars.sh

dline="================================================================================"

for corefile in build/tests/core.*; do
  if [ -e "$corefile" ]; then
    # extract %e from the core pattern: core.%e.%p.%t
    bin_name=$(basename $corefile | awk 'BEGIN { FS="." } { print $2 }')

    # $bin_name is limited to 15 characters, so we might have truncation compared
    # to the name of the binary in the file system.  In this loop we try dumping a
    # stack trace with each binary that matches.  There is only a single match
    # that will work but, in practice, we will probably only see a single match
    # anyway so it is not worth trying to work out which is the correct one here.

    for bin_path in $(find -L . -name "${bin_name}*" -type f -executable); do
      echo -e "$dline\nBacktrace for corefile=$corefile (binary=$bin_path)\n$dline"
      gdb --cd=${SOURCE_DIR} --batch $bin_path ./$corefile -ex "thread apply all bt full"
      echo
    done
  fi
done