Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Python API: Getting symbol by address
@ 2017-12-21 18:20 Roman Popov
  2017-12-21 22:24 ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Roman Popov @ 2017-12-21 18:20 UTC (permalink / raw)
  To: gdb

Hello,
I have collection in C++ that stores pointers to functions and methods. I
want to pretty-print pointed method and functions names.

It is possible using GDB shell, for example:

(gdb) info symbol 0x405ece

top::test_thread() in section .text of test_procs


However I found no way to do the same using Python API.  Why such
limitation?

P/S Same question on stackoverflow :
https://stackoverflow.com/questions/47916564/gdb-python-api-getting-symbol-name-from-address

Thanks,
Roman


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Python API: Getting symbol by address
  2017-12-21 18:20 Python API: Getting symbol by address Roman Popov
@ 2017-12-21 22:24 ` Simon Marchi
  2017-12-21 22:56   ` Roman Popov
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2017-12-21 22:24 UTC (permalink / raw)
  To: Roman Popov; +Cc: gdb

On 2017-12-21 13:20, Roman Popov wrote:
> Hello,
> I have collection in C++ that stores pointers to functions and methods. 
> I
> want to pretty-print pointed method and functions names.
> 
> It is possible using GDB shell, for example:
> 
> (gdb) info symbol 0x405ece
> 
> top::test_thread() in section .text of test_procs
> 
> 
> However I found no way to do the same using Python API.  Why such
> limitation?
> 
> P/S Same question on stackoverflow :
> https://stackoverflow.com/questions/47916564/gdb-python-api-getting-symbol-name-from-address
> 
> Thanks,
> Roman

Hi Roman,

As most things in the Python API (and GDB in general), it's likely 
because no one took the time to do it.  I don't see any technical reason 
not to have it.  If you take a shot at writing a patch for this, feel 
free to ask if you are blocked.

Thanks,

Simon


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Python API: Getting symbol by address
  2017-12-21 22:24 ` Simon Marchi
@ 2017-12-21 22:56   ` Roman Popov
  0 siblings, 0 replies; 3+ messages in thread
From: Roman Popov @ 2017-12-21 22:56 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb

Thanks, so it is just not implemented yet.
Unfortunately I can't quickly write a patch myself because I'm not familiar
with gdb codebase. I don't even know how debuggers work to be honest .

I've noticed that GDB can pretty-print function/method pointer values like
this:

print ( some_func_ptr_gdbvalue )
>>> (void (*)(int, int)) 0x4049f7 <test(int, int)>

So I've unblocked myself by this ugly text parsing workaround:

s = str (some_func_ptr_gdbvalue)
symbol_name = s[s.find("<") + 1 : s.rfind(">")]
gdb_symbol = gdb.lookup_symbol(symbol_name)


2017-12-21 14:24 GMT-08:00 Simon Marchi <simon.marchi@polymtl.ca>:

> On 2017-12-21 13:20, Roman Popov wrote:
>
>> Hello,
>> I have collection in C++ that stores pointers to functions and methods. I
>> want to pretty-print pointed method and functions names.
>>
>> It is possible using GDB shell, for example:
>>
>> (gdb) info symbol 0x405ece
>>
>> top::test_thread() in section .text of test_procs
>>
>>
>> However I found no way to do the same using Python API.  Why such
>> limitation?
>>
>> P/S Same question on stackoverflow :
>> https://stackoverflow.com/questions/47916564/gdb-python-api-
>> getting-symbol-name-from-address
>>
>> Thanks,
>> Roman
>>
>
> Hi Roman,
>
> As most things in the Python API (and GDB in general), it's likely because
> no one took the time to do it.  I don't see any technical reason not to
> have it.  If you take a shot at writing a patch for this, feel free to ask
> if you are blocked.
>
> Thanks,
>
> Simon
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-12-21 22:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-21 18:20 Python API: Getting symbol by address Roman Popov
2017-12-21 22:24 ` Simon Marchi
2017-12-21 22:56   ` Roman Popov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox