Include NDK R13 Method
////////////////eclipse setting//////////////////
http://www.eclipse.org/downloads/packages/release/Kepler/SR2
Eclipse Standard 4.3.2 -> linux 64bits
install eclipse-standard-kepler-SR2-linux-gtk-x86_64.tar.gz
extract to /opt/eclipse
chmod 755 -R /opt/eclipse
gedit /opt/eclipse.ini
-XX:PermSize=64m
-XX:MaxPermSize=256m
-Xms128m
-Xmx4096m
//android sdk path
http://dl.google.com/android/ndk/android-ndk-r8e-linux-x86_64.tar.bz2
install ndk to /opt/android-ndk-r8e
chmod 755 -R /opt/android-ndk-r8e
http://dl.google.com/android/android-sdk_r22.2.1-linux.tgz
install android sdk to /opt/android-sdk-linux
http://dl-ssl.google.com/android/repository/platform-tools_r18.0.1-linux.zip
install android sdk platform-tools to /opt/android-sdk-linux
chmod 755 -R /opt/android-sdk-linux
//start eclipse
help -> install new software
[work with]: Kepler - http://download.eclipse.org/releases/kepler
install cdt
programming -> c++ development tools
programming -> c++ development tools sdk
http://dl.google.com/android/ADT-22.2.1.zip
help -> install new software
Add... -> Archive... -> ADT-22.2.1.zip
window -> android sdk manager
install only
1.android sdk build-tools 18.1.1
2.android api 4.3 api 18
window -> perferences -> android
sdk location:/opt/android-sdk-linux
ndk location:/opt/android-ndk-r8e
//If you want to use Android 5.1.1(API 22) refer to here
https://fatalfeel.blogspot.tw/2013/09/build-eclipse-debug-environment-for.html
/////////////////////jni setting///////////////
//path
gedit /etc/environment
add
/opt/android-ndk-r8e
reboot
/////ndk modify
gedit /opt/android-ndk-r8e/ndk-gdb
//find
APP_PROCESS=$APP_OUT/app_process
run adb_cmd pull /system/bin/app_process `native_path $APP_PROCESS`
log "Pulled app_process from device/emulator."
//modify to
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
//save to ndk-gdb
//NKD r10e
gedit /opt/android-ndk-r10e/ndk-gdb
#adb_var_shell BCFILES run-as $PACKAGE_NAME /system/bin/sh -c "ls lib/*.bc"
to
adb_var_shell BCFILES run-as $PACKAGE_NAME /system/bin/sh -c '"ls lib/*.bc"'
//save to ndk-gdb
cp /opt/android-ndk-xxx/ndk-gdb /opt/android-ndk-xxx/ndk-gdb-eclipse
gedit /opt/android-ndk-xxx/ndk-gdb-eclipse
//remove
$GDBCLIENT -x `native_path $GDBSETUP`
//save to ndk-gdb-eclipse
#NDK R13
//add
def SigHandler(signum, frame):
print("ctrl+z received & exit No. =\n", signum)
//comment
#gdbrunner.start_gdb(gdb_path, gdb_commands, gdb_flags)
//add
print("press ctrl+z to exit")
signal.signal(signal.SIGTSTP, SigHandler)
signal.pause()
//search
gdb_commands += "set solib-search-path {}\n".format(solib_search_path)
//after the line add
print(gdb_commands)
Patch: http://www.mediafire.com/file/ew38e44tail6i4k/ndk-gdb-eclipse.py
gedit ~/jni/Android.mk
//add after LOCAL_MODULE
LOCAL_STRIP_MODULE := false
//build c++ debug
convert c/c++
right click file > new > other
convert c/c++
makefile project = android gcc
properties > c/c++ build
uncheck [use defaultbuild command]
[build command]: ndk-build NDK_DEBUG=1 V=1
//generate process
Debug As -> Android Application
build project and install app to target
#NDK R13
After build project, generate 1 file
/root/nativeeglexample/libs/armeabi-v7a/gdb.setup
#NDK R10
//open new Termial
cd /root/nativeeglexample
ndk-gdb --start
then press q, press y
generate 2 files
/root/nativeeglexample/obj/local/armeabi-v7a/app_process
/root/nativeeglexample/obj/local/armeabi-v7a/gdb.setup
#NDK R13
cd /root/nativeeglexample
ndk-gdb --launch --verbose
then press q, press y
generate 1 file
/root/nativeeglexample/obj/local/armeabi-v7a/system/bin/app_process
#NDK R10
gedit /root/nativeeglexample/obj/local/armeabi-v7a/gdb.setup
//remove line
target remote :5039
//save as gdb_eclipse.setup
#NDK R13
copy
/root/nativeeglexample/libs/armeabi-v7a/gdb.setup
to
/root/nativeeglexample/obj/local/armeabi-v7a/gdb.setup
//then run ndk-gdb-eclipse.py print follow messages
set osabi GNU/Linux
file '/root/nativeeglexample/obj/local/armeabi-v7a/system/bin/app_process'
set solib-absolute-prefix /root/nativeeglexample/obj/local/armeabi-v7a
set solib-search-path /root/nativeeglexample/obj/local/armeabi-v7a:/root/nativeeglexample/obj/local/armeabi-v7a/system/bin:/root/nativeeglexample/obj/local/armeabi-v7a/system/lib
//copy the print messages to /root/nativeeglexample/obj/local/armeabi-v7a/gdb.setup and keep [directory] path
for example:
set osabi GNU/Linux
file '/root/nativeeglexample/obj/local/armeabi-v7a/system/bin/app_process'
set solib-absolute-prefix /root/nativeeglexample/obj/local/armeabi-v7a
set solib-search-path /root/nativeeglexample/obj/local/armeabi-v7a:/root/nativeeglexample/obj/local/armeabi-v7a/system/bin:/root/nativeeglexample/obj/local/armeabi-v7a/system/lib
directory /opt/android-ndk/platforms/android-22/arch-arm/usr/include /opt/android-ndk/sources/cxx-stl/gnu-libstdc++ jni/../../source /opt/android-ndk/sources/cxx-stl/gnu-libstdc++/4.9/include /opt/android-ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include /opt/android-ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/backward
File: http://www.mediafire.com/file/i6p3im2pc7yvy91/gdb.setup
//Debugger menu popup for gdbserver
Debug As->Debug configurations, double click [C/C++ Application]
click into bottom line -Select other...-
enable [Use configuration specific settings]
select [Standard Create Process Launcher]
(Linux => [Legacy Create Process Launcher])
(1)[Main] > [C/C++ Application:] obj/local/armeabi-v7a/app_process
(2)[Debugger:] GdbServer
(3)[Stop on starup at:] Java_com_example_NativeEglExample_nativeOnStart
(4)[GDB debugger:] /opt/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gdb
(5)[GDB command file:] /root/nativeeglexample/obj/local/armeabi-v7a/gdb-eclipse.setup
(6)[Verbose console mode] enable it. For watching running text
(7)[Connection] > [Type:] TCP
(8)[Host name or Ip address:] localhost
(9)[Port number:] 5039
//breakpoint
breakpoint at super.onCreate(savedInstanceState);
Debug As -> Android Application
when stop at super.onCreate(savedInstanceState);
open new Termial
cd /root/nativeeglexample
ndk-gdb-eclipse
Debug As -> c/c++ Application
retun to super.onCreate(savedInstanceState);
continue it~~~done
If add new break point, drag /root/nativeeglexample/xxxxxx.cpp to eclipse
set breakpoint, done
demo photo:
https://picasaweb.google.com/106185541018774360364/IMx6#6234033020574002994
沒有留言:
張貼留言