简体   繁体   English

add_qt_android_apk剥离共享库的调试符号

[英]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使用Qt 5构建APK:

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

QTAV_LIBRARIES is defined before: QTAV_LIBRARIES在以下位置定义:

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): 我使用调试模式(user.conf)构建libQtAV.so:

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检查符号时,会得到很多符号:

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: 但是,当我在libs目录中的复制库上使用nm时,什么也没得到:

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

Does add_qt_android_apk remove the debugging symbols? add_qt_android_apk是否会删除调试符号?

In the CMake module for Qt APK I found this: 在Qt APK的CMake模块中,我发现了这一点:

 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. 因此它使用指定的外部.so路径。 It is then added to qtdeploy.json in the CMake variable QT_ANDROID_APP_EXTRA_LIBS. 然后将其添加到CMake变量QT_ANDROID_APP_EXTRA_LIBS的qtdeploy.json中。 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. 在“ android-extra-libs”中:因此它实际上具有正确的条目,但是以某种方式剥离了调试符号。 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. “ libs”文件夹中的库的大小为1.1 MiBytes,而“ lib_android_arm”文件夹中的原始库的大小为1.6 MiBytes。

I'd like to see the routines using ndk-stack which prints at the moment: 我想看看使用ndk-stack的例程,它现在可以打印:

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 编辑:我使用以下CMake模块: 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 edit2:看起来androiddeployqt总是会删除库的符号: http : //code.qt.io/cgit/qt/qttools.git/tree/src/androiddeployqt/main.cpp

stripLibraries() is always called when building the application. 在构建应用程序时,始终调用stripLibraries()。

Well, androiddeployqt does ALWAYS strip the libraries to reduce their size. 好吧,androiddeployqt确实总是剥离库以减小它们的大小。 I have opened a bug report for Qt: https://bugreports.qt.io/browse/QTBUG-57771 我已经打开了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. 正如在已编辑的问题和答案中已经提到的,androiddeployqt是从.so文件中剥离debuginfo的东西。

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. 我相信这里的重点是androiddeployqt不会修改文件,它会在生成apk的过程中创建一个副本,并且只有该副本会删除调试信息。 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. 在生成的输出中,仍然有一个未修改的.so文件,其中包含调试信息,可用于调试应用程序(Qt创建者执行AFAIK),并且可用于获取符号信息-我使用它来创建可读的堆栈跟踪与breakpad crashdump文件。

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). 我认为这也是为什么QTBUG-57771被拒绝为不完整的原因:只要使用Qt Creator调试应用程序,Qt维护人员就没有充分的理由使符号在设备上可用(并演示了使用正确配置的工具链可以进行调试)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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