gpt4 book ai didi

c++ - LLDB 中的重复命令

转载 作者:行者123 更新时间:2023-12-03 07:15:26 25 4
gpt4 key购买 nike

如何在 LLDB 中重复运行命令以调试 C++ 代码?
例如,当我在循环内设置断点并希望在停止之前继续迭代 10 次时,我当前正在输入 continue十次手动执行此操作。有没有更好的办法?
例如,假设我有这个代码块:

int i = 0;
while (true) {
// Increment i
i++;
}
如果我在注释行设置断点,我可以继续使用命令 continue进行一次循环迭代并返回该行。但是,如果我想跳过 10 次迭代(即使用命令 continue 10 次),我该怎么做?

最佳答案

lldb 倾向于使用 gdb 使用命令参数的选项。这使得有一堆不同的方法来调节特定命令变得更容易,而不必为每个命令提出特别的迷你语法。
无论如何,所以在 lldb 你会这样做:

(lldb) c -i 10
您可以在帮助中看到这一点:
(lldb) help continue
Continue execution of all threads in the current process.

Syntax: continue <cmd-options>

Command Options Usage:
continue [-i <unsigned-integer>]

-i <unsigned-integer> ( --ignore-count <unsigned-integer> )
Ignore <N> crossings of the breakpoint (if it exists) for the currently selected thread.

'continue' is an abbreviation for 'process continue'
另请注意,您可以通过在刚刚命中的断点中设置忽略计数来执行相同的操作: break modify -i 10 <BKPTNO> .

关于c++ - LLDB 中的重复命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64639184/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com