Three fixes for ndk-gdb and ndk-gdb.py:

1) Always try to use app_process32/app_process64 to
avoid pulling symlinks (this does not work on win hosts).

2) Don't change the name of linker64 when pulling it from the device
(otherwise symbols from linker64 are not being loaded in 64-bit case).

3) Always pull app_process32/app_process64 as app_process to avoid
inconsistency.

Change-Id: I1e4f066b77ee2fc37b879c1a1924b8396921539c
Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
diff --git a/ndk-gdb b/ndk-gdb
index 6746a05..a9438f2 100755
--- a/ndk-gdb
+++ b/ndk-gdb
@@ -789,29 +789,30 @@
     exit 1
 fi
 
-# If we are debugging 32-bit application on 64-bit device
-# then we need to pull app_process32, not app_process
-APP_PROCESS_NAME=app_process
-if [ "$COMPAT_ABI_BITS" = 32 ] && [ -n "$CPU_ABILIST64" ] ; then
-    APP_PROCESS_NAME=app_process32
-    log "We are debugging 32-bit app on 64-bit device"
-fi
-
-# If we are debugging 64-bit app, then we need to pull linker64
-# and libc.so from lib64 directory
+# 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 [ "$COMPAT_ABI_BITS" = 64 ] ; then
     LINKER_NAME=linker64
     LIBDIR_NAME=lib64
+    APP_PROCESS_NAME=app_process64
+else
+    # Old 32-bit devices do not have app_process32. Pull
+    # app_process in this case
+    run adb_cmd shell test -e /system/bin/$APP_PROCESS_NAME
+    if [ $? != 0 ] ; then
+        APP_PROCESS_NAME=app_process
+    fi
 fi
 
 # Get the app_server binary from the device
-APP_PROCESS=$APP_OUT/$APP_PROCESS_NAME
+APP_PROCESS=$APP_OUT/app_process
 run adb_cmd pull /system/bin/$APP_PROCESS_NAME `native_path $APP_PROCESS`
 log "Pulled $APP_PROCESS_NAME from device/emulator."
 
-run adb_cmd pull /system/bin/$LINKER_NAME `native_path $APP_OUT/linker`
+run adb_cmd pull /system/bin/$LINKER_NAME `native_path $APP_OUT/$LINKER_NAME`
 log "Pulled $LINKER_NAME from device/emulator."
 
 run adb_cmd pull /system/$LIBDIR_NAME/libc.so `native_path $APP_OUT/libc.so`