开始学习LLDB命令(第二章:Help & Apropos)

跟其他的开发工具一样,LLDB也有大量健全的文档.知道如何通过一些比较模糊的命令标志在这些文档中导航, 是掌握LLDB必不可少的技能.
LLDB官方文档

help 命令

打开一个终端窗口键入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就是为你做这件事的. 这有点像在web上用搜索引擎找东西.
apropos是不区分大小写的,并且将返回LLDB文档中匹配的任何结果.例如搜索任何与Swift有关内容:

(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命令, 但是只要把helpapropos这两个命令记在心中.这些是查询命令信息的基础, 在调试只路上你会不停的用到他们.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,736评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,167评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,442评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,902评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,302评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,573评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,847评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,562评论 0 197
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,260评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,531评论 2 245
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,021评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,367评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,016评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,068评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,827评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,610评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,514评论 2 269

推荐阅读更多精彩内容

  • LLDB的Xcode默认的调试器,它与LLVM编译器一起,带给我们更丰富的流程控制和数据检测的调试功能。平时用Xc...
    CoderSC阅读 1,304评论 0 2
  • [转]浅谈LLDB调试器文章来源于:http://www.cocoachina.com/ios/20150126/...
    loveobjc阅读 2,410评论 2 6
  • 本文是Advanced Apple Debugging的学习笔记.首先将Xcode升级到8.3版本.可以通过下载地...
    填坑侠阅读 2,906评论 13 4
  • 随着Xcode 5的发布,LLDB调试器已经取代了GDB,成为了Xcode工程中默认的调试器。它与LLVM编译器一...
    随风飘荡的小逗逼阅读 1,344评论 0 0
  • 转载 与调试器共舞 - LLDB 的华尔兹: https://objccn.io/issue-19-2/ 推荐:i...
    F麦子阅读 3,281评论 0 10