Advanced+Apple+Debugging(2)

LLDB官方文档

帮助命令

打开一个终端窗口键入lldb。LLDB会迅速出来在那里简单的键入。help命令:

(lldb) help
这将会显示出所有可以用的命令,包括从~/.lldbinit加载出来的自定义的命令,但是可能晚一点显示出来
page32image6336.png
这里有相当多的LLDB命令可以用。
然而,许多命令包含着几个子命令,这些子命令又有自己相关的文档。
以breakpoint命令为例。键入通过下面的指令来查看breakpoint命令的文档:

(lldb) help breakpoint
你会看到下面这些输出:

Commands for operating on breakpoints (see 'help b' for shorthand.)
Syntax: breakpoint <subcommand> [<command-options>]
The following subcommands are supported:
clear -- Delete or disable breakpoints matching the specified
source file and line.
command -- Commands for adding, removing and listing LLDB commands
executed when a breakpoint is hit.
delete -- Delete the specified breakpoint(s). If no breakpoints
are specified, delete them all.
disable -- Disable the specified breakpoint(s) without deleting
them. If none are specified, disable all breakpoints.
enable -- Enable the specified disabled breakpoint(s). If no
breakpoints are specified, enable all of them.
list -- List some or all breakpoints at configurable levels of
detail.
modify -- Modify the options on a breakpoint or set of breakpoints
in the executable. If no breakpoint is specified,
acts on the last created breakpoint. With the exception
of -e, -d and -i, passing an empty argument clears
the modification.
name -- Commands to manage name tags for breakpoints
set -- Sets a breakpoint or set of breakpoints in the
executable.
For more help on any particular subcommand, type 'help <command>
<subcommand>'.
在这里你可以看到几个支持的子命令。要查看breakpoint name命令的文档,可以输入下面的内容:

(lldb) help breakpoint name
你将看到下面的输出:

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>'.
如果此刻你不理解breakpoint name,别担心你将很快就会理解breakpoints和后面所有的命令。从现在开始,help是你要记住的最重要的命令。

中肯命令

有时你并不知道你要搜索的命令的名字,但是你知道它包含的关键词或者短语可以给你指出正确的方向。apropos就是为你做这件事的。这有点像在网络上用搜索引擎找东西。
apropos是不区分大小写的,并且将返回LLDB文档中匹配的任何结果例如搜索任何与斯威夫特有关内容:

(lldb) apropos swift
你将会看到下面这些输出:

The following built-in commands may relate to 'swift':
breakpoint set -- Sets a breakpoint or set of breakpoints in
the executable.
expression -- Evaluate an expression (ObjC++ or Swift) in
the current program context, using user defined variables and variables
currently in scope.
language swift -- A set of commands for operating on the Swift
Language Runtime.
language swift demangle -- Demangle a Swift mangled name
language swift 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.
这将选取出所有与单词Swift相关的内容。首先是相关的命令,然后是可以控制LLDB操作的LLDB设置。
你也可以使用apropos去搜索一个特定的句子。例如,如果你要搜索与reference counting相关的内容,你可以使用下面的命令:

(lldb) apropos "reference count"
The following built-in commands may relate to 'reference count':
language swift refcount -- Inspect the reference count data for a Swift
object
target modules list -- List current executable and dependent shared
library images.
注意爱用双引号包裹着单词“reference count”,. apropos只会接收一个搜索的参数,因此双引号可以让它们作为一个单独的参数是必要的。
感觉不够整洁?apropos是一个用来查询的方便的工具。它不像现代互联网搜索引擎那么复杂,然而在平常的练习中你可以找到你想要的。
我们为什么要学这些?
我们很容易就会忘记我们将要学习的大量的LLDB命令,但是只要把help和apropos这两个命令记在心中。这些是查询命令信息的基础,在调试只路上你会不停的用到他们。

猜你喜欢

转载自blog.51cto.com/haidragon/2126779