Colin Cross | e89c784 | 2022-04-07 19:31:24 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2019 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # Call retrace with the r8 map file. |
| 18 | # |
| 19 | # Usage: |
| 20 | # |
| 21 | # retrace-r8.sh [-verbose] [<stacktrace_file>] |
| 22 | # |
| 23 | # Read from stdin if stacktrace file is not specified. |
| 24 | |
| 25 | # Set up prog to be the path of this script, including following symlinks, |
| 26 | # and set up progdir to be the fully-qualified pathname of its directory. |
| 27 | prog="$0" |
| 28 | while [ -h "${prog}" ]; do |
| 29 | newProg=`/bin/ls -ld "${prog}"` |
| 30 | newProg=`expr "${newProg}" : ".* -> \(.*\)$"` |
| 31 | if expr "x${newProg}" : 'x/' >/dev/null; then |
| 32 | prog="${newProg}" |
| 33 | else |
| 34 | progdir=`dirname "${prog}"` |
| 35 | prog="${progdir}/${newProg}" |
| 36 | fi |
| 37 | done |
| 38 | oldwd=`pwd` |
| 39 | progdir=`dirname "${prog}"` |
| 40 | cd "${progdir}" |
| 41 | progdir=`pwd` |
| 42 | prog="${progdir}"/`basename "${prog}"` |
| 43 | cd "${oldwd}" |
| 44 | |
| 45 | retracedir="${progdir}" |
| 46 | retracejar="r8.jar" |
| 47 | |
| 48 | if [ ! -r "${retracedir}/${retracejar}" ]; then |
| 49 | echo `basename "$prog"`": can't find ${retracejar}" |
| 50 | exit 1 |
| 51 | fi |
| 52 | |
| 53 | mapfile="r8.jar.map" |
| 54 | |
| 55 | if [ ! -r "${progdir}/${mapfile}" ]; then |
| 56 | echo `basename "${prog}"`": can't find ${mapfile}" |
| 57 | exit 1 |
| 58 | fi |
| 59 | |
| 60 | if [ "$OSTYPE" = "cygwin" ]; then |
| 61 | # For Cygwin, convert the scriptfile path into native Windows style. |
| 62 | mappath=`cygpath -w "${progdir}/${mapfile}"` |
| 63 | retracepath=`cygpath -w "${retracedir}/${retracejar}"` |
| 64 | else |
| 65 | mappath="${progdir}/${mapfile}" |
| 66 | retracepath="${retracedir}/${retracejar}" |
| 67 | fi |
| 68 | |
| 69 | exec java -cp "${retracepath}" com.android.tools.r8.retrace.Retrace "${mappath}" "$@" |