From cfe0969ab9db403684d2a6a97dd6c487cc0b13fc Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Tue, 19 Feb 2013 17:00:46 -0800 Subject: [PATCH 1/2] 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 f582437162ff483b342ad9d02cb0af948a734c5a) Change-Id: I2513f0de0d90cccd56c4949ca7d218e430439c00 --- envsetup.sh | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/envsetup.sh b/envsetup.sh index b4199b073..a8e7a1347 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -737,7 +737,40 @@ function pid() # to the usual ANR traces file 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() From 301bbadb12a6ad5df8baa1aaa7a11adb6329b7d9 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Fri, 8 Mar 2013 10:20:47 -0800 Subject: [PATCH 2/2] Function to grep AndroidManifest.xml files. (cherry picked from commit 50b61e9e66bad2f8addc425271b41e74babf3a34) Change-Id: I1998a9d6a05176fc7fc8643c5d1c40e2dd699d4e --- envsetup.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/envsetup.sh b/envsetup.sh index a8e7a1347..b4bfaa9b0 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -872,6 +872,11 @@ function resgrep() for dir in `find . -name .repo -prune -o -name .git -prune -o -name res -type d`; do find $dir -type f -name '*\.xml' -print0 | xargs -0 grep --color -n "$@"; done; } +function mangrep() +{ + find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -name 'AndroidManifest.xml' -print0 | xargs -0 grep --color -n "$@" +} + case `uname -s` in Darwin) function mgrep()