blob: 7365a9bb3d090f236999015ba7ceddb82bebabb9 [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
Zheng Xu468bcf62015-04-21 17:35:25 +080040 adb pull $1/$2 /tmp || exit 1
41 mkdir -p $OUT/symbols/$1
42 oatdump --symbolize=/tmp/$2 --output=$OUT/symbols/$1/$2
Andreas Gampe54fc26c2014-09-04 21:47:42 -070043}
44
Zheng Xu468bcf62015-04-21 17:35:25 +080045# adb shell find seems to output in DOS format (CRLF), which messes up scripting
46function adbshellstrip() {
47 adb shell $@ | sed 's/\r$//'
Andreas Gampe54fc26c2014-09-04 21:47:42 -070048}
49
Zheng Xu468bcf62015-04-21 17:35:25 +080050# Search in all of /data on device.
Andreas Gampe54fc26c2014-09-04 21:47:42 -070051function all() {
Zheng Xu468bcf62015-04-21 17:35:25 +080052 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 Gampe54fc26c2014-09-04 21:47:42 -070057 done
58}
59
60all