forked from Imagelibrary/binutils-gdb
target_read_memory&co: no longer return target_xfer_status
Years ago, these functions used to return errno/EIO. Later, through a
series of changes that intended to remove native/remote differences,
they ended up returning a target_xfer_status in disguise.
Unlike target_xfer_partial&co, the point of target_read_memory&co is
to either fully succeed or fail. On error, they always return
TARGET_XFER_E_IO. So there's no real point in casting the return of
target_read_memory to a target_xfer_status to pass it to memory_error.
Instead, it results in clearer code to simply decouple
target_read_memory&co's return from target_xfer_status.
This fixes build errors like this in C++ mode:
../../src/gdb/corefile.c: In function ‘void read_stack(CORE_ADDR, gdb_byte*, ssize_t)’:
../../src/gdb/corefile.c:276:34: error: invalid conversion from ‘int’ to ‘target_xfer_status’ [-fpermissive]
memory_error (status, memaddr);
^
../../src/gdb/corefile.c:216:1: error: initializing argument 1 of ‘void memory_error(target_xfer_status, CORE_ADDR)’ [-fpermissive]
gdb/ChangeLog:
2015-10-27 Pedro Alves <palves@redhat.com>
* alpha-tdep.c (alpha_read_insn): Always pass TARGET_XFER_E_IO to
memory_error. Rename local 'status' to 'res'.
* c-lang.c (c_get_string): Always pass TARGET_XFER_E_IO to
memory_error.
* corefile.c (read_stack, read_code, write_memory): Always pass
TARGET_XFER_E_IO to memory_error.
* disasm.c (dis_asm_memory_error): Always pass TARGET_XFER_E_IO to
memory_error. Rename parameter 'status' to 'err'.
(dump_insns): Rename local 'status' to 'err'.
* mips-tdep.c (mips_fetch_instruction): Rename parameter 'statusp'
to 'errp'. Rename local 'status' to 'err'. Always pass
TARGET_XFER_E_IO to memory_error.
(mips_breakpoint_from_pc): Rename local 'status' to 'err'.
* target.c (target_read_memory, target_read_raw_memory)
(target_read_stack, target_read_code, target_write_memory)
(target_write_raw_memory): Return -1 on error instead of
TARGET_XFER_E_IO.
* valprint.c (val_print_string): Rename local 'errcode' to 'err'.
Always pass TARGET_XFER_E_IO to memory_error. Update comment.
This commit is contained in:
30
gdb/target.c
30
gdb/target.c
@@ -1380,7 +1380,7 @@ target_xfer_partial (struct target_ops *ops,
|
||||
|
||||
/* Read LEN bytes of target memory at address MEMADDR, placing the
|
||||
results in GDB's memory at MYADDR. Returns either 0 for success or
|
||||
TARGET_XFER_E_IO if any error occurs.
|
||||
-1 if any error occurs.
|
||||
|
||||
If an error occurs, no guarantee is made about the contents of the data at
|
||||
MYADDR. In particular, the caller should not depend upon partial reads
|
||||
@@ -1399,7 +1399,7 @@ target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
|
||||
myaddr, memaddr, len) == len)
|
||||
return 0;
|
||||
else
|
||||
return TARGET_XFER_E_IO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* See target/target.h. */
|
||||
@@ -1431,7 +1431,7 @@ target_read_raw_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
|
||||
myaddr, memaddr, len) == len)
|
||||
return 0;
|
||||
else
|
||||
return TARGET_XFER_E_IO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Like target_read_memory, but specify explicitly that this is a read from
|
||||
@@ -1446,7 +1446,7 @@ target_read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
|
||||
myaddr, memaddr, len) == len)
|
||||
return 0;
|
||||
else
|
||||
return TARGET_XFER_E_IO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Like target_read_memory, but specify explicitly that this is a read from
|
||||
@@ -1461,14 +1461,14 @@ target_read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
|
||||
myaddr, memaddr, len) == len)
|
||||
return 0;
|
||||
else
|
||||
return TARGET_XFER_E_IO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Write LEN bytes from MYADDR to target memory at address MEMADDR.
|
||||
Returns either 0 for success or TARGET_XFER_E_IO if any
|
||||
error occurs. If an error occurs, no guarantee is made about how
|
||||
much data got written. Callers that can deal with partial writes
|
||||
should call target_write. */
|
||||
Returns either 0 for success or -1 if any error occurs. If an
|
||||
error occurs, no guarantee is made about how much data got written.
|
||||
Callers that can deal with partial writes should call
|
||||
target_write. */
|
||||
|
||||
int
|
||||
target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
|
||||
@@ -1479,14 +1479,14 @@ target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
|
||||
myaddr, memaddr, len) == len)
|
||||
return 0;
|
||||
else
|
||||
return TARGET_XFER_E_IO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Write LEN bytes from MYADDR to target raw memory at address
|
||||
MEMADDR. Returns either 0 for success or TARGET_XFER_E_IO
|
||||
if any error occurs. If an error occurs, no guarantee is made
|
||||
about how much data got written. Callers that can deal with
|
||||
partial writes should call target_write. */
|
||||
MEMADDR. Returns either 0 for success or -1 if any error occurs.
|
||||
If an error occurs, no guarantee is made about how much data got
|
||||
written. Callers that can deal with partial writes should call
|
||||
target_write. */
|
||||
|
||||
int
|
||||
target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
|
||||
@@ -1497,7 +1497,7 @@ target_write_raw_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
|
||||
myaddr, memaddr, len) == len)
|
||||
return 0;
|
||||
else
|
||||
return TARGET_XFER_E_IO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Fetch the target's memory map. */
|
||||
|
||||
Reference in New Issue
Block a user