The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (C) 2007 The Android Open Source Project |
| 4 | # |
| 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 |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 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. |
| 16 | |
| 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". |
| 20 | |
| 21 | FILE_BASE="$1" |
| 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." |
| 28 | exit 1 |
| 29 | fi |
| 30 | fi |
| 31 | |
| 32 | FILE_BASE=/data/misc/${FILE_BASE} |
| 33 | OUT_FILE=heap-dump.hprof |
| 34 | |
| 35 | adb pull "$FILE_BASE" "$OUT_FILE" |
| 36 | if [ $? -ne 0 ]; then |
| 37 | echo "Failed pulling $FILE_BASE." |
| 38 | exit 1 |
| 39 | fi |
| 40 | echo "hat $OUT_FILE" |
| 41 | exit 0 |