* Walking an array of structs under gdb-Python
@ 2011-03-18 17:02 Keith Goldberg
2011-03-22 16:40 ` Tom Tromey
0 siblings, 1 reply; 4+ messages in thread
From: Keith Goldberg @ 2011-03-18 17:02 UTC (permalink / raw)
To: gdb
All -
Can someone please point me to an example of how to walk through an
array of structs using python under GDB? Presuming I have malloc'd
enough space for 100 of mystruct, I would like to be able to use
"pointer math" to inspect each element and its members at will. I
appreciate any pointer to the right resource.
Thanks -
K.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Walking an array of structs under gdb-Python
2011-03-18 17:02 Walking an array of structs under gdb-Python Keith Goldberg
@ 2011-03-22 16:40 ` Tom Tromey
2011-03-23 16:36 ` kidoshisama
0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2011-03-22 16:40 UTC (permalink / raw)
To: Keith Goldberg; +Cc: gdb
Keith> Can someone please point me to an example of how to walk through an
Keith> array of structs using python under GDB? Presuming I have malloc'd
Keith> enough space for 100 of mystruct, I would like to be able to use
Keith> "pointer math" to inspect each element and its members at will. I
Keith> appreciate any pointer to the right resource.
I don't know of an example offhand, but it should pretty much work as
you'd expect.
Suppose you have 'type *array' in the source.
python v = gdb.parse_and_eval('array')
python print v.dereference() # print array[0]
python print (v + 1).dereference() # print array[1]
python print (v + 2)['field'] # print array[2].field
Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-03-23 18:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-18 17:02 Walking an array of structs under gdb-Python Keith Goldberg
2011-03-22 16:40 ` Tom Tromey
2011-03-23 16:36 ` kidoshisama
2011-03-23 18:15 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox