From: Pedro Alves Date: Wed, 26 Feb 2014 14:36:03 +0000 (+0000) Subject: remote-mips.c: Don't install a deprecated_xfer_memory method X-Git-Tag: gdb-7.8-release~982 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6df1b29f02837669d68b8f153b189502e798a302;p=external%2Fbinutils.git remote-mips.c: Don't install a deprecated_xfer_memory method This removes another yet instance of a deprecated_xfer_memory user. Tested by building a --enable-targets=all gdb, on x86-64 Fedora 17. gdb/ 2014-02-26 Pedro Alves * remote-mips.c (mips_xfer_memory): Adjust as to_xfer_partial helper. (mips_xfer_partial): New function. (_initialize_remote_mips): Don't install a deprecated_xfer_memory hook. Install a to_xfer_partial hook. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a4377a9..821ec53 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2014-02-26 Pedro Alves + + * remote-mips.c (mips_xfer_memory): Adjust as to_xfer_partial + helper. + (mips_xfer_partial): New function. + (_initialize_remote_mips): Don't install a deprecated_xfer_memory + hook. Install a to_xfer_partial hook. + 2014-02-26 Joel Brobecker * gdbtypes.h (create_array_type_with_stride): Add declaration. diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c index 4338ffa..383d31c 100644 --- a/gdb/remote-mips.c +++ b/gdb/remote-mips.c @@ -98,10 +98,11 @@ static int mips_fetch_word (CORE_ADDR addr, unsigned int *valp); static int mips_store_word (CORE_ADDR addr, unsigned int value, int *old_contents); -static int mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, - int write, - struct mem_attrib *attrib, - struct target_ops *target); +static enum target_xfer_status mips_xfer_memory (gdb_byte *readbuf, + const gdb_byte *writebuf, + ULONGEST memaddr, + ULONGEST len, + ULONGEST *xfered_len); static void mips_files_info (struct target_ops *ignore); @@ -2141,18 +2142,17 @@ mips_store_word (CORE_ADDR addr, unsigned int val, int *old_contents) return 0; } -/* Read or write LEN bytes from inferior memory at MEMADDR, - transferring to or from debugger address MYADDR. Write to inferior - if SHOULD_WRITE is nonzero. Returns length of data written or - read; 0 for error. Note that protocol gives us the correct value - for a longword, since it transfers values in ASCII. We want the - byte values, so we have to swap the longword values. */ +/* Helper for mips_xfer_partial that handles memory transfers. + Arguments are like target_xfer_partial. Note that the protocol + gives us the correct value for a longword, since it transfers + values in ASCII. We want the byte values, so we have to swap the + longword values. */ static int mask_address_p = 1; -static int -mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write, - struct mem_attrib *attrib, struct target_ops *target) +static enum target_xfer_status +mips_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf, + ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len) { enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); int i; @@ -2173,7 +2173,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write, /* Allocate buffer of that many longwords. */ buffer = alloca (count * 4); - if (write) + if (writebuf != NULL) { /* Fill start and end extra bytes of buffer with existing data. */ if (addr != memaddr || len < 4) @@ -2181,7 +2181,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write, unsigned int val; if (mips_fetch_word (addr, &val)) - return 0; + return TARGET_XFER_E_IO; /* Need part of initial word -- fetch it. */ store_unsigned_integer (&buffer[0], 4, byte_order, val); @@ -2194,7 +2194,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write, /* Need part of last word -- fetch it. FIXME: we do this even if we don't need it. */ if (mips_fetch_word (addr + (count - 1) * 4, &val)) - return 0; + return TARGET_XFER_E_IO; store_unsigned_integer (&buffer[(count - 1) * 4], 4, byte_order, val); @@ -2202,7 +2202,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write, /* Copy data to be written over corresponding part of buffer. */ - memcpy ((char *) buffer + (memaddr & 3), myaddr, len); + memcpy ((char *) buffer + (memaddr & 3), writebuf, len); /* Write the entire buffer. */ @@ -2219,10 +2219,7 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write, gdb_flush (gdb_stdout); } if (status) - { - errno = status; - return 0; - } + return TARGET_XFER_E_IO; /* FIXME: Do we want a QUIT here? */ } if (count >= 256) @@ -2236,18 +2233,38 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write, unsigned int val; if (mips_fetch_word (addr, &val)) - return 0; + return TARGET_XFER_E_IO; store_unsigned_integer (&buffer[i * 4], 4, byte_order, val); QUIT; } /* Copy appropriate bytes out of the buffer. */ - memcpy (myaddr, buffer + (memaddr & 3), len); + memcpy (readbuf, buffer + (memaddr & 3), len); } return len; } +/* Target to_xfer_partial implementation. */ + +static enum target_xfer_status +mips_xfer_partial (struct target_ops *ops, enum target_object object, + const char *annex, gdb_byte *readbuf, + const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, + ULONGEST *xfered_len) +{ + switch (object) + { + case TARGET_OBJECT_MEMORY: + return mips_xfer_memory (readbuf, writebuf, offset, len, xfered_len); + + default: + return ops->beneath->to_xfer_partial (ops->beneath, object, annex, + readbuf, writebuf, offset, len, + xfered_len); + } +} + /* Print info on this target. */ static void @@ -3623,7 +3640,7 @@ _initialize_remote_mips (void) mips_ops.to_fetch_registers = mips_fetch_registers; mips_ops.to_store_registers = mips_store_registers; mips_ops.to_prepare_to_store = mips_prepare_to_store; - mips_ops.deprecated_xfer_memory = mips_xfer_memory; + mips_ops.to_xfer_partial = mips_xfer_partial; mips_ops.to_files_info = mips_files_info; mips_ops.to_insert_breakpoint = mips_insert_breakpoint; mips_ops.to_remove_breakpoint = mips_remove_breakpoint;