blob: b68ecceff4d2a7cbe3e9c6d1915afc60a24cb8d4 [file] [log] [blame]
Colin Crosse89c7842022-04-07 19:31:24 +00001#!/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.
27prog="$0"
28while [ -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
37done
38oldwd=`pwd`
39progdir=`dirname "${prog}"`
40cd "${progdir}"
41progdir=`pwd`
42prog="${progdir}"/`basename "${prog}"`
43cd "${oldwd}"
44
45retracedir="${progdir}"
46retracejar="r8.jar"
47
48if [ ! -r "${retracedir}/${retracejar}" ]; then
49 echo `basename "$prog"`": can't find ${retracejar}"
50 exit 1
51fi
52
53mapfile="r8.jar.map"
54
55if [ ! -r "${progdir}/${mapfile}" ]; then
56 echo `basename "${prog}"`": can't find ${mapfile}"
57 exit 1
58fi
59
60if [ "$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}"`
64else
65 mappath="${progdir}/${mapfile}"
66 retracepath="${retracedir}/${retracejar}"
67fi
68
69exec java -cp "${retracepath}" com.android.tools.r8.retrace.Retrace "${mappath}" "$@"