This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
Re: Add gdb.read_memory, gdb.write_memory and gdb.Membuf.
- From: Thiago Jung Bauermann <bauerman at br dot ibm dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: archer ml <archer at sourceware dot org>
- Date: Sat, 14 Feb 2009 23:27:56 -0300
- Subject: Re: Add gdb.read_memory, gdb.write_memory and gdb.Membuf.
- References: <1230581254.8380.97.camel@localhost.localdomain> <m3ocyliaj4.fsf@fleche.redhat.com>
El lun, 05-01-2009 a las 16:43 -0700, Tom Tromey escribiÃ:
> >>>>> "Thiago" == Thiago Jung Bauermann <bauerman@br.ibm.com> writes:
> Thiago> It's very simple: gdb.read_memory takes an address and a
> Thiago> length and reads the bytes from the inferior, placing them in
> Thiago> a Python buffer object. gdb.write_memory takes an address and
> Thiago> a Python object supporting the buffer protocol[0] (i.e., the
> Thiago> object from read_memory, an array or a string) and writes it
> Thiago> to the inferior memory.
>
> I was wondering whether we should have a buffer object be the access
> method. That is, provide a new class, implementing the buffer
> protocol, which provides "direct" access to inferior memory; it
> could have a constructor accepting an address and a size. Then,
> explicit read/write calls would not be needed.q
>
> Is this feasible? Would it perform well enough?
You mean a way to make GDB write to inferior memory when, for instance,
"b[6] = 'a'" is executed? No, the buffer protocol doesn't allow that. It
just allows the object to return a pointer to some memory region.
Individual accesses to that memory region happen independently of the
buffer object.
We could do this by implementing some __magic__ Python method to
override the default implementation of [], but that would have nothing
to do with the buffer protocol, and would not work with the struct
module or other python facilities which use that protocol.
--
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center