Replace -1 with TARGET_XFER_E_IO

Hi,
This patch replaces -1 with TARGET_XFER_E_IO in the implementations of
to_xfer_partial and their callees.  This change is quite mechanical,
and makes the next patch shorter.

gdb:

2014-02-07  Yao Qi  <yao@codesourcery.com>

	* auxv.c (procfs_xfer_auxv): Replace -1 with TARGET_XFER_E_IO.
	(ld_so_xfer_auxv): Likewise.
	* bfd-target.c (target_bfd_xfer_partial): Likewise.
	* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
	* corelow.c (core_xfer_partial): Likewise.
	* ctf.c (ctf_xfer_partial): Likewise.
	* darwin-nat.c (darwin_read_dyld_info): Likewise.
	(darwin_xfer_partial): Likewise.
	* exec.c (exec_xfer_partial): Likewise.
	* gnu-nat.c (gnu_xfer_partial): Likewise.
	* ia64-hpux-nat.c (ia64_hpux_xfer_uregs): Likewise.
	* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise.
	* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
	* linux-nat.c (linux_xfer_siginfo): Likewise.
	(linux_proc_xfer_spu): Likewise.
	* procfs.c (procfs_xfer_partial): Likewise.
	* record-full.c (record_full_xfer_partial): Likewise.
	(record_full_core_xfer_partial): Likewise.
	* remote-sim.c (gdbsim_xfer_partial): Likewise.
	* remote.c (remote_write_qxfer): Likewise.
	(remote_write_qxfer, remote_read_qxfer): Likewise.
	(remote_xfer_partial): Likewise.
	* rs6000-nat.c (rs6000_xfer_partial): Likewise.
	(rs6000_xfer_shared_libraries): Likewise.
	* sparc-nat.c (sparc_xfer_wcookie): Likewise.
	* spu-linux-nat.c (spu_proc_xfer_spu): Likewise.
	(spu_xfer_partial): Likewise.
	* target.c (memory_xfer_partial_1): Likewise.
	* tracepoint.c (tfile_xfer_partial): Likewise.
	* windows-nat.c (windows_xfer_shared_libraries): Likewise.
	(windows_xfer_partial): Likewise.
This commit is contained in:
Yao Qi 2014-01-27 17:32:33 +08:00
parent c09f20e469
commit 2ed4b5488f
23 changed files with 105 additions and 71 deletions

View File

@ -1,3 +1,37 @@
2014-02-07 Yao Qi <yao@codesourcery.com>
* auxv.c (procfs_xfer_auxv): Replace -1 with TARGET_XFER_E_IO.
(ld_so_xfer_auxv): Likewise.
* bfd-target.c (target_bfd_xfer_partial): Likewise.
* bsd-kvm.c (bsd_kvm_xfer_partial): Likewise.
* corelow.c (core_xfer_partial): Likewise.
* ctf.c (ctf_xfer_partial): Likewise.
* darwin-nat.c (darwin_read_dyld_info): Likewise.
(darwin_xfer_partial): Likewise.
* exec.c (exec_xfer_partial): Likewise.
* gnu-nat.c (gnu_xfer_partial): Likewise.
* ia64-hpux-nat.c (ia64_hpux_xfer_uregs): Likewise.
* inf-ptrace.c (inf_ptrace_xfer_partial): Likewise.
* inf-ttrace.c (inf_ttrace_xfer_partial): Likewise.
* linux-nat.c (linux_xfer_siginfo): Likewise.
(linux_proc_xfer_spu): Likewise.
* procfs.c (procfs_xfer_partial): Likewise.
* record-full.c (record_full_xfer_partial): Likewise.
(record_full_core_xfer_partial): Likewise.
* remote-sim.c (gdbsim_xfer_partial): Likewise.
* remote.c (remote_write_qxfer): Likewise.
(remote_write_qxfer, remote_read_qxfer): Likewise.
(remote_xfer_partial): Likewise.
* rs6000-nat.c (rs6000_xfer_partial): Likewise.
(rs6000_xfer_shared_libraries): Likewise.
* sparc-nat.c (sparc_xfer_wcookie): Likewise.
* spu-linux-nat.c (spu_proc_xfer_spu): Likewise.
(spu_xfer_partial): Likewise.
* target.c (memory_xfer_partial_1): Likewise.
* tracepoint.c (tfile_xfer_partial): Likewise.
* windows-nat.c (windows_xfer_shared_libraries): Likewise.
(windows_xfer_partial): Likewise.
2014-02-07 Yao Qi <yao@codesourcery.com>
* gdbarch.sh (core_xfer_shared_libraries): Returns ULONGEST. Add

