blob: b68ecceff4d2a7cbe3e9c6d1915afc60a24cb8d4 [file] [log] [blame]
Tamas Kenez21b9b2a2019-01-10 11:26:35 +01001#!/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
Søren Gjesse52a56902019-12-10 16:26:09 +000017# Call retrace with the r8 map file.
Tamas Kenez21b9b2a2019-01-10 11:26:35 +010018#
19# Usage:
20#
Søren Gjesse52a56902019-12-10 16:26:09 +000021# retrace-r8.sh [-verbose] [<stacktrace_file>]
Tamas Kenez21b9b2a2019-01-10 11:26:35 +010022#
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
Ian Zernycc855492021-10-26 14:31:35 +020045retracedir="${progdir}"
46retracejar="r8.jar"
Tamas Kenez21b9b2a2019-01-10 11:26:35 +010047
48if [ ! -r "${retracedir}/${retracejar}" ]; then
49 echo `basename "$prog"`": can't find ${retracejar}"
50 exit 1
51fi
52
Søren Gjesse52a56902019-12-10 16:26:09 +000053mapfile="r8.jar.map"
Tamas Kenez21b9b2a2019-01-10 11:26:35 +010054
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
Ian Zernycc855492021-10-26 14:31:35 +020069exec java -cp "${retracepath}" com.android.tools.r8.retrace.Retrace "${mappath}" "$@"