美文网首页
第二章:Help 和 Apropos

第二章:Help 和 Apropos

作者: KarenLoo | 来源:发表于2018-01-24 20:14 被阅读0次

就像其他大型开发者工具一样,LLDB 提供了大量的文档。 知道如何浏览这个文档 —— 包括一些比较晦涩的命令标志 —— 对于掌握 LLDB 是非常重要的。

“help”命令

打开终端窗口并输入 lldb。 LLDB 提示符将出现。 然后只需输入 help 命令:

(lldb) help

这将显示出所有可用的命令,包括从 ~/.lldbinit 中加载的自定义命令 —— 稍后会更多。

Help & Apropos-1.png

LLDB 可以使用相当多的命令。

但是,许多命令有大量子命令,而子命令又有子命令,这些命令也有自己的相关文档。 我告诉过你这是一个庞大的文件量!

以 breakpoint 命令为例。 通过输入以下内容运行 breakpoint 文档:

(lldb) help breakpoint

你会看到下面的输出:

 Commands for operating on breakpoints (see 'help b' for shorthand.)

Syntax: breakpoint

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
  read    -- Read and set the breakpoints previously saved to a file
             with "breakpoint write".
  set     -- Sets a breakpoint or set of breakpoints in the executable.
  write   -- Write the breakpoints listed to a file that can be read in
             with "breakpoint read".  If given no arguments, writes all
             breakpoints.

For more help on any particular subcommand, type 'help <command> <subcommand>'.

你可以在这里看到几个支持的子命令。 通过输入以下内容查找 breakpoint name 的文档:

(lldb) help breakpoint name

你会看到下面的输出:

   Commands to manage name tags for breakpoints

Syntax: 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,不要担心 —— 你很快就会熟悉断点和所有其子命令。 现在,help 命令是你要记住的最重要的命令。

“apropos”命令

有时你不知道你正在搜索的命令的名字,但你知道某个单词或短语可能会指引你正确的方向。 apropos 命令可以为你做这个,这有点像使用搜索引擎在网上找东西。

apropos 将根据 LLDB 文档对任何单词或字符串进行不区分大小写的搜索,并返回匹配的结果。 例如,尝试搜索有关 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.

这显示了与 Swift 这个单词有关的所有内容:首先是命令,然后是 LLDB 设置,这些设置可以用来控制 LLDB 的运行方式。

你也可以使用 apropos 来搜索特定的句子。 例如,如果你正在寻找引用计数的相关内容,则可以尝试以下操作:

(lldb) apropos "reference count"
The following commands may relate to 'reference count':
  refcount -- Inspect the reference count data for a Swift object

注意包裹“reference count”的引号。 apropos 只接受一个参数来搜索,所以引号是必要的,把输入作为一个单一的参数。

灵活吧?apropos 是一个方便查询的工具。 它不像现代的互联网搜索引擎那么复杂,不过,你尝试几次,通常能找到你要找的内容。

接下来?

很容易忘记即将到来的大量 LLDB 命令的猛攻,但尽量把 help 和 apropos 这两个命令记在心里。 它们是查询命令信息的基础,而且在你掌握调试的时候,你会一直使用它们。

相关文章

  • Help & Apropos

    LLDB是新一代高性能调试器,是Xcode的默认调试器,并且支持调试C/C++程序。LLDB命令繁多,下面开始接少...

  • 第二章:Help 和 Apropos

    就像其他大型开发者工具一样,LLDB 提供了大量的文档。 知道如何浏览这个文档 —— 包括一些比较晦涩的命令标志 ...

  • lldb

    (lldb) help Debugger commands: apropos -- List debug...

  • 第三章:使用 LLDB 连接

    既然你已经了解了两个最重要的命令,help 和 apropos,现在是时候研究 LLDB 如何连接进程。 你将学习...

  • 开始学习LLDB命令(第三章:使用LLDB附加)

    现在你已经学到了两个最基本的命令apropos和help.是时候研究一下LLDB是如何把自己附加到进程上的.你会学...

  • LLDB常用命令

    apropos 列出与单词或主题相关的调试器命令 eg: apropos br breakpoint 设置断点 ...

  • Xcode GDB调试命令列表

    Debugger commands: apropos-- List debugger commands relat...

  • 调试器命令

    Debugger commands: 调试器命令: apropos -- List debugger...

  • Xcode调试之LLDB(2)

    断点和调试器交互 help命令 help 列出所有命令 help 列出某个命令更多细节,例如help prin p...

  • XCode调试LLDB

    XCode版本:9.2 (9C40b) apropos-- List debugger commands rela...

网友评论

      本文标题:第二章:Help 和 Apropos

      本文链接:https://www.haomeiwen.com/subject/lzfpaxtx.html