View File

@ -52,7 +52,7 @@ procfs_xfer_auxv (gdb_byte *readbuf,
fd = gdb_open_cloexec (pathname, writebuf != NULL ? O_WRONLY : O_RDONLY, 0);
xfree (pathname);
if (fd < 0)
return -1;
return TARGET_XFER_E_IO;
if (offset != (ULONGEST) 0
&& lseek (fd, (off_t) offset, SEEK_SET) != (off_t) offset)
@ -86,10 +86,10 @@ ld_so_xfer_auxv (gdb_byte *readbuf,
msym = lookup_minimal_symbol ("_dl_auxv", NULL, NULL);
if (msym == NULL)
return -1;
return TARGET_XFER_E_IO;
if (MSYMBOL_SIZE (msym) != ptr_size)
return -1;
return TARGET_XFER_E_IO;
/* POINTER_ADDRESS is a location where the `_dl_auxv' variable
resides. DATA_ADDRESS is the inferior value present in
@ -118,14 +118,14 @@ ld_so_xfer_auxv (gdb_byte *readbuf,
11440. */
if (target_read_memory (pointer_address, ptr_buf, ptr_size) != 0)
return -1;
return TARGET_XFER_E_IO;
data_address = extract_typed_address (ptr_buf, ptr_type);
/* Possibly still not initialized such as during an inferior
startup. */
if (data_address == 0)
return -1;
return TARGET_XFER_E_IO;
data_address += offset;
@ -134,7 +134,7 @@ ld_so_xfer_auxv (gdb_byte *readbuf,
if (target_write_memory (data_address, writebuf, len) == 0)
return len;
else
return -1;
return TARGET_XFER_E_IO;
}
/* Stop if trying to read past the existing AUXV block. The final
@ -144,7 +144,7 @@ ld_so_xfer_auxv (gdb_byte *readbuf,
{
if (target_read_memory (data_address - auxv_pair_size, ptr_buf,
ptr_size) != 0)
return -1;
return TARGET_XFER_E_IO;
if (extract_typed_address (ptr_buf, ptr_type) == AT_NULL)
return 0;

View File

@ -55,7 +55,7 @@ target_bfd_xfer_partial (struct target_ops *ops,
NULL);
}
default:
return -1;
return TARGET_XFER_E_IO;
}
}

View File

@ -143,7 +143,7 @@ bsd_kvm_xfer_partial (struct target_ops *ops, enum target_object object,
return bsd_kvm_xfer_memory (offset, len, readbuf, writebuf);
default:
return -1;
return TARGET_XFER_E_IO;
}
}

View File

@ -698,7 +698,7 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
section = bfd_get_section_by_name (core_bfd, ".auxv");
if (section == NULL)
return -1;
return TARGET_XFER_E_IO;
size = bfd_section_size (core_bfd, section);
if (offset >= size)
@ -711,12 +711,12 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
(file_ptr) offset, size))
{
warning (_("Couldn't read NT_AUXV note in core file."));
return -1;
return TARGET_XFER_E_IO;
}
return size;
}
return -1;
return TARGET_XFER_E_IO;
case TARGET_OBJECT_WCOOKIE:
if (readbuf)
@ -730,7 +730,7 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
section = bfd_get_section_by_name (core_bfd, ".wcookie");
if (section == NULL)
return -1;
return TARGET_XFER_E_IO;
size = bfd_section_size (core_bfd, section);
if (offset >= size)
@ -743,19 +743,19 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
(file_ptr) offset, size))
{
warning (_("Couldn't read StackGhost cookie in core file."));
return -1;
return TARGET_XFER_E_IO;
}
return size;
}
return -1;
return TARGET_XFER_E_IO;
case TARGET_OBJECT_LIBRARIES:
if (core_gdbarch
&& gdbarch_core_xfer_shared_libraries_p (core_gdbarch))
{
if (writebuf)
return -1;
return TARGET_XFER_E_IO;
return
gdbarch_core_xfer_shared_libraries (core_gdbarch,
readbuf, offset, len);
@ -767,7 +767,7 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
&& gdbarch_core_xfer_shared_libraries_aix_p (core_gdbarch))
{
if (writebuf)
return -1;
return TARGET_XFER_E_IO;
return
gdbarch_core_xfer_shared_libraries_aix (core_gdbarch,
readbuf, offset, len);
@ -789,7 +789,7 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
section = bfd_get_section_by_name (core_bfd, sectionstr);
if (section == NULL)
return -1;
return TARGET_XFER_E_IO;
size = bfd_section_size (core_bfd, section);
if (offset >= size)
@ -802,7 +802,7 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
(file_ptr) offset, size))
{
warning (_("Couldn't read SPU section in core file."));
return -1;
return TARGET_XFER_E_IO;
}
return size;
@ -820,19 +820,19 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
bfd_map_over_sections (core_bfd, add_to_spuid_list, &list);
return list.written;
}
return -1;
return TARGET_XFER_E_IO;
case TARGET_OBJECT_SIGNAL_INFO:
if (readbuf)
return get_core_siginfo (core_bfd, readbuf, offset, len);
return -1;
return TARGET_XFER_E_IO;
default:
if (ops->beneath != NULL)
return ops->beneath->to_xfer_partial (ops->beneath, object,
annex, readbuf,
writebuf, offset, len);
return -1;
return TARGET_XFER_E_IO;
}
}

View File

@ -1493,7 +1493,7 @@ ctf_xfer_partial (struct target_ops *ops, enum target_object object,
}
/* Indicate failure to find the requested memory block. */
return -1;
return TARGET_XFER_E_IO;
}
/* This is the implementation of target_ops method

View File

@ -1907,7 +1907,7 @@ darwin_read_dyld_info (task_t task, CORE_ADDR addr, gdb_byte *rdaddr,
kret = task_info (task, TASK_DYLD_INFO, (task_info_t) &task_dyld_info, &count);
MACH_CHECK_ERROR (kret);
if (kret != KERN_SUCCESS)
return -1;
return TARGET_XFER_E_IO;
/* Truncate. */
if (addr + length > sz)
length = sz - addr;
@ -1942,12 +1942,12 @@ darwin_xfer_partial (struct target_ops *ops,
if (writebuf != NULL || readbuf == NULL)
{
/* Support only read. */
return -1;
return TARGET_XFER_E_IO;
}
return darwin_read_dyld_info (inf->private->task, offset, readbuf, len);
#endif
default:
return -1;
return TARGET_XFER_E_IO;
}
}

