简体   繁体   中英

add_qt_android_apk strips debug symbols of shared library

I use add_qt_android_apk to build an APK using Qt 5:

add_qt_android_apk(my_app_apk gustavsfairyland NAME "@string/ApplicationName"
        DEPENDS
        ${QTAV_LIBRARIES}
    )

QTAV_LIBRARIES is defined before:

set(QTAV_LIBRARIES
        "${QTAV_FFMPEG_LIB_DIR}/libavcodec.so"
        "${QTAV_FFMPEG_LIB_DIR}/libavfilter.so"
        "${QTAV_FFMPEG_LIB_DIR}/libavformat.so"
        "${QTAV_FFMPEG_LIB_DIR}/libavresample.so"
        "${QTAV_FFMPEG_LIB_DIR}/libavutil.so"
        "${QTAV_FFMPEG_LIB_DIR}/libswresample.so"
        "${QTAV_FFMPEG_LIB_DIR}/libswscale.so"
        "${CMAKE_BINARY_DIR}/buildqtav/${QTAV_LIB_DIR}/libQtAV.so"
        "${CMAKE_BINARY_DIR}/buildqtav/${QTAV_LIB_DIR}/libQtAVWidgets.so"
    )

I build libQtAV.so using the debug mode (user.conf):

CONFIG += no_config_tests
CONFIG += config_avutil config_avformat config_avcodec config_swscale config_swresample

CONFIG -= release
CONFIG += debug

When I use nm to check for symbols I get many symbols:

nm ../buildqtav/lib_android_arm/libQtAV.so
00062884 t $a
00061d88 t $a
0005f9d0 t $a
...

But when I use nm on the copied library in the libs directory I get nothing:

bash-4.3$ nm armeabi-v7a/libQtAV.so 
nm: armeabi-v7a/libQtAV.so: no symbols

Does add_qt_android_apk remove the debugging symbols?

In the CMake module for Qt APK I found this:

 if(EXTRA_LIBS)
        set(EXTRA_LIBS "${EXTRA_LIBS},${LIB}")
    else()
        set(EXTRA_LIBS "${LIB}")
    endif()
    endforeach()
    set(QT_ANDROID_APP_EXTRA_LIBS "\"android-extra-libs\": \"${EXTRA_LIBS}\",")

so it uses the specified external .so path. It is then added to qtdeploy.json in the CMake variable QT_ANDROID_APP_EXTRA_LIBS. Which has the entry

buildandroidarmeabi-v7a/buildqtav/lib_android_arm/libQtAV.so

in "android-extra-libs": So it actually has the correct entry but somehow strips the debug symbols. The library in the "libs" folder has a size of 1.1 MiBytes while the original library in "lib_android_arm" has a size of 1.6 MiBytes.

I'd like to see the routines using ndk-stack which prints at the moment:

Stack frame #05 pc 000b714f  /data/app/org.qtproject.gustavsfairyland-1/lib/arm/libQtAV.so: Routine ??

edit: I use the following CMake module: https://github.com/LaurentGomila/qt-android-cmake

edit2: It looks like androiddeployqt does always strip symbols of the libraries: http://code.qt.io/cgit/qt/qttools.git/tree/src/androiddeployqt/main.cpp

stripLibraries() is always called when building the application.

Well, androiddeployqt does ALWAYS strip the libraries to reduce their size. I have opened a bug report for Qt: https://bugreports.qt.io/browse/QTBUG-57771

As already mentioned in the edited question and in the answer, androiddeployqt is what strips the debuginfo from the .so file.

I belive the important point here is that androiddeployqt does not modify the file, it creates a copy in the process of generating the apk, and only this copy has the debug infos stripped. In the build output there is still the unmodified .so file which contains the debug infos and which can be used to debug the application (Qt creator does that AFAIK) and which can be used to grab symbol information - I use this for creating readable stacktraces with breakpad crashdump files.

I believe that's also the reason why QTBUG-57771 was rejected as incomplete: The Qt maintainers see no good reason to have the symbols available on the device, as long as debugging the application with Qt creator works with the current build process (and demonstrates that debugging is possible with a properly configured toolchain).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM