Debugging Android NDK C/C++ code in Eclipse - breakpoints are not hit -
i downloaded android sdk bundle linux , android ndk. adt installed, installed cdt.
i created android project , added native support (jni). wrote native function in java-code exporting in c++ code. in c++ code defined function.
java-code:
static { system.loadlibrary("test"); } private native string get_text_from_cpp();
c++ code (h):
extern "c"{ jniexport jstring jnicall java_com_example_test_mainactivity_get_1text_1from_1cpp(jnienv *, jobject); }
c++ code (cpp):
jniexport jstring jnicall java_com_example_test_mainactivity_get_1text_1from_1cpp(jnienv * env, jobject){ return env->newstringutf( "hello c++" ); }
code works without errors. when set breakpoint in c++ code not hit.
build-nkd ndk_debug = 1 - included
i followed instructions http://tools.android.com/recent/usingthendkplugin
android.mk in jni/ has local_cflags := -g
i have read information could't customized eclipse. please, anybody.
ps: sorry english not native language. have difficulty in writing.
add: during debug in console shows: "warning: not load shared library symbols 95 libraries, e.g. /system/bin/linker. use "info sharedlibrary" command see complete listing. need "set solib-search-path" or "set sysroot"? warning: unable find dynamic linker breakpoint function. gdb retry eventurally. meanwhile, gdb unable debug shared library initializers or resolve pending breakpoints after dlopen()."
the trick use put usleep call first native line in debug code.
this makes thread sleep , gives debugger chance ready you.
#include <unistd.h> . . . #ifndef ndebug usleep(5000 * 1000); #endif
Comments
Post a Comment