3 # Copyright (C) 2007 The Android Open Source Project
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Grab an hprof file using adb. If an argument is specified, grab
18 # the so-named file. If no argument is specified, grab the last such file
19 # as found by using "ls".
22 if [ "x$FILE_BASE" = "x" ]; then
23 # Note: substr() is to get rid of the final carriage return.
24 FILE_BASE=`adb shell ls -l '/data/misc/heap-dump*.hprof' | tail -1 | \
25 awk '{ printf("%s", substr($7, 1, length($7) - 1)); }'`
26 if [ "x$FILE_BASE" = "x" ]; then
27 echo "No file base defined."
32 FILE_BASE=/data/misc/${FILE_BASE}
33 OUT_FILE=heap-dump.hprof
35 adb pull "$FILE_BASE" "$OUT_FILE"
37 echo "Failed pulling $FILE_BASE."