blob: d56d7ada30fee54875d53bc08377d9268e6f8687 [file] [log] [blame]
The Android Open Source Project2ad60cf2008-10-21 07:00:00 -07001#!/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
The Android Open Source Project5d709782009-02-10 15:43:57 -080017# Grab an hprof file using adb. If an argument is specified, grab
The Android Open Source Project2ad60cf2008-10-21 07:00:00 -070018# the so-named file. If no argument is specified, grab the last such file
19# as found by using "ls".
20
21FILE_BASE="$1"
22if [ "x$FILE_BASE" = "x" ]; then
23 # Note: substr() is to get rid of the final carriage return.
The Android Open Source Project5d709782009-02-10 15:43:57 -080024 FILE_BASE=`adb shell ls -l '/data/misc/heap-dump*.hprof' | tail -1 | \
The Android Open Source Project2ad60cf2008-10-21 07:00:00 -070025 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
30fi
31
The Android Open Source Project5d709782009-02-10 15:43:57 -080032FILE_BASE=/data/misc/${FILE_BASE}
The Android Open Source Project2ad60cf2008-10-21 07:00:00 -070033OUT_FILE=heap-dump.hprof
34
The Android Open Source Project5d709782009-02-10 15:43:57 -080035adb pull "$FILE_BASE" "$OUT_FILE"
The Android Open Source Project2ad60cf2008-10-21 07:00:00 -070036if [ $? -ne 0 ]; then
37 echo "Failed pulling $FILE_BASE."
38 exit 1
39fi
The Android Open Source Project2ad60cf2008-10-21 07:00:00 -070040echo "hat $OUT_FILE"
The Android Open Source Project5d709782009-02-10 15:43:57 -080041exit 0