This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [python][patch] Inferior and Thread information support.
On 06/18/2010 03:21 PM, Doug Evans wrote:
> I think search_memory should take just the same type of parameter for
> the search pattern that write_memory takes: a byte array (etc.). Keep
> the API simple and let the caller do the conversion to a byte array
> (or buffer protocol).
> We could provide utilities to convert to/from byte arrays (then
> write_memory can use them too!) but Python probably has them already.
> Then you can punt on the `size' parameter completely.
I'm not sure that conversion from a Python type to a buffer object are
that transparent. For instance there seems to be no straightforward
way to represent 3.141 as a sequence of bytes backed by a buffer in
Python (or accessible via the buffer interface rather). Maybe there
is, I'm certainly not a Python language expert. I hope someone can
prove me wrong!
Right now with the existing code, we take 3.141 as a gdb.value and
convert that to bytes via value_contents. Your suggestions would
certainly make the existing code simpler (and my porting task a little
easier ;), but I can't help thinking that it would be just making the
user jump through extra hoops just for API pureness. I strive for
that, it's a good thing; it just strikes me a little too much in this
case. OTOH we could just make add_value_pattern available via the API
and have the user manually do the conversion "the GDB way".
>
> You also want to document what the result is.
Sure, will do.
Cheers,
Phil