View File

@ -650,7 +650,7 @@ exec_xfer_partial (struct target_ops *ops, enum target_object object,
table->sections_end,
NULL);
else
return -1;
return TARGET_XFER_E_IO;
}

View File

@ -2520,7 +2520,7 @@ gnu_xfer_partial (struct target_ops *ops, enum target_object object,
return gnu_xfer_memory (readbuf, writebuf, offset, len);
default:
return -1;
return TARGET_XFER_E_IO;
}
}

View File

@ -630,7 +630,7 @@ ia64_hpux_xfer_uregs (struct target_ops *ops, const char *annex,
status = ia64_hpux_read_register_from_save_state_t (offset, readbuf, len);
if (status < 0)
return -1;
return TARGET_XFER_E_IO;
return len;
}

View File

@ -573,7 +573,7 @@ inf_ptrace_xfer_partial (struct target_ops *ops, enum target_object object,
}
case TARGET_OBJECT_UNWIND_TABLE:
return -1;
return TARGET_XFER_E_IO;
case TARGET_OBJECT_AUXV:
#if defined (PT_IO) && defined (PIOD_READ_AUXV)
@ -584,7 +584,7 @@ inf_ptrace_xfer_partial (struct target_ops *ops, enum target_object object,
struct ptrace_io_desc piod;
if (writebuf)
return -1;
return TARGET_XFER_E_IO;
piod.piod_op = PIOD_READ_AUXV;
piod.piod_addr = readbuf;
piod.piod_offs = (void *) (long) offset;
@ -596,13 +596,13 @@ inf_ptrace_xfer_partial (struct target_ops *ops, enum target_object object,
return piod.piod_len;
}
#endif
return -1;
return TARGET_XFER_E_IO;
case TARGET_OBJECT_WCOOKIE:
return -1;
return TARGET_XFER_E_IO;
default:
return -1;
return TARGET_XFER_E_IO;
}
}

