Commit b778482a authored by Josh Gao's avatar Josh Gao Committed by Gerrit Code Review
Browse files

Merge "[ndk-gdb.py] Select which ps command to run on the device."

parents ce64ba12 70af7d0e
......@@ -451,13 +451,22 @@ def get_pid_of(package_name):
package names like com.exampleisverylongtoolongbyfar.plasma
exceed the limit.
'''
ps_command = 'ps'
retcode,output = adb_cmd(False, ['shell', 'readlink $(which ps)'])
if output:
output = output.replace('\r', '').splitlines()[0]
if output == 'busybox':
ps_command = 'ps -w'
retcode,output = adb_cmd(False,['shell', ps_command])
# Perform the check on the device to avoid an adb roundtrip
# Some devices might not have readlink or which, so we need to check for
# them.
ps_script = '''
if [ ! -x /system/bin/readlink -o ! -x /system/bin/which ]; then
ps;
elif [ $(readlink $(which ps)) == "toolbox" ]; then
ps;
else
ps -w;
fi
'''
ps_script = " ".join([line.strip() for line in ps_script.splitlines()])
retcode, output = adb_cmd(False, ['shell', ps_script])
output = output.replace('\r', '').splitlines()
columns = output.pop(0).split()
try:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment