Andreas Gampe | 54fc26c | 2014-09-04 21:47:42 -0700 | [diff] [blame] | 1 | #!/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 | |
| 22 | INTERACTIVE="no" |
| 23 | if [ "x$1" = "x--interactive" ] ; then |
| 24 | INTERACTIVE="yes" |
| 25 | fi |
| 26 | |
| 27 | # Pull the file from the device and symbolize it. |
| 28 | function 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 |
| 46 | function adbls() { |
| 47 | adb shell ls $@ | sed 's/\r$//' |
| 48 | } |
| 49 | |
| 50 | # Check for all ISA directories on device. |
| 51 | function all() { |
| 52 | DIRS=$(adbls /data/dalvik-cache/) |
| 53 | for DIR in $DIRS ; do |
| 54 | case $DIR in |
Andreas Gampe | 1a5c406 | 2015-01-15 12:10:47 -0800 | [diff] [blame] | 55 | arm|arm64|mips|mips64|x86|x86_64) |
Andreas Gampe | 54fc26c | 2014-09-04 21:47:42 -0700 | [diff] [blame] | 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 | |
| 67 | all |