等效于lldb中的gdb“commands”命令

问题描述 投票:0回答:1

在gdb中,我可以告诉调试器在遇到断点时始终运行一组命令

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

lldb中是否有等效的命令/系统?当我尝试上述内容时,我最终会这样做

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

和互联网搜索“gdb命令等效lldb”给了我很多很好的备忘单,但没有使用commands命令。

macos gdb lldb
1个回答
1
投票

使用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
© www.soinside.com 2019 - 2024. All rights reserved.