Last active
June 24, 2022 07:57
-
-
Save chitacan/4554067 to your computer and use it in GitHub Desktop.
Small shell script to find process id via android shell and attach "strace" to it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
version="0.0.1" | |
TARGET_PROCESS=$1 | |
if [ ! $TARGET_PROCESS ]; then | |
echo | |
echo "Usage: sticker [process name]" | |
echo | |
exit | |
fi | |
# get process info | |
INFO=`adb shell ps | grep $TARGET_PROCESS` | |
if [ $? = 1 ]; then | |
echo "cannot find process info, abort" | |
exit | |
fi | |
# TODO : what if we grep more than 1 processes?? | |
IFS=' ' INFO_ARRAY=( $INFO ) | |
echo | |
echo "Found process:" | |
echo "$(tput setaf 6)${INFO_ARRAY[8]}$(tput sgr0)" | |
echo | |
# get pid | |
PID=${INFO_ARRAY[1]} | |
# trace pid and write to "trace.txt" | |
adb shell strace -fFp $PID | tee trace.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment