Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* How to do "info address" directly from python?
@ 2018-07-27 12:16 David Griffiths
  2018-07-27 12:41 ` Emiliano Testa
  2018-08-08 14:39 ` Tom Tromey
  0 siblings, 2 replies; 3+ messages in thread
From: David Griffiths @ 2018-07-27 12:16 UTC (permalink / raw)
  To: gdb

Hi, I can obtain the address of a non-debug symbol in python by doing:

gdb.execute("info address %s" % symbol, to_string=True)

and then parsing the result, but is there a way to obtain that information
directly using the python api? I've tried things like
gdb.lookup_global_symbol, gdb.lookup_type and gdb.parse_and_eval but none
of them return anything.

I'd prefer not to use gdb.execute as it sometimes gets the output of the
command mixed up with the output of a preceding gdb.write.

Cheers,

David


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

* Re: How to do "info address" directly from python?
  2018-07-27 12:16 How to do "info address" directly from python? David Griffiths
@ 2018-07-27 12:41 ` Emiliano Testa
  2018-08-08 14:39 ` Tom Tromey
  1 sibling, 0 replies; 3+ messages in thread
From: Emiliano Testa @ 2018-07-27 12:41 UTC (permalink / raw)
  To: David Griffiths; +Cc: gdb

I'm not knowledgeable in this context much... googling a bit helped in
finding this:

https://blog.0x972.info/?d=2015/11/02/10/10/23-looking-up-source-code-lines-from-gdbpython-and-openmp-complications

does it look helpful?

Cheers

Emiliano

On 27 July 2018 at 13:16, David Griffiths <dgriffiths@undo.io> wrote:

> Hi, I can obtain the address of a non-debug symbol in python by doing:
>
> gdb.execute("info address %s" % symbol, to_string=True)
>
> and then parsing the result, but is there a way to obtain that information
> directly using the python api? I've tried things like
> gdb.lookup_global_symbol, gdb.lookup_type and gdb.parse_and_eval but none
> of them return anything.
>
> I'd prefer not to use gdb.execute as it sometimes gets the output of the
> command mixed up with the output of a preceding gdb.write.
>
> Cheers,
>
> David
>



-- 
Emiliano Testa
Undo software engineer

22 Station Road
Cambridge
CB1 2JD
United Kingdom


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

* Re: How to do "info address" directly from python?
  2018-07-27 12:16 How to do "info address" directly from python? David Griffiths
  2018-07-27 12:41 ` Emiliano Testa
@ 2018-08-08 14:39 ` Tom Tromey
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2018-08-08 14:39 UTC (permalink / raw)
  To: David Griffiths; +Cc: gdb

>>>>> "David" == David Griffiths <dgriffiths@undo.io> writes:

David> Hi, I can obtain the address of a non-debug symbol in python by doing:
David> gdb.execute("info address %s" % symbol, to_string=True)

David> and then parsing the result, but is there a way to obtain that information
David> directly using the python api? I've tried things like
David> gdb.lookup_global_symbol, gdb.lookup_type and gdb.parse_and_eval but none
David> of them return anything.

The Python API doesn't expose non-debug symbols yet.
In fact the whole symbol part of the API isn't really complete.
It's an area that could use some work.

David> I'd prefer not to use gdb.execute as it sometimes gets the output of the
David> command mixed up with the output of a preceding gdb.write.

That sounds like a bug worth filing.
Do you know how to reproduce it?

Tom


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

end of thread, other threads:[~2018-08-08 14:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-27 12:16 How to do "info address" directly from python? David Griffiths
2018-07-27 12:41 ` Emiliano Testa
2018-08-08 14:39 ` Tom Tromey

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