blob: f2d74aa82f443f6aa2b31e1614816ecaa807be7f (
plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
#!/usr/bin/env bash
function die() {
echo $@ >&2
exit 1
}
function usage() {
echo "bt: $0 -c core_path [-d distro] [-C directory] [-v]"
exit 1
}
function log() {
if [ -n "$verbose" ]; then
echo $*
fi
}
function get_machine() {
local core_path=$1
local machine=${core_path%/coredump/*}
echo $(basename $machine)
}
function get_t_dir() {
local core_path=$1
echo ${core_path%/remote/*}
}
while getopts "c:C:d:v" opt
do
case $opt in
c) core_path=$OPTARG;;
C) wd=$OPTARG;;
d) codename=$OPTARG;;
v) verbose=1;;
*) usage;;
esac
done
if [ -z $core_path ]; then
usage
fi
sha1=$(strings $core_path | gawk 'BEGIN{ FS = "=" } /^CEPH_REF/{print $2}')
if [ -z $sha1 ]; then
teuthology_log=$(get_t_dir $core_path)/teuthology.log
sha1=$(grep -m1 -A1 "Running command: sudo ceph --version" ${teuthology_log} | tail -n1 | grep -oP "ceph version [^ ]+ \(\K[^\) ]+")
fi
if [ -z $distro ]; then
machine=$(get_machine $core_path)
teuthology_log=$(get_t_dir $core_path)/teuthology.log
if [ ! -r ${teuthology_log} ]; then
die "missing distro, and unable to read it from ${teuthology_log}"
fi
ld=$(grep -m1 -A1 "${machine}:Running.*linux_distribution" ${teuthology_log} | tail -n1 | grep -oP "\(\K[^\)]+")
distro=$(echo $ld | gawk -F ", " '{print $1}' | sed s/\'//g)
distro=$(echo $distro | tr '[:upper:]' '[:lower:]')
distro_ver=$(echo $ld | gawk -F ", " '{print $2}' | sed s/\'//g)
codename=$(echo $ld | gawk -F ", " '{print $3}' | sed s/\'//g)
if [ "$distro" == "centos linux" ]; then
# there is chance that it's actually something different,
# but we take it as centos7 anyway.
distro=centos
distro_ver=7
fi
else
case $codename in
xenial)
distro=ubuntu
distro_ver=16.04
;;
trusty)
distro=ubuntu
distro_ver=14.04
;;
centos7)
distro=centos
distro_ver=7
;;
*)
die "unknown distro: $distro"
;;
esac
fi
# try to figure out a name for working directory
if [ -z $wd ]; then
run=${core_path%/remote/*}
job_id=${run#/a/}
if [ $job_id != $core_path ]; then
# use the run/job for the working dir
wd=$job_id
fi
fi
if [ -z $wd ]; then
wd=$(basename $core_path)
wd=${wd%.*}
echo "unable to figure out the working directory, using ${wd}"
fi
log "creating ${wd}"
mkdir -p $wd
cd $wd
prog=$(file $core_path | grep -oP "from '\K[^']+" | cut -d' ' -f1)
case $prog in
ceph_test_*)
pkgs="ceph-test librados2"
;;
ceph-osd|ceph-mon)
pkgs=$prog
;;
*/python*)
prog=$(basename $prog)
pkgs=librados2
;;
rados)
pkgs="ceph-common librados2 libradosstriper1"
;;
*)
die "unknown prog: $prog"
;;
esac
flavor=default
arch=x86_64
release=$(strings $core_path | grep -m1 -oP '/build/ceph-\K[^/]+')
if [ -z $release ]; then
teuthology_log=$(get_t_dir $core_path)/teuthology.log
release=$(grep -m1 -A1 "Running command: sudo ceph --version" ${teuthology_log} | tail -n1 | grep -oP "ceph version \K[^ ]+")
fi
case $distro in
ubuntu)
pkg_path=pool/main/c/ceph/%s_%s-1${codename}_amd64.deb
for p in $pkgs; do
t="$t $p $p-dbg"
done
pkgs="$t"
;;
centos)
pkg_path=${arch}/%s-%s.el7.x86_64.rpm
# 11.0.2-1022-g5b25cd3 => 11.0.2-1022.g5b25cd3
release=$(echo $release | sed s/-/./2)
pkgs="$pkgs ceph-debuginfo"
;;
*)
die "unknown distro: $distro"
;;
esac
query_url="https://shaman.ceph.com/api/search?status=ready&project=ceph&flavor=${flavor}&distros=${distro}%2F${distro_ver}%2F${arch}&sha1=${sha1}"
repo_url=`curl -L -s "${query_url}" | jq -r '.[0] | .url'`
pkg_url=${repo_url}/${pkg_path}
log "repo url is ${repo_url}"
for pkg in ${pkgs}; do
url=`printf $pkg_url $pkg $release`
log "downloading ${url}"
curl -O -L -C - --silent --fail --insecure $url
fname=`basename $url`
case $fname in
*.deb)
ar p `basename $fname` data.tar.xz | tar xJv;;
*.rpm)
rpm2cpio < $fname | cpio -id;;
*)
esac
done
cat > preclude.gdb <<EOF
set sysroot .
set debug-file-directory ./usr/lib/debug
set solib-search-path ./usr/lib64
file ./usr/bin/$prog
core $core_path
EOF
gdb -x preclude.gdb
|