与 `-s` 选项相比,LLDB 中 `image lookup` 的 `-n` 选项如何操作?

How does the `-n` option to `image lookup` in LLDB operate compared to the `-s` option?

我知道 -s 选项在符号 table (image dump symtab) 中搜索匹配 <symbol>.

的符号

但是,我不明白 -n 选项是如何运作的。它 returns 与 -s 不同的结果,如果它不在符号 table 中搜索 functions/symbols,它会在哪里寻找 <function-or-symbol>?

help image lookup:

-s <symbol> ( --symbol <symbol> )
            Lookup a symbol by name in the symbol tables in one or more target modules.

-n <function-or-symbol> ( --name <function-or-symbol> )
            Lookup a function or symbol by name in one or more target modules.

在 lldb 中,"symbol table" 表示链接器和加载器用于从名称到可调用对象的 table。所以 -s 不会查询调试信息。

lldb 的约定是使用 "function" 而不是 "symbol" 来表示来自调试信息的可调用对象。所以 -n 将查询 linker/loader 的符号 table 信息和调试信息以匹配给定的名称。

官方GDB to LLDB command map reference是这样说的:

This one finds debug symbols:
(lldb) image lookup -r -n <FUNC_REGEX>

This one finds non-debug symbols:
(lldb) image lookup -r -s <FUNC_REGEX>

Provide a list of binaries as arguments to limit the search. 

因此,image lookup -n 仅搜索调试符号,而 image lookup -s 搜索非调试符号。