Bug in ndk-gdb.py: cannot pull /system/bin/app_process

22 views
Skip to first unread message

Kari Palenius

unread,
Sep 14, 2015, 11:01:27 AM9/14/15
to android-ndk
Hi,

I managed to spot a bug in ndk-gdb.py and I though it might be helpful to post the solution here as well. When running ndk-gdb-py.cmd on Windows with ndk-r10e, I ran into a issue on some phones that /system/bin/app_process was not pulled successfully. The issue turned out to be caused by the following check in ndk-gdb.py.

# If we are debugging 64-bit app, then we need to pull linker64,
# app_process64 and libc.so from lib64 directory.
linker_name = 'linker'
libdir_name = 'lib'
app_process_name = 'app_process32'
if (app_bits == 64):
    linker_name = 'linker64'
    libdir_name = 'lib64'
    app_process_name = 'app_process64'
else:
    retcode,_ = adb_cmd(False, ['shell', 'test -e /system/bin/%s' % (app_process_name)])
    if retcode:
        # Old 32-bit devices do not have app_process32. Pull
        # app_process in this case
        app_process_name = 'app_process'

The else part checks whether the '/system/bin/app_process32' exists. At least on my setup the return value was 0 no matter what the test returns. Therefore app_process_name resolved into a wrong value. I managed to fix the issue by changing the check to be

_,retcode = adb_cmd(False, ['shell', '[ -f "/system/bin/%s" ] && echo 1 || echo 0' % (app_process_name)])

I am pretty sure there is also a cleaner way to fix this, but for now it seems to work.

--Kari Palenius
Reply all
Reply to author
Forward
0 new messages