的Andr​​oid NDK调试C / C ++ code在Eclipse - 断点不会打断点、oid、Andr、NDK

2023-09-12 22:40:19 作者:扯淡的生活

我下载的Andr​​oid SDK套件,Linux和Android NDK。安装ADT,我安装了CDT。

I downloaded Android SDK Bundle for Linux and Android NDK. ADT was installed, I installed CDT.

我创建了一个Android项目,并添加原生支持(JNI)。然后,我在Java的code的出口在C code写的本地函数。在C ++ code我定义这个功能。

I created a Android project and added native support (jni). Then I wrote native function in java-code which exporting in c++ code. In c++ code I defined this function.

Java的code:

Java-code:

static {
    System.loadLibrary("test");
}

private native String get_text_from_cpp();

C ++ code(H):

c++ code (h):

extern "C"{
   JNIEXPORT jstring JNICALL Java_com_example_test_MainActivity_get_1text_1from_1cpp(JNIEnv *, jobject);
}

C ++ code(CPP):

c++ code (cpp):

JNIEXPORT jstring JNICALL Java_com_example_test_MainActivity_get_1text_1from_1cpp(JNIEnv * env, jobject){
    return env->NewStringUTF( "hello from C++" );
}

code工作没有错误。但是,当我设置断点在C code这是打不到。

Code works without errors. But when I set breakpoint in c++ code it is not hit.

打造-NKD NDK_DEBUG = 1 - 包括

build-nkd NDK_DEBUG = 1 - are included

我跟着这说明 http://tool​​s.android.com/recent/usingthendkplugin

Android.mk在JNI /有LOCAL_CFLAGS:= -g

Android.mk in jni/ has LOCAL_CFLAGS := -g

我看了很多资料,但我便无法定制的Eclipse。请帮助任何人。

I have read very much information but I could't customized Eclipse. Please, help anybody.

PS:我很抱歉,我的英语不是我的母语。我写作有困难。

PS: I am sorry for my English is not my native language. I have difficulty in writing.

地址:另外,在调试控制台显示: 警告:无法加载共享库符号9​​5库,例如:/系统/斌/连接器。 使用info sharedlibrary命令来查看完整列表。 你需要设置solib搜索路径或设置SYSROOT? 警告:找不到动态连接器的断点功能。 GDB将重试eventurally。同时,它很可能 这GDB无法调试共享库初始化 或解决悬而未决的断点的dlopen()之后。

Add: Also during debug in console shows: "warning: Could not load shared library symbols for 95 libraries, e.g. /system/bin/linker. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"? warning: Unable to find dynamic linker breakpoint function. GDB will retry eventurally. Meanwhile, it is likely that GDB is unable to debug shared library initializers or resolve pending breakpoints after dlopen()."

推荐答案

我使用的技巧是把usleep调用在我的调试code中的第一个原生行。

The trick I use is to put a usleep call as the very first native line in my debug code.

这使得你的线程睡眠,并给出了调试器有机会为你准备好。

This makes your thread sleep and gives the debugger a chance to be ready for you.

#include <unistd.h>

.
.
.

#ifndef NDEBUG
usleep(5000 * 1000);
#endif