Android GDB is not loading c++ shared library

杀马特。学长 韩版系。学妹 提交于 2019-12-01 08:17:47

问题


I've been trying to debug a shared library that I wrote in c/c++ but I can not debug it using eclipse. When I set a breakpoint is never hit and after execute info sharedlibrary in gdb, I got he following, confirming that the library is not there (called libtest-java.so)

From        To          Syms Read   Shared Object Library
                        No          /system/bin/linker
0x40093070  0x400c36f8  Yes         /Users/jpuig/Development/test/git/test_lib-protoype/java/test_Android/obj/local/armeabi/libc.so
                        No          libstdc++.so
                        No          libm.so
                        No          liblog.so
                        No          libcutils.so
                        No          libgccdemangle.so
                        No          libcorkscrew.so
                        No          libutils.so
                        No          libbinder.so
                        No          libhardware.so
                        No          libmemtrack.so
                        No          libz.so
                        No          libandroidfw.so
                        No          libexpat.so
                        No          libstlport.so
                        No          libnativehelper.so
                        No          libnetutils.so
                        No          libsync.so
                        No          libui.so
                        No          libGLES_trace.so
                        No          libEGL.so
                        No          libGLESv2.so
                        No          libgui.so
                        No          libinput.so
                        No          libcamera_metadata.so
                        No          libcamera_client.so
                        No          libpng.so
                        No          libft2.so
                        No          libjpeg.so
                        No          libgabi++.so
                        No          libicuuc.so
                        No          libicui18n.so
                        No          libskia.so
                        No          libsqlite.so
                        No          libGLESv1_CM.so
                        No          libETC1.so
                        No          libwpa_client.so
                        No          libhardware_legacy.so
                        No          libselinux.so
                        No          libsonivox.so
                        No          libcrypto.so
                        No          libssl.so
                        No          libstagefright_foundation.so
                        No          libspeexresampler.so
                        No          libaudioutils.so
                        No          libmedia.so
                        No          libusbhost.so
                        No          libharfbuzz_ng.so
                        No          libLLVM.so
                        No          libbcinfo.so
                        No          libbcc.so
                        No          libRS.so
                        No          libRScpp.so
                        No          libhwui.so
                        No          libandroid_runtime.so
                        No          libdvm.so
                        No          libjavacore.so
                        No          memtrack.msm8974.so
                        No          libdrmframework.so
                        No          libdrmframework_jni.so
                        No          libconnectivitymanager.so
                        No          libstagefright_omx.so
                        No          libstagefright_yuv.so
                        No          libvorbisidec.so
                        No          libpowermanager.so
                        No          libstagefright_enc_common.so
                        No          libstagefright_avc_common.so
                        No          libstagefright.so
                        No          libmtp.so
                        No          libexif.so
                        No          libstagefright_amrnb_common.so
                        No          libmedia_jni.so
                        No          libexif_jni.so
                        No          libcommon_time_client.so
                        No          libnbaio.so
                        No          libeffects.so
                        No          libaudioflinger.so
                        No          libvideoeditor_osal.so
                        No          libvideoeditor_videofilters.so
                        No          libvideoeditorplayer.so
                        No          libvideoeditor_core.so
                        No          libvideoeditor_jni.so
                        No          librs_jni.so
                        No          libandroid.so
                        No          libwilhelm.so
                        No          libOpenSLES.so
                        No          libjnigraphics.so
                        No          libwebviewchromium.so
                        No          libwebviewchromium_plat_support.so
                        No          libjavacrypto.so
                        No          libgsl.so
                        No          libadreno_utils.so
                        No          libEGL_adreno.so
                        No          libGLESv1_CM_adreno.so
                        No          libGLESv2_adreno.so
                        No          eglsubAndroid.so
                        No          libsc-a3xx.so
                        No          libqdutils.so
                        No          libmemalloc.so
                        No          gralloc.msm8974.so
0x77dbd638  0x77eb97b8  No          /Users/jpuig/Development/test/git/test_lib-protoype/java/test_Android/obj/local/armeabi/libtest-java.so

There is any way to load this library manually or something?? in the make file I use the following:

include $(CLEAR_VARS)

###### 
LOCAL_CPPFLAGS += -D DEBUG=1 -D NDK_DEBUG=1 
LOCAL_CFLAGS += -D DEBUG=1 -D NDK_DEBUG=1 
APP_OPTIM := debug
APP_CFLAG := -g -ggdb -O0
######

Thanks a lot for your time!


回答1:


I managed to fix it!

I was loading the library in an other class and my MainActivity was calling it when the button was pressed, therefore when GDB was ready no libraries where loaded... I thought that GDB will pick up the new library during runtime, so in order to load the library I just added the following lines in the static constructor of the first called class:

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


来源:https://stackoverflow.com/questions/21532229/android-gdb-is-not-loading-c-shared-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!