无需用户输入的 LLDB 重启进程

LLDB Restart process without user input

我正在尝试调试 LLDB 中的并发程序,但遇到了段错误,但不是每次执行都遇到错误。我想 运行 我的过程一遍又一遍,直到遇到段错误。到目前为止,我有以下内容:

b exit
breakpoint com add 1
Enter your debugger command(s).  Type 'DONE' to end.
> run 
> DONE

我觉得烦人的部分是,当我到达退出函数并命中断点时,当 run 命令被执行时,我从 LLDB 得到以下提示:

There is a running process, kill it and restart?: [Y/n] 

我想自动重新启动进程,而不必每次都手动输入 Y。有人知道怎么做吗?

您可以使用 kill 手动终止前一个实例 - 它不会提示 - 然后 run 命令也不会提示。

或:

(lldb) settings set auto-confirm 1

将为所有 lldb 查询提供默认(大写)答案。

或者如果您有 Xcode 6.x(或当前的 TOT svn lldb),您可以使用 lldb 驱动程序的批处理模式:

$ lldb --help
...
       -b 
       --batch 
            Tells the debugger to running the commands from -s, -S, -o & -O,
            and then quit.  However if any run command stopped due to a signal
            or crash, the debugger will return to the interactive prompt at the
            place of the crash.

例如,您可以在 shell、运行ning:

中编写脚本

lldb -b -o 运行

在一个循环中,如果 运行 以崩溃而不是正常退出结束,这将停止。在某些情况下,这可能更容易做到。