This is the mail archive of the mailing list for the Archer project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Add gdb.read_memory, gdb.write_memory and gdb.Membuf.

El lun, 05-01-2009 a las 16:43 -0700, Tom Tromey escribiÃ:
> >>>>> "Thiago" == Thiago Jung Bauermann <> 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.
Thiago Jung Bauermann
IBM Linux Technology Center

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]