如何检查LLDB是否从共享库加载了调试符号?

时间:2016-10-17 12:18:50

标签: c++ macos debugging lldb debug-symbols

在Linux上我使用

(gdb) i shared

在gdb和gdb中打印一个带有星号*的库列表(如果没有加载调试符号或没有加载调试符号),例如:

0x0000000100c18660  0x0000000100c489a0  Yes (*)     /Users/anon/work/software/webrtc-audio-processing-0.1/build_darwin/../bin/darwin/lib/libwebrtc_audio_processing.0.dylib
0x0000000100c57ca0  0x0000000100c76978  Yes         /Users/anon/work/software/speex/speex/speex-1.2rc2/build_darwin/../bin/darwin/lib/libspeex.1.dylib

我发现在LLDB中我应该使用

(lldb) image list

做同样的事情。但是我得到了一个库列表,它们对于是否为lib加载调试符号没有任何说明,例如:

[181] 19269C1D-EB29-384A-83F3-7DDDEB7D9DAD 0x00007fff8d2d3000 /System/Library/PrivateFrameworks/CoreWiFi.framework/Versions/A/CoreWiFi
[182] 8D7BA9BA-EB36-307A-9119-0B3D9732C953 0x00007fff879ee000 /System/Library/Frameworks/CoreBluetooth.framework/Versions/A/CoreBluetooth
[183] 6F03761D-7C3A-3C80-8031-AA1C1AD7C706 0x00007fff92e52000 /System/Library/PrivateFrameworks/DebugSymbols.framework/Versions/A/DebugSymbols

那么如何检查LLDB是否加载了调试符号?

更新:我刚刚决定发布(lldb) image lookup -vn <function>(感谢吉姆)的输出,让其他人知道它的样子:

image lookup -vn Herqq::Upnp::HSsdp::init
2 matches found in libHUpnp.2.dylib:
        Address: libHUpnp.2.dylib[0x00000000000283f0] (libHUpnp.2.dylib.__TEXT.__text + 150384)
        Summary: libHUpnp.2.dylib`Herqq::Upnp::HSsdp::init() at hssdp.cpp:804
         Module: file = "libHUpnp.2.dylib", arch = "x86_64"
    CompileUnit: id = {0x00000000}, file = "/Users/blade/work/software/HUPnP/build-herqq-Desktop_Qt_5_5_0_clang_64bit-Debug/hupnp/../../herqq/hupnp/src/ssdp/hssdp.cpp", language = "c89"
       Function: id = {0xa0002401f}, name = "init", range = [0x00000000000283f0-0x0000000000028511)
       FuncType: id = {0xa0002401f}, decl = hssdp.h:304, clang_type = "_Bool (void)"
         Blocks: id = {0xa0002401f}, range = [0x000283f0-0x00028511)
      LineEntry: [0x00000000000283f0-0x00000000000283ff): /Users/blade/work/software/HUPnP/build-herqq-Desktop_Qt_5_5_0_clang_64bit-Debug/hupnp/../../herqq/hupnp/src/ssdp/hssdp.cpp:804
         Symbol: id = {0x00000c9b}, range = [0x00000000000283f0-0x0000000000028520), name="Herqq::Upnp::HSsdp::init()", mangled="_ZN5Herqq4Upnp5HSsdp4initEv"
       Variable: id = {0xa0002403a}, name = "this", type= "Herqq::Upnp::HSsdp *", location = DW_OP_fbreg(-16), decl =
       Variable: id = {0xa00024047}, name = "herqqLog__", type= "HLogger", location = DW_OP_fbreg(-32), decl = hssdp.cpp:805
       Variable: id = {0xa00024056}, name = "ha", type= "QHostAddress", location = DW_OP_fbreg(-56), decl = hssdp.cpp:812
        Address: libHUpnp.2.dylib[0x0000000000028550] (libHUpnp.2.dylib.__TEXT.__text + 150736)
        Summary: libHUpnp.2.dylib`Herqq::Upnp::HSsdp::init(QHostAddress const&) at hssdp.cpp:817
         Module: file = "libHUpnp.2.dylib", arch = "x86_64"
    CompileUnit: id = {0x00000000}, file = "/Users/blade/work/software/HUPnP/build-herqq-Desktop_Qt_5_5_0_clang_64bit-Debug/hupnp/../../herqq/hupnp/src/ssdp/hssdp.cpp", language = "ISO C++:1998"
       Function: id = {0xa0002408f}, name = "init", range = [0x0000000000028550-0x000000000002862d)
       FuncType: id = {0xa0002408f}, decl = hssdp.h:321, clang_type = "_Bool (const class QHostAddress &)"
         Blocks: id = {0xa0002408f}, range = [0x00028550-0x0002862d)
      LineEntry: [0x0000000000028550-0x0000000000028564): /Users/blade/work/software/HUPnP/build-herqq-Desktop_Qt_5_5_0_clang_64bit-Debug/hupnp/../../herqq/hupnp/src/ssdp/hssdp.cpp:817
         Symbol: id = {0x00000ca3}, range = [0x0000000000028550-0x0000000000028630), name="Herqq::Upnp::HSsdp::init(QHostAddress const&)", mangled="_ZN5Herqq4Upnp5HSsdp4initERK12QHostAddress"
       Variable: id = {0xa000240aa}, name = "this", type= "Herqq::Upnp::HSsdp *", location = DW_OP_fbreg(-16), decl =
       Variable: id = {0xa000240b7}, name = "unicastAddress", type= "const QHostAddress &", location = DW_OP_fbreg(-24), decl = hssdp.cpp:816
       Variable: id = {0xa000240c6}, name = "herqqLog__", type= "HLogger", location = DW_OP_fbreg(-40), decl = hssdp.cpp:818

1 个答案:

答案 0 :(得分:1)

如果您的二进制文件是使用dSYM构建的,则dSYM将显示在图像列表中二进制文件列表之后的行上。

如果二进制文件正在使用&#34;将调试信息保留在.o文件中,则没有一种简单的方法可以做到这一点。样式是Xcode中Debug配置的默认样式。我提交了一个错误,以便更容易看到。

一种相当简单的方法是:

(lldb) image lookup -vn <SomeFunctionNameThatShouldHaveDebugInfo>

如果该命令的输出包含CompileUnit,则包含该函数的.o文件具有调试信息,否则不包含。

相关问题