Bug 1586798 - Use WalkerFront from the currently selected element in onTagEdit()...
[gecko.git] / build / macosx / llvm-dsymutil
blob2deb78f4b69428801ef55652be3d02ebe4781ce4
1 #!/bin/sh
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/.
6 "$REAL_DSYMUTIL" "$@"
7 ret=$?
8 if [ $ret -ne 139 ]; then
9 exit $ret
12 echo "$REAL_DSYMUTIL crashed. Trying to get a reduced testcase." >&2
13 tmpdir=$(mktemp -d)
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.
18 for arg in "$@"; do
19 case "$arg" in
20 -*)
23 lib="$arg"
25 esac
26 done
28 last_obj=$("$REAL_DSYMUTIL" --verbose "$@" 2> /dev/null | sed -n "/trying to open/s/trying to open '\(.*\)'/\1/p" | tail -1)
30 case "$last_obj" in
31 "")
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.
35 exit 139
37 *.a\(*.o\))
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(}"
42 obj="${obj%)}"
43 (cd "$tmpdir"; ar x "$archive" "$obj")
44 mkdir -p $tmpdir/crasher/$(dirname "$archive")
45 (cd "$tmpdir"; ar cr "$tmpdir/crasher/$archive" "$obj")
46 rm "$tmpdir/$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"
54 esac
55 cp "$lib" "$tmpdir/crasher"
56 cat > "$tmpdir/crasher/run-me.sh" <<EOF
57 #!/bin/sh
58 DSYMUTIL="\${DSYMUTIL:-llvm-dsymutil}"
59 dir="\$(dirname \$0)"
60 \$DSYMUTIL -oso-prepend-path="\$dir" "\$dir/$(basename "$lib")"
61 exit \$?
62 EOF
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
71 else
72 echo "Could not reproduce with a reduced testcase. Sorry." >&2
75 exit 139