lldb source paths for an external framework

0

I've made a small WebRTC player on macOS that is linked against Googles libwebrtc to torubleshoot my WebRTC streaming backend. But I am having issues putting any breakpoints in libwebrtc. For example, if I set a breakpoint in a known file like this breakpoint set --file packet_buffer.cc --line 365, lldb seems to resolve the symbol since the output from lldb is:

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

But when the breakpoint is hit, Xcode shows disassembly: enter image description here The thing that troubles me is the relative path of the source - I am unsure to where Xcode/lldb resolves that - to the root of the loaded application or the module?

If I do a image lookup with a function from that file, e.g. image lookup -vn webrtc::video_coding::PacketBuffer::Packet::Packet, the output shows that lldb seems to find the symbol:

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 =

It seems weird that there are duplicate entries (and I have no idea why), but at least lldb seems to know the name. The other thing that worries me is the relative path in CompileUnit but I am not sure how to fix that (compile flags while building libwebrtc?). The relative path is not correct if you take the /Users/rudolfs/Git/webrtc-checkout/src/out/Debug/WebRTC.framework/ as a base name, since then it should be ../../../modules, but maybe lldb treats frameworks differently and uses /Users/rudolfs/Git/webrtc-checkout/src/out/Debug as a base path?

I've seen multiple questions here regarding target.source-map, but I don't understand if this would help here and what should I override?

I also tried setting a custom working directory in the Xcode scheme (to /Users/rudolfs/Git/webrtc-checkout/src/out/Debug) in hope that the relative paths would not get resolved but that did not help.

c++
xcode
debugging
lldb
asked on Stack Overflow Dec 19, 2019 by Rudolfs Bundulis • edited Dec 19, 2019 by Rudolfs Bundulis

1 Answer

0

The output of image lookup -v is showing 4 matches for this source line -- this method was inlined in four different places (the last two looking like a ctor).

Looking at the LineEntrys, lldb is trying to show the source at ../../modules/video_coding/packet_buffer.cc:58 or ../../modules/video_coding/packet_buffer.h:37.

This is going to be tricky for lldb to resolve. The compiler has created debug information with relative paths. I thought most compilers would try to come up with an absolute path to the location of the source files for the debug information, but it's been a while since I've looked into a problem like this. It may be that invoking your compiler with an absolute source pathname may work, if you're invoking it with a relative one right now.

A common problem is when the source was compiled on one computer in /build-dir but on your debug system the source is in /src-dir -- there's an lldb setting specifically for this case, target.source-map which remaps the file paths in the debug information when looking for the source at debug-time. But that's not going to help you here.

answered on Stack Overflow Dec 30, 2019 by Jason Molenda

User contributions licensed under CC BY-SA 3.0