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 |
Zheng Xu | 468bcf6 | 2015-04-21 17:35:25 +0800 | [diff] [blame] | 40 | adb pull $1/$2 /tmp || exit 1 |
| 41 | mkdir -p $OUT/symbols/$1 |
| 42 | oatdump --symbolize=/tmp/$2 --output=$OUT/symbols/$1/$2 |
Andreas Gampe | 54fc26c | 2014-09-04 21:47:42 -0700 | [diff] [blame] | 43 | } |
| 44 | |
Zheng Xu | 468bcf6 | 2015-04-21 17:35:25 +0800 | [diff] [blame] | 45 | # adb shell find seems to output in DOS format (CRLF), which messes up scripting |
| 46 | function adbshellstrip() { |
| 47 | adb shell $@ | sed 's/\r$//' |
Andreas Gampe | 54fc26c | 2014-09-04 21:47:42 -0700 | [diff] [blame] | 48 | } |
| 49 | |
Zheng Xu | 468bcf6 | 2015-04-21 17:35:25 +0800 | [diff] [blame] | 50 | # Search in all of /data on device. |
Andreas Gampe | 54fc26c | 2014-09-04 21:47:42 -0700 | [diff] [blame] | 51 | function all() { |
Zheng Xu | 468bcf6 | 2015-04-21 17:35:25 +0800 | [diff] [blame] | 52 | FILES=$(adbshellstrip find /data -name "'*.oat'" -o -name "'*.dex'" -o -name "'*.odex'") |
| 53 | for FILE in $FILES ; do |
| 54 | DIR=$(dirname $FILE) |
| 55 | NAME=$(basename $FILE) |
| 56 | one $DIR $NAME |
Andreas Gampe | 54fc26c | 2014-09-04 21:47:42 -0700 | [diff] [blame] | 57 | done |
| 58 | } |
| 59 | |
| 60 | all |