View File

@ -1234,16 +1234,16 @@ inf_ttrace_xfer_partial (struct target_ops *ops, enum target_object object,
return inf_ttrace_xfer_memory (offset, len, readbuf, writebuf);
case TARGET_OBJECT_UNWIND_TABLE:
return -1;
return TARGET_XFER_E_IO;
case TARGET_OBJECT_AUXV:
return -1;
return TARGET_XFER_E_IO;
case TARGET_OBJECT_WCOOKIE:
return -1;
return TARGET_XFER_E_IO;
default:
return -1;
return TARGET_XFER_E_IO;
}
}

View File

@ -3879,12 +3879,12 @@ linux_xfer_siginfo (struct target_ops *ops, enum target_object object,
pid = ptid_get_pid (inferior_ptid);
if (offset > sizeof (siginfo))
return -1;
return TARGET_XFER_E_IO;
errno = 0;
ptrace (PTRACE_GETSIGINFO, pid, (PTRACE_TYPE_ARG3) 0, &siginfo);
if (errno != 0)
return -1;
return TARGET_XFER_E_IO;
/* When GDB is built as a 64-bit application, ptrace writes into
SIGINFO an object with 64-bit layout. Since debugging a 32-bit
@ -3909,7 +3909,7 @@ linux_xfer_siginfo (struct target_ops *ops, enum target_object object,
errno = 0;
ptrace (PTRACE_SETSIGINFO, pid, (PTRACE_TYPE_ARG3) 0, &siginfo);
if (errno != 0)
return -1;
return TARGET_XFER_E_IO;
}
return len;
@ -4219,7 +4219,7 @@ linux_proc_xfer_spu (struct target_ops *ops, enum target_object object,
if (!annex)
{
if (!readbuf)
return -1;
return TARGET_XFER_E_IO;
else
return spu_enumerate_spu_ids (pid, readbuf, offset, len);
}
@ -4227,7 +4227,7 @@ linux_proc_xfer_spu (struct target_ops *ops, enum target_object object,
xsnprintf (buf, sizeof buf, "/proc/%d/fd/%s", pid, annex);
fd = gdb_open_cloexec (buf, writebuf? O_WRONLY : O_RDONLY, 0);
if (fd <= 0)
return -1;
return TARGET_XFER_E_IO;
if (offset != 0
&& lseek (fd, (off_t) offset, SEEK_SET) != (off_t) offset)

View File

@ -3987,7 +3987,7 @@ procfs_xfer_partial (struct target_ops *ops, enum target_object object,
if (writebuf)
return (*ops->deprecated_xfer_memory) (offset, (gdb_byte *) writebuf,
len, 1/*write*/, NULL, ops);
return -1;
return TARGET_XFER_E_IO;
#ifdef NEW_PROC_API
case TARGET_OBJECT_AUXV:
@ -3999,7 +3999,7 @@ procfs_xfer_partial (struct target_ops *ops, enum target_object object,
if (ops->beneath != NULL)
return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
readbuf, writebuf, offset, len);
return -1;
return TARGET_XFER_E_IO;
}
}

