Android ndk gdb loaded shared libraries are missing *.oat
Asked Answered
C

1

102

Both gdb 7.7 and gbd 7.11 missed some shared libraries when debugging my device (oppo r7s). I've pulled all libraries to local.
Here is a complete list of libraries shown by info shared

(gdb) info shared
From        To          Syms Read   Shared Object Library
0x40000980  0x40009640  Yes (*)     Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\linker
0x401c7940  0x401ce6e8  Yes (*)     Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\libutils.so
                        No          libstdc++.so
                        No          libm.so
0x4013bbb0  0x4017329c  Yes (*)     Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\libc.so
                        No          libbinder.so
                        No          liblog.so
                        No          libhardware.so
                        No          libcutils.so
                        No          libc++.so
                        No          libLLVM.so
                        No          libbcinfo.so
                        No          libunwind.so
                        No          libz.so
                        No          libpng.so
                        No          libpowermanager.so
                        No          libcommon_time_client.so
                        No          libstlport.so
                        No          libui.so
                        No          libsync.so
                        No          libgui.so
                        No          libft2.so
                        No          libbcc.so
                        No          libGLESv2.so
                        No          libGLESv1_CM.so
                        No          libEGL.so
                        No          libunwind-ptrace.so
                        No          libgccdemangle.so
                        No          libcrypto.so
                        No          libicuuc.so
                        No          libicui18n.so
                        No          libjpeg.so
                        No          libexpat.so
                        No          libpcre.so
                        No          libharfbuzz_ng.so
                        No          libstagefright_foundation.so
                        No          libsonivox.so
                        No          libnbaio.so
                        No          libcamera_client.so
                        No          libaudioutils.so
                        No          libaudioparameter.so
                        No          libinput.so
                        No          libhardware_legacy.so
                        No          libcamera_metadata.so
                        No          libgabi++.so
                        No          libskia.so
                        No          libRScpp.so
                        No          libRS.so
                        No          libwpa_client.so
                        No          libnetutils.so
                        No          libspeexresampler.so
0x402635b0  0x402724a4  Yes (*)     Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\libandroidfw.so
                        No          libGLES_trace.so
                        No          libbacktrace.so
                        No          libusbhost.so
                        No          libssl.so
                        No          libsqlite.so
                        No          libsoundtrigger.so
                        No          libselinux.so
                        No          libprocessgroup.so
                        No          libpdfium.so
                        No          libnetd_client.so
                        No          libnativehelper.so
                        No          libnativebridge.so
                        No          libminikin.so
                        No          libmemtrack.so
                        No          libmedia.so
                        No          libinputflinger.so
                        No          libimg_utils.so
                        No          libhwui.so
                        No          libassert_tip_service.so
                        No          libETC1.so
0x4006d230  0x400ca9dc  Yes (*)     Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\libandroid_runtime.so
                        No          libNimsWrap.so
                        No          libsigchain.so
                        No          libvendorconn.so
                        No          libbacktrace_libc++.so
0x41d4baa0  0x41f9ee24  Yes (*)     Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\libart.so
                        No          libjavacore.so
                        No          memtrack.msm8916.so
                        No          libqti-perfd-client.so
                        No          libtinyxml.so
                        No          libqservice.so
                        No          libmm-abl-oem.so
                        No          libdiag.so
                        No          libmm-abl.so
                        No          libprotecteyes.so
                        No          libgsl.so
                        No          libadreno_utils.so
                        No          libEGL_adreno.so
                        No          libGLESv1_CM_adreno.so
                        No          libGLESv2_adreno.so
