代码之家  ›  专栏  ›  技术社区  ›  Zohar81

LLDB调试器步骤解析

  •  0
  • Zohar81  · 技术社区  · 9 年前

    我已经从命令行启动了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时得到的那样)?

    1 回复  |  直到 9 年前
        1
  •  2
  •   Paul R    9 年前

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

    在gcc中, -克 在生成的代码中启用调试符号-您通常希望这适用于任何调试或分析构建(有时甚至发布构建)。