90

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@framework@boot.oat
0x721dc000  0x725657c4  Yes (*)     Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\system@framework@boot-core-libart.oat
0x725dc000  0x7262d9cc  Yes (*)     Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\system@framework@boot-conscrypt.oat
0x726c3000  0x727291ea  Yes (*)     Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\system@framework@boot-okhttp.oat
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@WebViewGoogle@WebViewGoogle.apk@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@framework@boot.oat, which will also work correctly when the oat file is loaded.

Can anyone give some advice?

applesomthing
  • 361
  • 3
  • 19
Joey.Z
  • 4,492
  • 4
  • 38
  • 63
  • 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... – ahasbini Feb 14 '18 at 11:01
  • Have you tried "add-symbol-file Z:\program\program\target\android_RelWithDebInfo\obj\local\armeabi-v7a\system@framework@boot.oat" or something like that? – Christian B Oct 08 '19 at 03:09

2 Answers2

-1

If you are encountering an error in Android Studio's Android Native Development Kit (NDK) debugging with gdb, specifically stating that "loaded shared libraries missing *.oat," it could indicate an issue with the Ahead-Of-Time (AOT) compilation of the libraries.

The *.oat files are generated by the Android Runtime (ART) when it compiles the Android application's bytecode for execution on the device. In some cases, these *.oat files may not be generated or may be missing for the shared libraries you are trying to debug.

To resolve this issue, you can try the following steps:

  1. Clean and rebuild the project: In Android Studio, go to "Build" -> "Clean Project" to clean the project and then "Build" -> "Rebuild Project" to rebuild it. This process ensures that all necessary files, including the *.oat files, are generated correctly.

  2. Check your build configuration: Ensure that the build configuration for your project includes the necessary settings to generate the *.oat files. Specifically, make sure that the "minifyEnabled" flag in your build.gradle file is set to false, as enabling code shrinking and obfuscation can interfere with the generation of *.oat files.

    For example:

    android {
        // ...
        buildTypes {
            release {
                // ...
                minifyEnabled false
                // ...
            }
        }
    }
    
  3. Check your device: If you are debugging on a physical Android device, make sure that the device is running a compatible version of Android that supports AOT compilation and *.oat files. Some custom ROMs or modified Android versions may not generate *.oat files correctly.

  4. Update your Android Studio and SDK tools: Ensure that you are using the latest version of Android Studio and have updated the Android SDK tools to the latest available version. This ensures that you have the latest bug fixes and improvements related to the NDK and debugging.

If the above steps do not resolve the issue, it may be helpful to provide more specific details about your project setup, including the Android Studio version, NDK version, and any relevant build configurations.

Nikhith sunil
  • 229
  • 3
  • 4
-2

The reason why gdb cannot unwind the stack correctly in your case is that the oat files are not loaded. Oat files are used by the Android Runtime (ART) to optimize the execution of Java bytecode. When the oat files are not loaded, gdb cannot read the debugging information that is stored in them, which makes it difficult to unwind the stack.

To resolve this issue, you need to make sure that the oat files are loaded for the shared libraries that you are debugging. You can do this by following these steps:

  1. Find the oat files for the shared libraries that you are debugging. You can find these files in the data/dalvik-cache directory of the Android device.
  2. Copy the oat files to the same directory as the shared libraries.
  3. Restart the Android device.

Once the oat files are loaded, gdb should be able to unwind the stack correctly.

In your case, the oat file for the system@framework@boot.oat shared library is not loaded. You can copy this file to the data/dalvik-cache directory of your Android device and then restart the device. This should resolve the issue and allow gdb to unwind the stack correctly.

Here are some additional things to keep in mind:

  • Make sure that the Android device is running a compatible version of Android that supports oat files.
  • Make sure that the shared libraries that you are debugging are compiled with debugging information.
  • If you are still having trouble, you can try using a different version of gdb.
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 02 '23 at 23:06