Update runhat command to use "am dumpheap".
Instead of sending a kill -10 to write a file to /data/misc, we now use "am dumpheap" to create a file on /sdcard. Also, - Removed mention of unused "output-file" argument. - Quoted args in initial tests so bash doesn't go nuts when you say "runhat" with no arguments. Bug 2835170. Change-Id: I614fdb54a1d6b8824bc9b568c07cc0901c41a3d4
This commit is contained in:
17
envsetup.sh
17
envsetup.sh
@@ -907,10 +907,10 @@ function runhat()
|
||||
{
|
||||
# process standard adb options
|
||||
local adbTarget=""
|
||||
if [ $1 = "-d" -o $1 = "-e" ]; then
|
||||
if [ "$1" = "-d" -o "$1" = "-e" ]; then
|
||||
adbTarget=$1
|
||||
shift 1
|
||||
elif [ $1 = "-s" ]; then
|
||||
elif [ "$1" = "-s" ]; then
|
||||
adbTarget="$1 $2"
|
||||
shift 2
|
||||
fi
|
||||
@@ -919,10 +919,9 @@ function runhat()
|
||||
|
||||
# runhat options
|
||||
local targetPid=$1
|
||||
local outputFile=$2
|
||||
|
||||
if [ "$targetPid" = "" ]; then
|
||||
echo "Usage: runhat [ -d | -e | -s serial ] target-pid [output-file]"
|
||||
echo "Usage: runhat [ -d | -e | -s serial ] target-pid"
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -932,18 +931,14 @@ function runhat()
|
||||
return
|
||||
fi
|
||||
|
||||
adb ${adbOptions} shell >/dev/null mkdir /data/misc
|
||||
adb ${adbOptions} shell chmod 777 /data/misc
|
||||
|
||||
# send a SIGUSR1 to cause the hprof dump
|
||||
# issue "am" command to cause the hprof dump
|
||||
local devFile=/sdcard/hprof-$targetPid
|
||||
echo "Poking $targetPid and waiting for data..."
|
||||
adb ${adbOptions} shell kill -10 $targetPid
|
||||
adb ${adbOptions} shell am dumpheap $targetPid $devFile
|
||||
echo "Press enter when logcat shows \"hprof: heap dump completed\""
|
||||
echo -n "> "
|
||||
read
|
||||
|
||||
local availFiles=( $(adb ${adbOptions} shell ls /data/misc | grep '^heap-dump' | sed -e 's/.*heap-dump-/heap-dump-/' | sort -r | tr '[:space:][:cntrl:]' ' ') )
|
||||
local devFile=/data/misc/${availFiles[0]}
|
||||
local localFile=/tmp/$$-hprof
|
||||
|
||||
echo "Retrieving file $devFile..."
|
||||
|
Reference in New Issue
Block a user