【问题标题】:LLDB debugger step resolutionLLDB 调试器步骤解析
【发布时间】:2015-11-12 11:03:43
【问题描述】:

我已经从命令行启动了 LLDB 调试器,目标独立 C 可执行文件,并将main() 方法的开始设置为断点。

在调试器中运行应用程序后,我看到它停止在装配线上,而不是 C 代码行。另外,我每走一步,一步解析就是一条流水线。

这是 lldb 的输出:

(lldb) target create "./a.out"
Current executable set to './a.out' (x86_64).
(lldb) breakpoint set --name main
Breakpoint 1: where = a.out`main, address = 0x0000000100000e80
(lldb) run
Process 2023 launched: './a.out' (x86_64)
Process 2023 stopped
* thread #1: tid = 0xfca5, 0x0000000100000e80 a.out`main, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100000e80 a.out`main a.out`main:
->  0x100000e80 <+0>: pushq  %rbp
    0x100000e81 <+1>: movq   %rsp, %rbp
    0x100000e84 <+4>: pushq  %r15
    0x100000e86 <+6>: pushq  %r14
(lldb) n
Process 2023 stopped
* thread #1: tid = 0xfca5, 0x0000000100000e81 a.out`main + 1, queue = 'com.apple.main-thread', stop reason = instruction step over
frame #0: 0x0000000100000e81 a.out`main + 1
a.out`main:
->  0x100000e81 <+1>: movq   %rsp, %rbp
    0x100000e84 <+4>: pushq  %r15
    0x100000e86 <+6>: pushq  %r14
    0x100000e88 <+8>: pushq  %r12
(lldb) n

有什么方法可以更改单个 C 源代码行而不是装配线的步长分辨率(就像我从 Xcode 运行 lldb 时得到的那样)?

【问题讨论】:

  • 你是用-g或类似的方式编译的吗?
  • 用 -g 标志编译代码似乎已经解决了这个问题。这个选项在 clang 编译器中代表什么?
  • 在 gcc 中,clang 等人 -g 在生成的代码中启用调试符号 - 您通常希望在任何调试或分析构建(有时甚至是发布构建)中使用它。
  • 我现在已将其转换为答案,供任何未来访问该问题的人使用...
  • 太好了,我刚刚在 gcc/clang 手册中注意到了这一点。但是,我确实尝试使用应该提供更多调试信息的 -O 标志进行编译,也许你知道 -O 到 -g 之间有什么区别

标签: c xcode macos debugging lldb


【解决方案1】:

您需要在启用调试符号的情况下进行编译(例如-g),以便 gdb 或 lldb 能够进入源代码级别。

在 gcc、clang 中,et al -g 在生成的代码中启用调试符号 - 您通常希望在任何调试或分析构建(有时甚至发布构建)中使用它。

【讨论】:

    猜你喜欢
    • 2017-12-30
    • 1970-01-01
    • 2016-01-29
    • 2014-07-28
    • 1970-01-01
    • 2018-08-30
    • 1970-01-01
    • 2018-01-13
    • 2014-12-10
    相关资源
    最近更新 更多