【问题标题】:when remote-debugging with lldb, does the remote binary need debug symbols?使用 lldb 进行远程调试时,远程二进制文件是否需要调试符号?
【发布时间】:2021-05-11 17:51:32
【问题描述】:

使用 gdb,可以剥离远程二进制文件,本地二进制文件包含调试符号。
使用 lldb,我可以使用gdb-remote 连接到远程 gdbserver,但是我如何告诉 lldb 在哪里可以找到调试符号? lldb local-binary 似乎无法识别本地二进制文件中的调试信息。
我的步骤:

  • 在 ubuntu16.04(远程)上,运行gdbserver --attach :9988 6379,输出为
Attached; pid = 6379
Listening on port 9988
  • 在macos catalina(主机)上,运行lldb target/x86_64-unknown-linux-musl/debug/server,在提示符下运行gdb-remote,输出为
❯ lldb target/x86_64-unknown-linux-musl/debug/server
(lldb) target create "target/x86_64-unknown-linux-musl/debug/server"
Current executable set to '/Users/sifangyuan/Source/hy/sca/target/x86_64-unknown-linux-musl/debug/server' (x86_64).
(lldb) gdb-remote remote-ubuntu-ip:9988
Process 6379 stopped
* thread #1, stop reason = signal SIGTRAP
    frame #0: 0x000000000208b705 server`epoll_pwait + 24
server`epoll_pwait:
->  0x208b705 <+24>: movl   %eax, %ecx
    0x208b707 <+26>: cmpl   $-0x26, %eax
    0x208b70a <+29>: jne    0x208b71a                 ; <+45>
    0x208b70c <+31>: testq  %r8, %r8
Target 0: (server) stopped.
(lldb) source info
error: No debug info for the selected frame.
(lldb) source list
(lldb) c
Process 6379 resuming
(lldb) process detach
Process 6379 detached

您可以看到 lldb 显示汇编代码,没有调试信息,但我可以继续或分离。可执行文件确实有调试信息:

❯ file target/x86_64-unknown-linux-musl/debug/server
target/x86_64-unknown-linux-musl/debug/server: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, with debug_info, not stripped

【问题讨论】:

  • 你能展示一下你是怎么做的吗?如果您首先创建目标(通过在命令行上指定文件或使用target create,然后使用gdb-remote 连接到远程,lldb 应该使用您指定的目标。如果它有调试信息或有指向可以在本地解析的单独调试信息的指针,lldb 应该使用它。
  • 在运行gdb-remote命令之前,可以运行source list -n epoll_pwait -s server命令吗?这是否显示源信息?如果没有,那么由于某种原因,这个函数最终没有调试信息。如果是,则在gdb-remote 命令之前和之后运行image list server。该列表中的第二列是二进制文件的 UUID。附加之前和之后它们是否相同?

标签: remote-debugging lldb gdbserver


【解决方案1】:

映射对我有用:

settings append target.source-map /remote-src /local-src

...由于某种原因settings set 没有。

【讨论】:

    猜你喜欢
    • 2016-02-06
    • 2016-07-26
    • 2010-10-13
    • 2011-06-12
    • 2011-03-06
    • 2014-01-22
    • 1970-01-01
    • 2014-02-09
    • 2011-05-03
    相关资源
    最近更新 更多