Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I know that the -s option searches the symbol table (image dump symtab) for symbols matching <symbol>.

However, I don't understand how the -n option operates. It returns different results from -s, and if it doesn't search the symbol table for functions/symbols, where does it look for <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.
like image 701
Shuzheng Avatar asked Mar 03 '23 11:03

Shuzheng


2 Answers

The official GDB to LLDB command map reference says that:

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. 

So, image lookup -n only searches debug symbols, while image lookup -s searches non-debug symbols.

like image 158
Nicolas Lykke Iversen Avatar answered Mar 06 '23 22:03

Nicolas Lykke Iversen


In lldb, the "symbol table" means the table that the linker and loader use to go from names to callable objects. So -s will NOT consult debug information.

lldb's convention is to use "function" as opposed to "symbol" to mean the representation of a callable object coming from the debug information. So -n will consult both the linker/loader's symbol table information and debug info to match the given name.

like image 36
Jim Ingham Avatar answered Mar 06 '23 21:03

Jim Ingham