Thr*_*ash 9 c++ debugging android gdb android-ndk
我有一个项目,可以很好地编译,加载和运行在Android设备中.当我调用gdb服务器时,它也可以正常工作.然后,当我调用gdb客户端运行断点时,就会出现消息:
Error while mapping shared library sections:
/system/bin/linker: No such file or directory.
libandroid.so: No such file or directory.
liblog.so: No such file or directory.
libEGL.so: No such file or directory.
libOpenSLES.so: No such file or directory.
libGLESv2.so: No such file or directory.
libGLESv2_POWERVR_SGX540_120.so: No such file or directory.
...
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code
warning: shared library handler failed to enable breakpoint
Run Code Online (Sandbox Code Playgroud)
这是我当前的Android.mk文件,对于这种情况,可能会缺少一些额外的设置:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LS_CPP=$(subst $(1)/,,$(wildcard $(1)/*.cpp))
APP_MODULES := callbacks
APP_PLATFORM := android-14
APP_OPTIM:= debug
LOCAL_CFLAGS := -DRAPIDXML_NO_EXCEPTIONS
LOCAL_CFLAGS += -g
LOCAL_CFLAGS += -ggdb
LOCAL_CFLAGS += -O1
LOCAL_MODULE:=app3D
LOCAL_SRC_FILES := $(call LS_CPP,$(LOCAL_PATH))
LOCAL_LDLIBS := -landroid -llog -lEGL -lOpenSLES -lGLESv2
LOCAL_STATIC_LIBRARIES := android_native_app_glue png
LOCAL_STATIC_LIBRARIES += /jni
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)
$(call import-module,libpng)
Run Code Online (Sandbox Code Playgroud)
有关这种奇怪错误的原因是什么以及如何摆脱它的任何建议?
所有评论和提示都深受欢迎和欢迎.
使用ndk-gdb而不是标准gdb.从项目根目录启动它.--verbose如果您想了解ndk-gdb正在做什么,请考虑使用选项.您必须将此行添加到您的AndroidManifest.xml:
android:debuggable="true"
Run Code Online (Sandbox Code Playgroud)
例如,我的看起来像:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:debuggable="true" >
Run Code Online (Sandbox Code Playgroud)
你的application.mk应该定义
APP_OPTIM := debug
Run Code Online (Sandbox Code Playgroud)
有了这个,您不必添加-g到编译器标志,ndk-build将自动执行此操作.