This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 'info symbol' equivalent in python?


For current gdb, you can get the output of "info symbol" and parse it.

http://kgtp.googlecode.com/svn/trunk/add-ons/hotcode.py function
get_line_from_sym is a example for it.

Thanks,
Hui

On Mon, Mar 19, 2012 at 18:47, Avi Kivity <avi@redhat.com> wrote:
> On 03/19/2012 12:43 PM, Matt Rice wrote:
>> On 3/19/12, Avi Kivity <avi@redhat.com> wrote:
>> > On 03/19/2012 06:34 AM, Hui Zhu wrote:
>> >> http://sourceware.org/gdb/current/onlinedocs/gdb/Symbols-In-Python.html#Symbols-In-Python
>> >>
>> >>
>> >> On 03/18/12 22:37, Avi Kivity wrote:
>> >>> Is there a gdb python API for 'info symbol'?
>> >>>
>> >>
>> >
>> > These give lookup the symbol given a name. ?I want to lookup a symbol
>> > given an address (like 'info symbol').
>>
>> sounds like you're looking for the block_for_pc and gdb.Block's
>> function attribute,
>>
>> (gdb) py print repr(gdb.block_for_pc(0x0000000000400598).function)
>> <gdb.Symbol object at 0x7fb5ef615df0>
>> (gdb) py print gdb.block_for_pc(0x0000000000400598).function
>> main
>> (gdb)
>
> Similar. ?I want the names of static/global variables, not functions.
>
> --
> error compiling committee.c: too many arguments to function
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]