相当于 lldb 中的 gdb "commands" 命令

Equivilant of gdb "commands" Command in lldb

在 gdb 中,我可以告诉调试器在到达断点时总是 运行 一组命令

(gdb) b somefile.c:25
(gdb) commands
> watch -l some->expression
> continue
> end
(gdb) continue

lldb中是否有等价的command/system?当我尝试上面的方法时,我得到

(lldb) commands
error: 'commands' is not a valid command.
error: Unrecognized command 'commands'.

和互联网搜索 "gdb commands equivalent lldb" 给了我很多很棒的备忘单,但是 none 使用 commands 命令。

使用breakpoint command add [optional_breakpoint_id]

(lldb) breakpoint set -n f
Breakpoint 1: where = x`f + 12 at x.c:4, address = 0x0000000000001161
(lldb) breakpoint command add
Enter your debugger command(s).  Type 'DONE' to end.
> watch set expression &b 
> continue
> DONE
(lldb)

您还可以指定一个或多个单行命令作为 breakpoint set 命令的选项。

(lldb) breakpoint set -n f -C "watch set expression &b" -C "continue"
Breakpoint 2: where = x`f + 12 at x.c:4, address = 0x0000000000001161