Add convenience retrace script for R8.

Test: R8_THROW_EXCEPTION_FOR_TESTING_RETRACE=1 \
      java -cp r8-master.jar com.android.tools.r8.R8 --help 2>&1 \
      | ./retrace-r8-master.sh

Change-Id: Iee18f25fcd1167bb7d557207d805757d1d023e6c
diff --git a/retrace-r8-master.sh b/retrace-r8-master.sh
new file mode 100755
index 0000000..0b908a1
--- /dev/null
+++ b/retrace-r8-master.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+#
+# Copyright (C) 2019 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Call retrace with the r8-master map file.
+#
+# Usage:
+#
+#     retrace-r8-master.sh [-verbose] [<stacktrace_file>]
+#
+# Read from stdin if stacktrace file is not specified.
+
+# Set up prog to be the path of this script, including following symlinks,
+# and set up progdir to be the fully-qualified pathname of its directory.
+prog="$0"
+while [ -h "${prog}" ]; do
+    newProg=`/bin/ls -ld "${prog}"`
+    newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
+    if expr "x${newProg}" : 'x/' >/dev/null; then
+        prog="${newProg}"
+    else
+        progdir=`dirname "${prog}"`
+        prog="${progdir}/${newProg}"
+    fi
+done
+oldwd=`pwd`
+progdir=`dirname "${prog}"`
+cd "${progdir}"
+progdir=`pwd`
+prog="${progdir}"/`basename "${prog}"`
+cd "${oldwd}"
+
+retracedir="${progdir}/retrace"
+retracejar="retrace.jar"
+proguardjar="proguard.jar"
+
+if [ ! -r "${retracedir}/${retracejar}" ]; then
+    echo `basename "$prog"`": can't find ${retracejar}"
+    exit 1
+fi
+
+if [ ! -r "${retracedir}/${proguardjar}" ]; then
+    echo `basename "$prog"`": can't find ${proguardjar}"
+    exit 1
+fi
+
+mapfile="r8-master.jar.map"
+
+if [ ! -r "${progdir}/${mapfile}" ]; then
+    echo `basename "${prog}"`": can't find ${mapfile}"
+    exit 1
+fi
+
+if [ "$OSTYPE" = "cygwin" ]; then
+    # For Cygwin, convert the scriptfile path into native Windows style.
+    mappath=`cygpath -w "${progdir}/${mapfile}"`
+    retracepath=`cygpath -w "${retracedir}/${retracejar}"`
+else
+    mappath="${progdir}/${mapfile}"
+    retracepath="${retracedir}/${retracejar}"
+fi
+
+exec java -jar "${retracepath}" "${mappath}" "$@"