以下内容整理自:<ADVANCED APPLE DEBUGGING & REVERSE ENGINEERING> 如有出入望指正
此文主要是讲怎么使用帮助文档,以及在记不清命令全称的时候进行模糊搜索
The “help” command
在终端输入 lldb,进入 LLDB debugger 模式,键入:
(lldb) help
将会输出所有可用命令,包括在 ~/.lldbinit 自定义的命令
这个help和man命令功能相似,查看 breakpoint 文档
(lldb) help breakpoint
如果你想查看 breakpoint 中 name 的用法
(lldb) help breakpoint name
Commands to manage name tags for breakpoints
Syntax: breakpoint name <subcommand> [<command-options>]
The following subcommands are supported:
add -- Add a name to the breakpoints provided.
delete -- Delete a name from the breakpoints provided.
list -- List either the names for a breakpoint or the breakpoints for a
given name.
For more help on any particular subcommand, type 'help <command> <subcommand>'.
其他命令也可以使用这种方法进行查询
The “apropos” command
如果你只记得命令的一部分,可以使用 apropos 命令进行搜索, apropos 搜索的时候不区分大小写 假如你想搜索 swift 相关的东西
(lldb) apropos swift
The following commands may relate to 'swift':
swift -- A set of commands for operating on the Swift Language Runtime.
demangle -- Demangle a Swift mangled name
refcount -- Inspect the reference count data for a Swift object
The following settings variables may relate to 'swift':
target.swift-framework-search-paths -- List of directories to be searched
when locating frameworks for Swift.
target.swift-module-search-paths -- List of directories to be searched when
locating modules for Swift.
target.use-all-compiler-flags -- Try to use compiler flags for all modules
when setting up the Swift expression parser,
not just the main executable.
apropos 还可以搜句子/词组,例如:你想搜和引用计数相关的东西
(lldb) apropos "reference count"
The following commands may relate to 'reference count':
refcount -- Inspect the reference count data for a Swift object
提示
Notice the quotes surrounding the words "reference count". apropos will only accept one argument to search for, so the quotes are necessary to treat the input as a single argument.
本节简要说了 help 和 apropos 两个命令,因为众多命令不一定可以全部记住,这时候这两个命令就用处大了。