View File

@ -1685,7 +1685,7 @@ record_full_xfer_partial (struct target_ops *ops, enum target_object object,
fprintf_unfiltered (gdb_stdlog,
"Process record: failed to record "
"execution log.");
return -1;
return TARGET_XFER_E_IO;
}
if (record_full_arch_list_add_end ())
{
@ -1694,7 +1694,7 @@ record_full_xfer_partial (struct target_ops *ops, enum target_object object,
fprintf_unfiltered (gdb_stdlog,
"Process record: failed to record "
"execution log.");
return -1;
return TARGET_XFER_E_IO;
}
record_full_list->next = record_full_arch_list_head;
record_full_arch_list_head->prev = record_full_list;
@ -2270,7 +2270,7 @@ record_full_core_xfer_partial (struct target_ops *ops,
}
}
return -1;
return TARGET_XFER_E_IO;
}
else
error (_("You can't do that without a process to debug."));

View File

@ -1124,7 +1124,7 @@ gdbsim_xfer_partial (struct target_ops *ops, enum target_object object,
return gdbsim_xfer_memory (ops, readbuf, writebuf, offset, len);
default:
return -1;
return TARGET_XFER_E_IO;
}
}

View File

@ -8749,7 +8749,7 @@ remote_write_qxfer (struct target_ops *ops, const char *object_name,
int max_size = get_memory_write_packet_size ();
if (packet->support == PACKET_DISABLE)
return -1;
return TARGET_XFER_E_IO;
/* Insert header. */
i = snprintf (rs->buf, max_size,
@ -8765,7 +8765,7 @@ remote_write_qxfer (struct target_ops *ops, const char *object_name,
if (putpkt_binary (rs->buf, i + buf_len) < 0
|| getpkt_sane (&rs->buf, &rs->buf_size, 0) < 0
|| packet_ok (rs->buf, packet) != PACKET_OK)
return -1;
return TARGET_XFER_E_IO;
unpack_varlen_hex (rs->buf, &n);
return n;
@ -8788,7 +8788,7 @@ remote_read_qxfer (struct target_ops *ops, const char *object_name,
LONGEST i, n, packet_len;
if (packet->support == PACKET_DISABLE)
return -1;
return TARGET_XFER_E_IO;
/* Check whether we've cached an end-of-object packet that matches
this request. */
@ -8818,12 +8818,12 @@ remote_read_qxfer (struct target_ops *ops, const char *object_name,
phex_nz (n, sizeof n));
i = putpkt (rs->buf);
if (i < 0)
return -1;
return TARGET_XFER_E_IO;
rs->buf[0] = '\0';
packet_len = getpkt_sane (&rs->buf, &rs->buf_size, 0);
if (packet_len < 0 || packet_ok (rs->buf, packet) != PACKET_OK)
return -1;
return TARGET_XFER_E_IO;
if (rs->buf[0] != 'l' && rs->buf[0] != 'm')
error (_("Unknown remote qXfer reply: %s"), rs->buf);
@ -8920,7 +8920,7 @@ remote_xfer_partial (struct target_ops *ops, enum target_object object,
&remote_protocol_packets
[PACKET_qXfer_statictrace_read]);
else
return -1;
return TARGET_XFER_E_IO;
}
/* Only handle flash writes. */
@ -8934,7 +8934,7 @@ remote_xfer_partial (struct target_ops *ops, enum target_object object,
return remote_flash_write (ops, offset, len, writebuf);
default:
return -1;
return TARGET_XFER_E_IO;
}
}
@ -9002,7 +9002,7 @@ remote_xfer_partial (struct target_ops *ops, enum target_object object,
&remote_protocol_packets[PACKET_qXfer_btrace]);
default:
return -1;
return TARGET_XFER_E_IO;
}
/* Note: a zero OFFSET and LEN can be used to query the minimum
@ -9012,7 +9012,7 @@ remote_xfer_partial (struct target_ops *ops, enum target_object object,
/* Minimum outbuf size is get_remote_packet_size (). If LEN is not
large enough let the caller deal with it. */
if (len < get_remote_packet_size ())
return -1;
return TARGET_XFER_E_IO;
len = get_remote_packet_size ();
/* Except for querying the minimum buffer size, target must be open. */
@ -9044,7 +9044,7 @@ remote_xfer_partial (struct target_ops *ops, enum target_object object,
i = putpkt (rs->buf);
if (i < 0)
return i;
return TARGET_XFER_E_IO;
getpkt (&rs->buf, &rs->buf_size, 0);
strcpy ((char *) readbuf, rs->buf);

View File

@ -476,7 +476,7 @@ rs6000_xfer_partial (struct target_ops *ops, enum target_object object,
}
default:
return -1;
return TARGET_XFER_E_IO;
}
}
@ -697,7 +697,7 @@ rs6000_xfer_shared_libraries
gdb_assert (target_has_execution);
if (writebuf)
return -1;
return TARGET_XFER_E_IO;
ldi_buf = rs6000_ptrace_ldinfo (inferior_ptid);
gdb_assert (ldi_buf != NULL);

