[lldb-dev] target modules lookup
Greg Clayton
gclayton at apple.com
Wed Jul 10 11:14:01 PDT 2013
On Jul 10, 2013, at 10:56 AM, Michael Sartain <mikesart at gmail.com> wrote:
> Is this supposed to work?
>
> (lldb) target modules lookup -Av -s argc
>
> It does nothing. Looking up the address of argc and using it also does nothing.
"-s" or "--symbol" only looks up symbols in the symbol table, not local variables. If you do a:
(lldb) target modules dump symtab a.out
...
You will see all symbols for your executable. That is what "--symbol" is looking for.
>
> (lldb) p &argc
> (int *) $3 = 0x00007fff506c9458
This is the local variable address on the stack.
> (lldb) target modules lookup -Av -a 0x00007fff506c9458
"-a" or "--address" doesn't lookup things on the stack currently. We could modify "target modules lookup" it to find the stack frame that contains the address if the lookup fails, and then associated it with any local variables. But it doesn't do that right now.
>
> It does work with the function "main":
main is a function and you are lookup up the debug info for it since you specified verbose info and main does have a symbol.
>
> (lldb) target modules lookup -Av -F main
> 1 match found in /home/mikesart/data/src/blah/build/blah:
> Address: blah[0x0000000000409970] (blah..text + 368)
> Summary: blah`main at blah.cpp:160
> Module: file = "/home/mikesart/data/src/blah/build/blah", arch = "x86_64"
> CompileUnit: id = {0x00000000}, file = "/home/mikesart/data/src/blah/blah.cpp", language = "ISO C++:1998"
> Function: id = {0x000003c9}, name = "main", range = [0x0000000000409970-0x000000000040a275)
> FuncType: id = {0x000003c9}, decl = blah.cpp:159, clang_type = "int (int, char **)"
> Blocks: id = {0x000003c9}, range = [0x00409970-0x0040a275)
> LineEntry: [0x0000000000409970-0x0000000000409991): /home/mikesart/data/src/blah/blah.cpp:160
> Symbol: id = {0x00000076}, range = [0x0000000000409970-0x000000000040a275), name="main"
> Variable: id = {0x000003e6}, name = "argc", type= "int", location = DW_OP_fbreg(-8), decl = blah.cpp:159
> Variable: id = {0x000003f4}, name = "argv", type= "char **", location = DW_OP_fbreg(-16), decl = blah.cpp:159
> Variable: id = {0x00000402}, name = "msg", type= "Person", location = DW_OP_fbreg(-248), decl = blah.cpp:297
>
> As does using the address for "main".
>
> (lldb) p main
> (int (*)(int, char **)) $4 = 0x0000000000409970 (blah`main at blah.cpp:160)
> (lldb) target modules lookup -Av -a 0x0000000000409970
> Address: blah[0x0000000000409970] (blah..text + 368)
> Summary: blah`main at blah.cpp:160
> Module: file = "/home/mikesart/data/src/blah/build/blah", arch = "x86_64"
> CompileUnit: id = {0x00000000}, file = "/home/mikesart/data/src/blah/blah.cpp", language = "ISO C++:1998"
> Function: id = {0x000003c9}, name = "main", range = [0x0000000000409970-0x000000000040a275)
> FuncType: id = {0x000003c9}, decl = blah.cpp:159, clang_type = "int (int, char **)"
> Blocks: id = {0x000003c9}, range = [0x00409970-0x0040a275)
> LineEntry: [0x0000000000409970-0x0000000000409991): /home/mikesart/data/src/blah/blah.cpp:160
> Symbol: id = {0x00000076}, range = [0x0000000000409970-0x000000000040a275), name="main"
> Variable: id = {0x000003e6}, name = "argc", type= "int", location = DW_OP_fbreg(-8), decl = blah.cpp:159
> Variable: id = {0x000003f4}, name = "argv", type= "char **", location = DW_OP_fbreg(-16), decl = blah.cpp:159
> Variable: id = {0x00000402}, name = "msg", type= "Person", location = DW_OP_fbreg(-248), decl = blah.cpp:297
If you are sitting in main you can use "frame variable" to do what you want:
(lldb) frame variable --location argc
0x00007fff5fbff8c0: (int) argc = 1
Adding "--location" to frame variable will show you the address of argc (if it indeed is at an address, it could very well be in a register).
All throughout LLDB when "--symbol" is used it specifies symbol table symbols only. We often also use "--name" to mean either functions or symbols.
Let us know if you think anything needs changing in your command set. I don't think that looking up "argc" with "--symbol" makes sense though.
Greg
More information about the lldb-dev
mailing list