问题
While investigating a problem with hitting breakpoints in native code, I decided to check if ndk-gdb works OK. I've deleted app_process, started Java debugging and ran ndk-gdb --force
. Guess what, app_process is not created. ndk-gdb --verbose
output has this line :
## COMMAND: adb_cmd pull /system/bin/app_process obj/local/armeabi-v7a/app_process
remote object '/system/bin/app_process' not a file or directory
Pulled app_process from device/emulator.
I've uninstalled the app from the target device, rebooted the device and repeated. Still no app_process. So, I wonder what's the problem here, and I also wonder when is this file created, and by what process / script.
回答1:
As mentioned before, Android 5.0 has /system/bin/app_process
as a symlink to /system/bin/app_process32
. Since a symlink cannot be pulled with adb pull
, the ndk-gdb
script will not be able to work as-is.
Change ndk-gdb
as follows to support api21 changes as well as backwards compatibility for < api21:
# Get the app_server binary from the device
APP_PROCESS=$APP_OUT/app_process
if [ "$API_LEVEL" -lt "21" ] ; then
run adb_cmd pull /system/bin/app_process `native_path $APP_PROCESS`
log "Pulled app_process from device/emulator to $APP_PROCESS"
else
run adb_cmd pull /system/bin/app_process32 `native_path $APP_PROCESS`
log "Pulled app_process32 from device/emulator to $APP_PROCESS"
fi
EDIT: or:
# Get the app_server binary from the device
APP_PROCESS=$APP_OUT/app_process
APP_PROCESS_DEVICE=app_process32
if [ "$API_LEVEL" -lt "21" ] ; then
APP_PROCESS_DEVICE=app_process
fi
run adb_cmd pull /system/bin/$APP_PROCESS_DEVICE `native_path $APP_PROCESS`
log "Pulled $APP_PROCESS_DEVICE from device/emulator to $APP_PROCESS"
Original Change is also here: http://pastebin.com/YfxNs06U. Note that this change renames app_process32
to app_process
when it is pulled to your development machine to support having a single debugging config in Eclipse.
回答2:
Found the problem. My device is running Android 5.0 preview, and app_process there is a symlink to a file called app_process32. So pulling app_process32 works fine.
回答3:
In addition to the answer of Violet Giraffe, exchange in the script ndk-gdb the line
run adb_cmd pull /system/bin/app_process `native_path $APP_PROCESS`
with
run adb_cmd pull /system/bin/app_process32 `native_path $APP_PROCESS`
This solved the problem for me for this Android 5.0 issue and I was able to build and debug as before.
来源:https://stackoverflow.com/questions/26530675/ndk-debugging-ndk-gdb-fails-to-pull-app-process-who-and-when-creates-the-app-p