This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: How to get a sequence of bytes with python?
- From: Tom Tromey <tromey at redhat dot com>
- To: S Boucher <stbya at yahoo dot com>
- Cc: "gdb\ at sourceware dot org" <gdb at sourceware dot org>
- Date: Wed, 05 Oct 2011 14:25:29 -0600
- Subject: Re: How to get a sequence of bytes with python?
- References: <1317845287.27305.YahooMailNeo@web161609.mail.bf1.yahoo.com>
>>>>> ">" == S Boucher <stbya@yahoo.com> writes:
>> I get gdb.Value that is a pointer, and want to read 16 bytes and store
>> this in a python string.
>> gdb.Value's string() doesn't seem to have a way to interpret memory as
>> raw bytes.
Yeah.
I think a new Value method would be good.
Please at least file a bug for this.
>> Alternatively, accessing memory via gdb.Inferior seems problematic in that:
>> 1) I don't see a way to programatically get the relevant/current
>> gdb.Inferior using gdb.inferiors()
gdb.selected_inferior went in recently.
>> 2) read_memory() will require me to iterate and convert explicitly to
>> a real python string (ok, this is only a minor annoyance)
>> Any suggestion on how I could go about doing this?
You could try fetching a string using the ISO-8859-1 encoding.
This is sort of gross but it might work.
Tom