forked from openkylin/platform_build
Utility to dump stacks from arbitrary processes.
Saves any existing traces, dumps stacks from the target process,
then restores the original traces.
(cherry picked from commit f582437162
)
Change-Id: I2513f0de0d90cccd56c4949ca7d218e430439c00
This commit is contained in:
parent
c47bea9dd9
commit
cfe0969ab9
35
envsetup.sh
35
envsetup.sh
|
@ -737,7 +737,40 @@ function pid()
|
||||||
# to the usual ANR traces file
|
# to the usual ANR traces file
|
||||||
function systemstack()
|
function systemstack()
|
||||||
{
|
{
|
||||||
adb shell echo '""' '>>' /data/anr/traces.txt && adb shell chmod 776 /data/anr/traces.txt && adb shell kill -3 $(pid system_server)
|
stacks system_server
|
||||||
|
}
|
||||||
|
|
||||||
|
function stacks()
|
||||||
|
{
|
||||||
|
if [[ $1 =~ ^[0-9]+$ ]] ; then
|
||||||
|
local PID="$1"
|
||||||
|
elif [ "$1" ] ; then
|
||||||
|
local PID=$(pid $1)
|
||||||
|
else
|
||||||
|
echo "usage: stacks [pid|process name]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$PID" ] ; then
|
||||||
|
local TRACES=/data/anr/traces.txt
|
||||||
|
local ORIG=/data/anr/traces.orig
|
||||||
|
local TMP=/data/anr/traces.tmp
|
||||||
|
|
||||||
|
# Keep original traces to avoid clobbering
|
||||||
|
adb shell mv $TRACES $ORIG
|
||||||
|
|
||||||
|
# Make sure we have a usable file
|
||||||
|
adb shell touch $TRACES
|
||||||
|
adb shell chmod 666 $TRACES
|
||||||
|
|
||||||
|
# Dump stacks and wait for dump to finish
|
||||||
|
adb shell kill -3 $PID
|
||||||
|
adb shell notify $TRACES
|
||||||
|
|
||||||
|
# Restore original stacks, and show current output
|
||||||
|
adb shell mv $TRACES $TMP
|
||||||
|
adb shell mv $ORIG $TRACES
|
||||||
|
adb shell cat $TMP | less -S
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function gdbclient()
|
function gdbclient()
|
||||||
|
|
Loading…
Reference in New Issue