View File

@ -272,7 +272,7 @@ sparc_xfer_wcookie (struct target_ops *ops, enum target_object object,
if (offset == sizeof (unsigned long))
return 0; /* Signal EOF. */
if (offset > sizeof (unsigned long))
return -1;
return TARGET_XFER_E_IO;
#ifdef PT_WCOOKIE
/* If PT_WCOOKIE is defined (by <sys/ptrace.h>), assume we're

View File

@ -244,7 +244,7 @@ spu_proc_xfer_spu (const char *annex, gdb_byte *readbuf,
xsnprintf (buf, sizeof buf, "/proc/%d/fd/%s", pid, annex);
fd = open (buf, writebuf? O_WRONLY : O_RDONLY);
if (fd <= 0)
return -1;
return TARGET_XFER_E_IO;
if (offset != 0
&& lseek (fd, (off_t) offset, SEEK_SET) != (off_t) offset)
@ -601,7 +601,7 @@ spu_xfer_partial (struct target_ops *ops,
offset & lslr, len);
}
return -1;
return TARGET_XFER_E_IO;
}
/* Override the to_can_use_hw_breakpoint routine. */

View File

@ -1542,12 +1542,12 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
{
case MEM_RO:
if (writebuf != NULL)
return -1;
return TARGET_XFER_E_IO;
break;
case MEM_WO:
if (readbuf != NULL)
return -1;
return TARGET_XFER_E_IO;
break;
case MEM_FLASH:
@ -1557,7 +1557,7 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object,
break;
case MEM_NONE:
return -1;
return TARGET_XFER_E_IO;
}
if (!ptid_equal (inferior_ptid, null_ptid))

View File

@ -5120,7 +5120,7 @@ tfile_xfer_partial (struct target_ops *ops, enum target_object object,
{
/* We're only doing regular memory for now. */
if (object != TARGET_OBJECT_MEMORY)
return -1;
return TARGET_XFER_E_IO;
if (readbuf == NULL)
error (_("tfile_xfer_partial: trace file is read-only"));
@ -5199,7 +5199,7 @@ tfile_xfer_partial (struct target_ops *ops, enum target_object object,
}
/* Indicate failure to find the requested memory block. */
return -1;
return TARGET_XFER_E_IO;
}
/* Iterate through the blocks of a trace frame, looking for a 'V'

View File

@ -2514,7 +2514,7 @@ windows_xfer_shared_libraries (struct target_ops *ops,
struct so_list *so;
if (writebuf)
return -1;
return TARGET_XFER_E_IO;
obstack_init (&obstack);
obstack_grow_str (&obstack, "<library-list>\n");
@ -2557,7 +2557,7 @@ windows_xfer_partial (struct target_ops *ops, enum target_object object,
if (ops->beneath != NULL)
return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
readbuf, writebuf, offset, len);
return -1;
return TARGET_XFER_E_IO;
}
}