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這兩個命令記在心中。這些是查詢命令信息的基礎,在調試只路上你會不停的用到他們。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章