0x68246388  0x68249184  Yes (*)     Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\libandroid.so
                        No          libcompiler_rt.so
                        No          libjnigraphics.so
                        No          libvorbisidec.so
                        No          libstagefright_yuv.so
                        No          libstagefright_omx.so
                        No          libstagefright_enc_common.so
                        No          libstagefright_avc_common.so
                        No          libopus.so
                        No          libdrmframework.so
                        No          libstagefright_amrnb_common.so
                        No          libstagefright.so
                        No          libmtp.so
                        No          libjhead.so
                        No          libexif.so
                        No          libmedia_jni.so
                        No          libjavacrypto.so
                        No          libsoundpool.so
                        No          libaudioeffect_jni.so
                        No          librs_jni.so
                        No          libthwsplit.so
                        No          libwebviewchromium_loader.so
                        No          eglsubAndroid.so
                        No          libsc-a3xx.so
                        No          libqdutils.so
                        No          libqdMetaData.so
                        No          libmemalloc.so
                        No          gralloc.msm8916.so
                        No          libfmodex.so
                        No          libfmodevent.so
                        No          libstagefright_http_support.so
                        No          libeffects.so
                        No          libwilhelm.so
                        No          libOpenSLES.so
0x7f9ceb40  0x8102f72c  Yes         Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\libclient.so
                        No          libwebviewchromium.so
                        No          libwebviewchromium_plat_support.so
(*): Shared library is missing debugging information.

But oat files are loaded when debugging other devices like Huawei (FRD-AL00).
Following is an excerpt of the output of show shared on such a device.

0x71867000  0x71cc76d6  Yes (*)     Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\system@[email protected]
0x721dc000  0x725657c4  Yes (*)     Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\system@[email protected]
0x725dc000  0x7262d9cc  Yes (*)     Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\system@[email protected]
0x726c3000  0x727291ea  Yes (*)     Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\system@[email protected]
0xea0de584  0xea0e5714  Yes (*)     Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\libandroid.so
0xe1b15da0  0xe1cdc3ec  Yes (*)     Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\libart-compiler.so
                        No          /system/lib/libvixl.so
0xc2b0ab40  0xc416b72c  Yes         Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\libclient.so
                        No          /data/dalvik-cache/arm/system@app@[email protected]@classes.dex

And without the libraries being loaded, gdb cannot unwind the stack correctly, the backtrace in oppo:

(gdb) bt
#0  0x40168698 in __epoll_pwait () from Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\libc.so
#1  0x4013f746 in epoll_pwait () from Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\libc.so
#2  0x4013f754 in epoll_wait () from Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\libc.so
#3  0x401cdf56 in android::Looper::pollInner(int) () from Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\libutils.so
#4  0x401ce180 in android::Looper::pollOnce(int, int*, int*, void**) ()
   from Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\libutils.so
#5  0x4009c7dc in android::NativeMessageQueue::pollOnce(_JNIEnv*, int) ()
   from Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\libandroid_runtime.so
#6  0x72403cdc in ?? ()

The last address is in the system@[email protected], which will also work correctly when the oat file is loaded.

Can anyone give some advice?

Cyclades answered 5/2, 2018 at 3:3 Comment(2)
Do you have multiple flavors in your project? Faced a similar issue where Android Studio has bug in it's iml file due to doing the gradle sync incorrectly...Whipsaw
Have you tried "add-symbol-file Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\system@[email protected]" or something like that?Telescopy
M
1

This issue is likely caused by missing debug symbols for some of the libraries on your Oppo device. Here are some things you can try:

Pull the full debug symbol files for all libraries. The missing debug symbols (indicated by "No" in your info shared output) are preventing gdb from fully unwinding the stack trace.

Install the debug versions of the system libraries on your device. The OAT files you see are loaded on the Huawei device and contain debug info that allows gdb to properly unwind the stack.

Rebuild your app with full debug info. Make sure to compile with -g to include debug symbols. This will ensure gdb has all the info it needs for your app's libraries.

Update gdb to a newer version. Sometimes newer gdb releases contain fixes for unwinding stack traces on Android.

As a last resort, you can manually load the .oat files on your Oppo device during the gdb session. This will provide the missing debug info and allow gdb to unwind properly. The command would be something like:

add-symbol-file /path/to/system@[email protected] 0x71867000

You would need to load all the relevant .oat files this way.

In summary, the issue is likely missing debug symbols that gdb needs to properly unwind the stack. Pulling full debug symbols, installing debug versions of system libraries, and ensuring your app has full debug info are the recommended approaches.

Martainn answered 11/10, 2023 at 6:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.