diff options
author | Pedro Alves <palves@redhat.com> | 2015-10-27 17:25:09 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2015-10-27 17:25:09 +0000 |
commit | d09f2c3fc15dd4491e9cfa455191045c0729a3c3 (patch) | |
tree | d5fcb14b4ba086bfc062bf13b2d6926c4e6d7ed8 /gdb/mips-tdep.c | |
parent | c5192092506e52a5f075b137a36933e42db64563 (diff) | |
download | gdb-d09f2c3fc15dd4491e9cfa455191045c0729a3c3.zip gdb-d09f2c3fc15dd4491e9cfa455191045c0729a3c3.tar.gz gdb-d09f2c3fc15dd4491e9cfa455191045c0729a3c3.tar.bz2 |
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.
Diffstat (limited to 'gdb/mips-tdep.c')
-rw-r--r-- | gdb/mips-tdep.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 7cea832..6b5a1bd 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -1429,12 +1429,12 @@ mips_write_pc (struct regcache *regcache, CORE_ADDR pc) static ULONGEST mips_fetch_instruction (struct gdbarch *gdbarch, - enum mips_isa isa, CORE_ADDR addr, int *statusp) + enum mips_isa isa, CORE_ADDR addr, int *errp) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); gdb_byte buf[MIPS_INSN32_SIZE]; int instlen; - int status; + int err; switch (isa) { @@ -1450,13 +1450,13 @@ mips_fetch_instruction (struct gdbarch *gdbarch, internal_error (__FILE__, __LINE__, _("invalid ISA")); break; } - status = target_read_memory (addr, buf, instlen); - if (statusp != NULL) - *statusp = status; - if (status) + err = target_read_memory (addr, buf, instlen); + if (errp != NULL) + *errp = err; + if (err != 0) { - if (statusp == NULL) - memory_error (status, addr); + if (errp == NULL) + memory_error (TARGET_XFER_E_IO, addr); return 0; } return extract_unsigned_integer (buf, instlen, byte_order); @@ -7118,12 +7118,13 @@ mips_breakpoint_from_pc (struct gdbarch *gdbarch, static gdb_byte micromips16_big_breakpoint[] = { 0x46, 0x85 }; static gdb_byte micromips32_big_breakpoint[] = { 0, 0x5, 0, 0x7 }; ULONGEST insn; - int status; + int err; int size; - insn = mips_fetch_instruction (gdbarch, ISA_MICROMIPS, pc, &status); - size = status ? 2 - : mips_insn_size (ISA_MICROMIPS, insn) == 2 ? 2 : 4; + insn = mips_fetch_instruction (gdbarch, ISA_MICROMIPS, pc, &err); + size = (err != 0 + ? 2 : (mips_insn_size (ISA_MICROMIPS, insn) == 2 + ? 2 : 4)); *pcptr = unmake_compact_addr (pc); *lenptr = size; return (size == 2) ? micromips16_big_breakpoint |