This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [COMMIT PATCH] server.c:gdb_read_memory: Fix error return.
- From: Pedro Alves <palves at redhat dot com>
- To: Pierre Muller <pierre dot muller at ics-cnrs dot unistra dot fr>, GDB Patches <gdb-patches at sourceware dot org>
- Date: Mon, 02 Sep 2013 16:02:58 +0100
- Subject: Re: [COMMIT PATCH] server.c:gdb_read_memory: Fix error return.
- Authentication-results: sourceware.org; auth=none
- References: <20130902141620 dot 20351 dot 77144 dot stgit at brno dot lan> <000601cea7e9$1cade4e0$5609aea0$ at muller@ics-cnrs.unistra.fr>
On 09/02/2013 03:31 PM, Pierre Muller wrote:
>
>
>> -----Message d'origine-----
>> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
>> owner@sourceware.org] De la part de Pedro Alves
>> Envoyà : lundi 2 septembre 2013 16:16
>> Ã : gdb-patches@sourceware.org
>> Objet : [COMMIT PATCH] server.c:gdb_read_memory: Fix error return.
>>
>> When I added gdb_read_memory, with bits factored out from elsewhere, I
>> missed adjusting this error return. gdb_read_memory has an interface
>> similar to GDB's xfer_partial:
>>
>>> /* Read trace frame or inferior memory. Returns the number of bytes
>>> actually read, zero when no further transfer is possible, and -1 on
>>> error. Return of a positive value smaller than LEN does not
>>> indicate there's no more to be read, only the end of the transfer.
>>
>> Returning EIO, a positive value, is obviously bogus, for the caller
>> will confuse it with a successful partial transfer.
>>
>> Found by inspection.
>
> I think there is still another EIO in gdb_write_memory
> which probably needs the same kind of treatment, no?
Not really. There's no support for partial writes in the
protocol (neither M nor X packets), and the callers expect
0 on success, not a length:
if (gdb_write_memory (mem_addr, mem_buf, len) == 0)
write_ok (own_buf);
else
write_enn (own_buf);
break;
case 'X':
require_running (own_buf);
if (decode_X_packet (&own_buf[1], packet_len - 1,
&mem_addr, &len, &mem_buf) < 0
|| gdb_write_memory (mem_addr, mem_buf, len) != 0)
write_enn (own_buf);
else
write_ok (own_buf);
The function is missing a describing comment. :-/
--
Pedro Alves