2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 if [ $ret -ne 139 ]; then
12 echo "$REAL_DSYMUTIL crashed. Trying to get a reduced testcase." >&2
14 trap "rm -rf $tmpdir" EXIT
16 # Get the library file name from the command line arguments. We assume
17 # it's the last argument that doesn't start with a dash.
28 last_obj
=$
("$REAL_DSYMUTIL" --verbose "$@" 2> /dev
/null |
sed -n "/trying to open/s/trying to open '\(.*\)'/\1/p" |
tail -1)
32 echo "Could not produce a reduced testcase. Aborting." >&2
33 # Ideally, we'd produce an archive with every .o and .a involved, but so
34 # far, this case has never happened, so, meh.
38 # The crash likely happened while reading one particular object in a library.
39 # Create a new library with just that one object.
40 archive
=$
(readlink
-f "${last_obj%(*}")
41 obj
="${last_obj#*.a(}"
43 (cd "$tmpdir"; ar x
"$archive" "$obj")
44 mkdir
-p $tmpdir/crasher
/$
(dirname "$archive")
45 (cd "$tmpdir"; ar cr
"$tmpdir/crasher/$archive" "$obj")
49 # The crash likely happened while reading one particular object.
50 obj
=$
(readlink
-f "$last_obj")
51 mkdir
-p "$tmpdir/crasher/$(dirname "$obj")"
52 cp "$obj" "$tmpdir/crasher/$obj"
55 cp "$lib" "$tmpdir/crasher"
56 cat > "$tmpdir/crasher/run-me.sh" <<EOF
58 DSYMUTIL="\${DSYMUTIL:-llvm-dsymutil}"
60 \$DSYMUTIL -oso-prepend-path="\$dir" "\$dir/$(basename "$lib")"
63 chmod +x
"$tmpdir/crasher/run-me.sh"
64 (cd "$tmpdir"/crasher
; DSYMUTIL
=/builds
/worker
/workspace
/build
/src
/llvm-dsymutil
/bin
/llvm-dsymutil .
/run-me.sh
> /dev
/null
2>&1)
65 if [ $?
-eq 139 ]; then
66 echo "Could reproduce with a reduced testcase. Creating an artifact." >&2
67 mkdir
-p "$HOME/artifacts"
68 artifact
=dsymutil-crasher.
tar.xz
69 tar -Jcf "$HOME/artifacts/$artifact" -C "$tmpdir" crasher
/
70 echo "Check the $artifact artifact." >&2
72 echo "Could not reproduce with a reduced testcase. Sorry." >&2