Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 29e99d37 authored by Jeff Brown's avatar Jeff Brown Committed by Android Git Automerger
Browse files

am e787eb61: am 91efe6bb: Merge "Enhance \'stacks\' script to handle native...

am e787eb61: am 91efe6bb: Merge "Enhance \'stacks\' script to handle native processes." into klp-dev

* commit 'e787eb61':
  Enhance 'stacks' script to handle native processes.
parents 744806df e787eb61
Loading
Loading
Loading
Loading
+34 −20
Original line number Original line Diff line number Diff line
@@ -847,12 +847,22 @@ function stacks()
    if [[ $1 =~ ^[0-9]+$ ]] ; then
    if [[ $1 =~ ^[0-9]+$ ]] ; then
        local PID="$1"
        local PID="$1"
    elif [ "$1" ] ; then
    elif [ "$1" ] ; then
        local PID=$(pid $1)
        local PIDLIST="$(pid $1)"
        if [[ $PIDLIST =~ ^[0-9]+$ ]] ; then
            local PID="$PIDLIST"
        elif [ "$PIDLIST" ] ; then
            echo "more than one process: $1"
        else
            echo "no such process: $1"
        fi
    else
    else
        echo "usage: stacks [pid|process name]"
        echo "usage: stacks [pid|process name]"
    fi
    fi


    if [ "$PID" ] ; then
    if [ "$PID" ] ; then
        # Determine whether the process is native
        if adb shell ls -l /proc/$PID/exe | grep -q /system/bin/app_process ; then
            # Dump stacks of Dalvik process
            local TRACES=/data/anr/traces.txt
            local TRACES=/data/anr/traces.txt
            local ORIG=/data/anr/traces.orig
            local ORIG=/data/anr/traces.orig
            local TMP=/data/anr/traces.tmp
            local TMP=/data/anr/traces.tmp
@@ -866,12 +876,16 @@ function stacks()


            # Dump stacks and wait for dump to finish
            # Dump stacks and wait for dump to finish
            adb shell kill -3 $PID
            adb shell kill -3 $PID
        adb shell notify $TRACES
            adb shell notify $TRACES >/dev/null


            # Restore original stacks, and show current output
            # Restore original stacks, and show current output
            adb shell mv $TRACES $TMP
            adb shell mv $TRACES $TMP
            adb shell mv $ORIG $TRACES
            adb shell mv $ORIG $TRACES
        adb shell cat $TMP | less -S
            adb shell cat $TMP
        else
            # Dump stacks of native process
            adb shell debuggerd -b $PID
        fi
    fi
    fi
}
}