blob: b66191f9b0946b26b0d96ffd57f95d0661e2c274 [file] [log] [blame]
Andreas Gampe54fc26c2014-09-04 21:47:42 -07001#!/bin/sh
2# Copyright (C) 2014 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16#
17# Symbolize oat files from the dalvik cache of a device.
18#
19# By default, pulls everything from the dalvik cache. A simple yes/no/quit prompt for each file can
20# be requested by giving "--interactive" as a parameter.
21
22INTERACTIVE="no"
23if [ "x$1" = "x--interactive" ] ; then
24 INTERACTIVE="yes"
25fi
26
27# Pull the file from the device and symbolize it.
28function one() {
29 echo $1 $2
30 if [ "x$INTERACTIVE" = "xyes" ] ; then
31 echo -n "What to do? [Y/n/q] "
32 read -e input
33 if [ "x$input" = "xn" ] ; then
34 return
35 fi
36 if [ "x$input" = "xq" ] ; then
37 exit 0
38 fi
39 fi
40 adb pull /data/dalvik-cache/$1/$2 /tmp || exit 1
41 mkdir -p $OUT/symbols/data/dalvik-cache/$1
42 oatdump --symbolize=/tmp/$2 --output=$OUT/symbols/data/dalvik-cache/$1/$2
43}
44
45# adb shell ls seems to output in DOS format (CRLF), which messes up scripting
46function adbls() {
47 adb shell ls $@ | sed 's/\r$//'
48}
49
50# Check for all ISA directories on device.
51function all() {
52 DIRS=$(adbls /data/dalvik-cache/)
53 for DIR in $DIRS ; do
54 case $DIR in
55 arm|arm64|mips|x86|x86_64)
56 FILES=$(adbls /data/dalvik-cache/$DIR/*.oat /data/dalvik-cache/$DIR/*.dex)
57 for FILE in $FILES ; do
58 # Cannot use basename as the file doesn't exist.
59 NAME=$(echo $FILE | sed -e 's/.*\///')
60 one $DIR $NAME
61 done
62 ;;
63 esac
64 done
65}
66
67all