This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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: [COMMIT PATCH] server.c:gdb_read_memory: Fix error return.


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


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