首页 > 解决方案 > 外部框架的 lldb 源路径

问题描述

我在 macOS 上制作了一个小型 WebRTC 播放器,它与 Google 链接libwebrtc以对我的 WebRTC 流媒体后端进行调试。但是我在将任何断点放入libwebrtc. 例如,如果我在这样的已知文件中设置断点breakpoint set --file packet_buffer.cc --line 365,则 lldb 似乎可以解析符号,因为 lldb 的输出是:

Breakpoint 1: where = WebRTC`webrtc::video_coding::PacketBuffer::FindFrames(unsigned short) + 1827 at packet_buffer.cc:365:11, address = 0x0000000101331183

但是当断点被击中时,Xcode 会显示反汇编: 在此处输入图像描述 让我烦恼的是源的相对路径——我不确定 Xcode/lldb 在哪里解决它——到加载的应用程序或模块的根目录?

如果我image lookup使用该文件中的函数执行 a ,例如image lookup -vn webrtc::video_coding::PacketBuffer::Packet::Packet,输出显示 lldb 似乎找到了符号:

4 matches found in /Users/rudolfs/Git/webrtc-checkout/src/out/Debug/WebRTC.framework/WebRTC:
        Address: WebRTC[0x0000000000f1b8d0] (WebRTC.__TEXT.__text + 15835536)
        Summary: WebRTC`webrtc::video_coding::PacketBuffer::Packet::Packet(webrtc::RtpPacketReceived const&, webrtc::RTPVideoHeader const&, long long, long long) at packet_buffer.cc:58
         Module: file = "/Users/rudolfs/Git/webrtc-checkout/src/out/Debug/WebRTC.framework/WebRTC", arch = "x86_64"
    CompileUnit: id = {0x00000000}, file = "../../modules/video_coding/packet_buffer.cc", language = "c++14"
       Function: id = {0x4d30002c9f3}, name = "webrtc::video_coding::PacketBuffer::Packet::Packet(webrtc::RtpPacketReceived const&, webrtc::RTPVideoHeader const&, long long, long long)", mangled = "_ZN6webrtc12video_coding12PacketBuffer6PacketC2ERKNS_17RtpPacketReceivedERKNS_14RTPVideoHeaderExx", range = [0x000000010132e8d0-0x000000010132ea72)
       FuncType: id = {0x4d30002c9f3}, byte-size = 0, decl = packet_buffer.h:38, compiler_type = "void (const class webrtc::RtpPacketReceived &, const struct webrtc::RTPVideoHeader &, int64_t, int64_t)"
         Blocks: id = {0x4d30002c9f3}, range = [0x10132e8d0-0x10132ea72)
      LineEntry: [0x000000010132e8d0-0x000000010132e901): ../../modules/video_coding/packet_buffer.cc:58
         Symbol: id = {0x00057dfa}, range = [0x000000010132e8d0-0x000000010132ea80), name="webrtc::video_coding::PacketBuffer::Packet::Packet(webrtc::RtpPacketReceived const&, webrtc::RTPVideoHeader const&, long long, long long)", mangled="_ZN6webrtc12video_coding12PacketBuffer6PacketC2ERKNS_17RtpPacketReceivedERKNS_14RTPVideoHeaderExx"
       Variable: id = {0x4d30002ca11}, name = "this", type = "webrtc::video_coding::PacketBuffer::Packet *", location = DW_OP_fbreg(-80), decl = 
       Variable: id = {0x4d30002ca1f}, name = "rtp_packet", type = "const webrtc::RtpPacketReceived &", location = DW_OP_fbreg(-88), decl = packet_buffer.cc:42
       Variable: id = {0x4d30002ca2e}, name = "video_header", type = "const webrtc::RTPVideoHeader &", location = DW_OP_fbreg(-96), decl = packet_buffer.cc:43
       Variable: id = {0x4d30002ca3d}, name = "ntp_time_ms", type = "int64_t", location = DW_OP_fbreg(-104), decl = packet_buffer.cc:44
       Variable: id = {0x4d30002ca4c}, name = "receive_time_ms", type = "int64_t", location = DW_OP_fbreg(-112), decl = packet_buffer.cc:45
        Address: WebRTC[0x0000000000f1ba80] (WebRTC.__TEXT.__text + 15835968)
        Summary: WebRTC`webrtc::video_coding::PacketBuffer::Packet::Packet(webrtc::RtpPacketReceived const&, webrtc::RTPVideoHeader const&, long long, long long) at packet_buffer.cc:58
         Module: file = "/Users/rudolfs/Git/webrtc-checkout/src/out/Debug/WebRTC.framework/WebRTC", arch = "x86_64"
    CompileUnit: id = {0x00000000}, file = "../../modules/video_coding/packet_buffer.cc", language = "c++14"
       Function: id = {0x4d30002cbf0}, name = "webrtc::video_coding::PacketBuffer::Packet::Packet(webrtc::RtpPacketReceived const&, webrtc::RTPVideoHeader const&, long long, long long)", mangled = "_ZN6webrtc12video_coding12PacketBuffer6PacketC1ERKNS_17RtpPacketReceivedERKNS_14RTPVideoHeaderExx", range = [0x000000010132ea80-0x000000010132eabb)
       FuncType: id = {0x4d30002cbf0}, byte-size = 0, decl = packet_buffer.h:38, compiler_type = "void (const class webrtc::RtpPacketReceived &, const struct webrtc::RTPVideoHeader &, int64_t, int64_t)"
         Blocks: id = {0x4d30002cbf0}, range = [0x10132ea80-0x10132eabb)
      LineEntry: [0x000000010132ea80-0x000000010132eaa0): ../../modules/video_coding/packet_buffer.cc:58
         Symbol: id = {0x00057dfe}, range = [0x000000010132ea80-0x000000010132eac0), name="webrtc::video_coding::PacketBuffer::Packet::Packet(webrtc::RtpPacketReceived const&, webrtc::RTPVideoHeader const&, long long, long long)", mangled="_ZN6webrtc12video_coding12PacketBuffer6PacketC1ERKNS_17RtpPacketReceivedERKNS_14RTPVideoHeaderExx"
       Variable: id = {0x4d30002cc0e}, name = "this", type = "webrtc::video_coding::PacketBuffer::Packet *", location = DW_OP_fbreg(-8), decl = 
       Variable: id = {0x4d30002cc1b}, name = "rtp_packet", type = "const webrtc::RtpPacketReceived &", location = DW_OP_fbreg(-16), decl = packet_buffer.cc:42
       Variable: id = {0x4d30002cc29}, name = "video_header", type = "const webrtc::RTPVideoHeader &", location = DW_OP_fbreg(-24), decl = packet_buffer.cc:43
       Variable: id = {0x4d30002cc37}, name = "ntp_time_ms", type = "int64_t", location = DW_OP_fbreg(-32), decl = packet_buffer.cc:44
       Variable: id = {0x4d30002cc45}, name = "receive_time_ms", type = "int64_t", location = DW_OP_fbreg(-40), decl = packet_buffer.cc:45
        Address: WebRTC[0x0000000000f23740] (WebRTC.__TEXT.__text + 15867904)
        Summary: WebRTC`webrtc::video_coding::PacketBuffer::Packet::Packet() at packet_buffer.h:37
         Module: file = "/Users/rudolfs/Git/webrtc-checkout/src/out/Debug/WebRTC.framework/WebRTC", arch = "x86_64"
    CompileUnit: id = {0x00000000}, file = "../../modules/video_coding/packet_buffer.cc", language = "c++14"
       Function: id = {0x4d300038648}, name = "webrtc::video_coding::PacketBuffer::Packet::Packet()", mangled = "_ZN6webrtc12video_coding12PacketBuffer6PacketC1Ev", range = [0x0000000101336740-0x000000010133675b)
       FuncType: id = {0x4d300038648}, byte-size = 0, decl = packet_buffer.h:37, compiler_type = "void (void)"
         Blocks: id = {0x4d300038648}, range = [0x101336740-0x10133675b)
      LineEntry: [0x0000000101336740-0x0000000101336750): ../../modules/video_coding/packet_buffer.h:37
         Symbol: id = {0x0005803a}, range = [0x0000000101336740-0x0000000101336760), name="webrtc::video_coding::PacketBuffer::Packet::Packet()", mangled="_ZN6webrtc12video_coding12PacketBuffer6PacketC1Ev"
       Variable: id = {0x4d300038664}, name = "this", type = "webrtc::video_coding::PacketBuffer::Packet *", location = DW_OP_fbreg(-8), decl = 
        Address: WebRTC[0x0000000000f23760] (WebRTC.__TEXT.__text + 15867936)
        Summary: WebRTC`webrtc::video_coding::PacketBuffer::Packet::Packet() at packet_buffer.h:37
         Module: file = "/Users/rudolfs/Git/webrtc-checkout/src/out/Debug/WebRTC.framework/WebRTC", arch = "x86_64"
    CompileUnit: id = {0x00000000}, file = "../../modules/video_coding/packet_buffer.cc", language = "c++14"
       Function: id = {0x4d300038672}, name = "webrtc::video_coding::PacketBuffer::Packet::Packet()", mangled = "_ZN6webrtc12video_coding12PacketBuffer6PacketC2Ev", range = [0x0000000101336760-0x00000001013367e3)
       FuncType: id = {0x4d300038672}, byte-size = 0, decl = packet_buffer.h:37, compiler_type = "void (void)"
         Blocks: id = {0x4d300038672}, range = [0x101336760-0x1013367e3)
      LineEntry: [0x0000000101336760-0x0000000101336770): ../../modules/video_coding/packet_buffer.h:37
         Symbol: id = {0x0005803e}, range = [0x0000000101336760-0x00000001013367f0), name="webrtc::video_coding::PacketBuffer::Packet::Packet()", mangled="_ZN6webrtc12video_coding12PacketBuffer6PacketC2Ev"
       Variable: id = {0x4d30003868e}, name = "this", type = "webrtc::video_coding::PacketBuffer::Packet *", location = DW_OP_fbreg(-8), decl =

有重复的条目似乎很奇怪(我不知道为什么),但至少 lldb 似乎知道这个名字。让我担心的另一件事是相对路径,CompileUnit但我不确定如何解决这个问题(在构建 libwebrtc 时编译标志?)。/Users/rudolfs/Git/webrtc-checkout/src/out/Debug/WebRTC.framework/如果您将用作基本名称,则相对路径不正确,因为那时它应该是../../../modules,但也许 lldb 以不同的方式对待框架并/Users/rudolfs/Git/webrtc-checkout/src/out/Debug用作基本路径?

我在这里看到了多个关于 的问题target.source-map,但我不明白这是否有帮助,我应该覆盖什么?

我还尝试在 Xcode 方案中设置一个自定义工作目录 (to /Users/rudolfs/Git/webrtc-checkout/src/out/Debug),希望相对路径不会得到解决,但这没有帮助。

标签: c++xcodedebugginglldb

解决方案


的输出image lookup -v显示了此源代码行的 4 个匹配项——此方法在四个不同的位置内联(最后两个看起来像一个 ctor)。

查看LineEntrys,lldb 试图在../../modules/video_coding/packet_buffer.cc:58or 处显示源代码../../modules/video_coding/packet_buffer.h:37

这对于 lldb 来说将很难解决。编译器创建了带有相对路径的调试信息。我认为大多数编译器会尝试为调试信息提供源文件位置的绝对路径,但是我已经有一段时间没有研究过这样的问题了。如果您现在使用相对路径名调用编译器,那么使用绝对源路径名调用编译器可能会起作用。

一个常见的问题是,源代码是在一台计算机上编译的,/build-dir但在您的调试系统上,源代码所在的位置/src-dir——有一个专门针对这种情况的 lldb 设置,target.source-map当在调试时查找源代码时,它会重新映射调试信息中的文件路径——时间。但这对你没有帮助。


推荐阅读