Assuming the Android NDK is installed in ~/android-ndk-r8e, and the device is rooted, su and change the system permission command for to be writable, for example, for Asus Transformer TF201,
mount -o rw,remount -t yaffs2 /dev/block/mmcblk0p1 /system
Then push android-ndk-r8e\prebuilt\android-arm\gdbserver to /system/bin.
2. adb push the native executable app_executable to /data/data/app_name
3. In device sdcard, make a working directory /sdcard/app_name
4. On the device or emulator, go to /sdcard/app_name, launch a new command (port number 5039 is an example)
gdbserver : 5039 /data/data/app_name/app_executable some_command_line_options_defined_in_exe
5. On the host, forward port 5039 to the device with adb:
adb forward tcp: 5039 tcp: 5039
6. Assuming the executable build directory is exe_build_directory, set source path with "set solib-search-path ~/android-ndk-r8e/platforms/android-9/arch-arm/usr/include ~/android-ndk-r8e/sources/cxx-stl/gnu-libstdc+/4.6/include: ~/android-ndk-r8e/sources/cxx-stl/gnu-libstdc+/4.6/libs/armeabi/include: exe_build_directory"
7. Go to the exe_build_directory, start a special version of gdb client that lives in the "prebuilt" area of the source tree with ddd, for example,
ddd --debugger ~/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gdb
8. Then "file app_executable", the source code trees are brought in ddd window,
9. Connect to the device by issuing the gdb command in ddd window:
target remote: 5039
and then have fun with ddd
No comments:
Post a Comment