For this old of an LLDB you will need to put back ticks around the $pc:
(lldb) image lookup -va `$pc`
To get the file list, we can turn to python:
#!/usr/bin/python
import lldb
import shlex
def dump_module_sources(module, result):
if module:
print >> result, "Module: %s" % (module.file)
for compile_unit in module.compile_units:
print >> result, " %s" % (compile_unit.file)
def info_sources(debugger, command, result, dict):
description='''This command will dump all compile units in any modules that are listed as arguments, or for all modules if no arguments are supplied.'''
module_names = shlex.split(command)
target = debugger.GetSelectedTarget()
if module_names:
for module_name in module_names:
dump_module_sources(target.module[module_name], result)
else:
for module in target.modules:
dump_module_sources(module, result)
def __lldb_init_module (debugger, dict):
# Add any commands contained in this module to LLDB
debugger.HandleCommand('command script add -f sources.info_sources info_sources')
print 'The "info_sources" command has been installed, type "help info_sources" or "info_sources --help" for detailed help.'
Import the above file and then run the new "info_sources" command:
(lldb) command script import /tmp/sources.py
The "info_sources" command has been installed, type "help info_sources" or
"info_sources --help" for detailed help.
(lldb) info_sources a.out
Module: /Volumes/work/gclayton/Documents/src/args/a.out
/Volumes/work/gclayton/Documents/src/args/main.c
Checkout the python and then head to:
http://lldb.llvm.org/python_reference/index.html
to see the rest of the API you have available to you
On Sep 3, 2013, at 6:29 PM, Yin Ma <[email protected]> wrote:
> Hi Jim,
>
> Thank you for your help.
>
> I tried image lookup -va $pc on my lldb.
> I got
> error: invalid address string '$pc'
>
> I am using lldb-179.3, is your version much higher than mine?
>
> Do you know any method that I can retrieve the source file list
> from lldb?
>
> Yin
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
> Sent: Tuesday, September 03, 2013 6:15 PM
> To: Yin Ma
> Cc: [email protected]
> Subject: Re: [lldb-dev] help for lldb command like gdb info sources & info
> source
>
> There isn't an equivalent of "info sources" yet.
>
> There is a rough equivalent of "info line" (listed in the gdb->lldb cheat
> sheet at http://lldb.llvm.org/lldb-gdb.html), which is to do:
>
> (lldb) image lookup -va $pc
> ...
> LineEntry: [0x000000010001a98e-0x000000010001a99f): /Work/Foo.c:11
> ...
>
> It isn't as good as "info line" because it only gives the address range from
> the given source line that surrounds the address passed to the lookup
> command. It doesn't answer the question "what are ALL the address ranges
> that contribute to the implementation of this source line?"
>
> Hope this helps,
>
> Jim
>
>
> On Sep 3, 2013, at 4:58 PM, Yin Ma <[email protected]> wrote:
>
>> Hi,
>>
>> Could anyone let me know what is the lldb command
>> to show all source files like gdb info sources and
>> the command to show the source file info of the
>> current $pc location?
>>
>> Thanks,
>>
>> Yin
>>
>> _______________________________________________
>> lldb-dev mailing list
>> [email protected]
>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>
>
> _______________________________________________
> lldb-dev mailing list
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
_______________________________________________
lldb-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev