File: gdb-backtrace

package info (click to toggle)
charliecloud 0.43-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,084 kB
  • sloc: python: 6,021; sh: 4,284; ansic: 3,863; makefile: 598
file content (22 lines) | stat: -rwxr-xr-x 580 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
#!/bin/bash

# $1  executable
# $2  core dump, or directory containing core dumps, in which case pick newest

bin=$1
core=$2

if [[ -d $core ]]; then
    # kludge but good enough for now (https://stackoverflow.com/q/1015678)
    printf "%s is a directory\n" "$core" 1>&2
    #shellcheck disable=SC2012
    core=$core/$(ls -At "$core" | head -1)
    printf "using %s\n" "$core" 1>&2
fi

gdb -batch "$bin" "$core" \
    -ex 'set style enabled on' \
    -ex 'set print pretty on' \
    -ex 'set print frame-info source-and-location' \
    -ex 'echo \n\n' \
    -ex 'backtrace -full'