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" |
Andreas Gampe | e0021c5 | 2015-07-09 14:39:56 -0700 | [diff] [blame] | 25 | shift |
Andreas Gampe | 54fc26c | 2014-09-04 21:47:42 -0700 | [diff] [blame] | 26 | fi |
| 27 | |
| 28 | # Pull the file from the device and symbolize it. |
leon.wang | 1abd3ec | 2020-03-26 18:38:30 +0800 | [diff] [blame] | 29 | one() { |
Andreas Gampe | 54fc26c | 2014-09-04 21:47:42 -0700 | [diff] [blame] | 30 | echo $1 $2 |
| 31 | if [ "x$INTERACTIVE" = "xyes" ] ; then |
| 32 | echo -n "What to do? [Y/n/q] " |
| 33 | read -e input |
| 34 | if [ "x$input" = "xn" ] ; then |
| 35 | return |
| 36 | fi |
| 37 | if [ "x$input" = "xq" ] ; then |
| 38 | exit 0 |
| 39 | fi |
| 40 | fi |
Zheng Xu | 468bcf6 | 2015-04-21 17:35:25 +0800 | [diff] [blame] | 41 | adb pull $1/$2 /tmp || exit 1 |
leon.wang | 1abd3ec | 2020-03-26 18:38:30 +0800 | [diff] [blame] | 42 | # pull vdex file for oatdump |
| 43 | vdex=${2%.*}.vdex |
| 44 | adb pull $1/$vdex /tmp/ 2>/dev/null |
Zheng Xu | 468bcf6 | 2015-04-21 17:35:25 +0800 | [diff] [blame] | 45 | mkdir -p $OUT/symbols/$1 |
| 46 | oatdump --symbolize=/tmp/$2 --output=$OUT/symbols/$1/$2 |
Andreas Gampe | 54fc26c | 2014-09-04 21:47:42 -0700 | [diff] [blame] | 47 | } |
| 48 | |
Zheng Xu | 468bcf6 | 2015-04-21 17:35:25 +0800 | [diff] [blame] | 49 | # adb shell find seems to output in DOS format (CRLF), which messes up scripting |
leon.wang | 1abd3ec | 2020-03-26 18:38:30 +0800 | [diff] [blame] | 50 | adbshellstrip() { |
Zheng Xu | 468bcf6 | 2015-04-21 17:35:25 +0800 | [diff] [blame] | 51 | adb shell $@ | sed 's/\r$//' |
Andreas Gampe | 54fc26c | 2014-09-04 21:47:42 -0700 | [diff] [blame] | 52 | } |
| 53 | |
Zheng Xu | 468bcf6 | 2015-04-21 17:35:25 +0800 | [diff] [blame] | 54 | # Search in all of /data on device. |
leon.wang | 1abd3ec | 2020-03-26 18:38:30 +0800 | [diff] [blame] | 55 | all() { |
Zheng Xu | 468bcf6 | 2015-04-21 17:35:25 +0800 | [diff] [blame] | 56 | FILES=$(adbshellstrip find /data -name "'*.oat'" -o -name "'*.dex'" -o -name "'*.odex'") |
| 57 | for FILE in $FILES ; do |
| 58 | DIR=$(dirname $FILE) |
| 59 | NAME=$(basename $FILE) |
| 60 | one $DIR $NAME |
Andreas Gampe | 54fc26c | 2014-09-04 21:47:42 -0700 | [diff] [blame] | 61 | done |
| 62 | } |
| 63 | |
Andreas Gampe | e0021c5 | 2015-07-09 14:39:56 -0700 | [diff] [blame] | 64 | if [ "x$1" = "x" ] ; then |
| 65 | # No further arguments, iterate over all oat files on device. |
| 66 | all |
| 67 | else |
| 68 | # Take the parameters as a list of paths on device. |
| 69 | while (($#)); do |
| 70 | DIR=$(dirname $1) |
| 71 | NAME=$(basename $1) |
| 72 | one $DIR $NAME |
| 73 | shift |
| 74 | done |
| 75 | fi |