From 915215be09d492d167fa2a0d0c4d3f75cfb40157 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 9 Oct 2013 15:55:17 +0000 Subject: [PATCH] monitor.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/ 2013-10-09 Pedro Alves * monitor.c (monitor_write_memory, monitor_write_memory_bytes) (monitor_write_memory_longlongs, monitor_write_memory_block): Constify 'myaddr' parameter. (monitor_xfer_memory): Adjust interface as monitor_xfer_partial helper. (monitor_xfer_partial): New function. (init_base_monitor_ops): Don't install a deprecated_xfer_memory hook. Install a to_xfer_partial hook. --- gdb/ChangeLog | 11 +++++++++++ gdb/monitor.c | 48 +++++++++++++++++++++++++++++++++--------------- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 51f9b43..d2fb999 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,14 @@ +2013-10-09 Pedro Alves + + * monitor.c (monitor_write_memory, monitor_write_memory_bytes) + (monitor_write_memory_longlongs, monitor_write_memory_block): + Constify 'myaddr' parameter. + (monitor_xfer_memory): Adjust interface as monitor_xfer_partial + helper. + (monitor_xfer_partial): New function. + (init_base_monitor_ops): Don't install a deprecated_xfer_memory + hook. Install a to_xfer_partial hook. + 2013-10-09 Tom Tromey * dwarf2read.c (dwarf2_get_dwz_file): Update for type change in diff --git a/gdb/monitor.c b/gdb/monitor.c index d0c9866..08153dd 100644 --- a/gdb/monitor.c +++ b/gdb/monitor.c @@ -1439,7 +1439,7 @@ monitor_files_info (struct target_ops *ops) } static int -monitor_write_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len) +monitor_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len) { enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ()); unsigned int val, hostval; @@ -1542,7 +1542,7 @@ monitor_write_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len) static int -monitor_write_memory_bytes (CORE_ADDR memaddr, gdb_byte *myaddr, int len) +monitor_write_memory_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, int len) { unsigned char val; int written = 0; @@ -1638,7 +1638,7 @@ longlong_hexchars (unsigned long long value, Which possably entails endian conversions. */ static int -monitor_write_memory_longlongs (CORE_ADDR memaddr, gdb_byte *myaddr, int len) +monitor_write_memory_longlongs (CORE_ADDR memaddr, const gdb_byte *myaddr, int len) { static char hexstage[20]; /* At least 16 digits required, plus null. */ char *endstring; @@ -1686,7 +1686,7 @@ monitor_write_memory_longlongs (CORE_ADDR memaddr, gdb_byte *myaddr, int len) monitor variations. */ static int -monitor_write_memory_block (CORE_ADDR memaddr, gdb_byte *myaddr, int len) +monitor_write_memory_block (CORE_ADDR memaddr, const gdb_byte *myaddr, int len) { int written; @@ -2015,31 +2015,49 @@ monitor_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len) return len; } -/* Transfer LEN bytes between target address MEMADDR and GDB address - MYADDR. Returns 0 for success, errno code for failure. TARGET is - unused. */ +/* Helper for monitor_xfer_partial that handles memory transfers. + Arguments are like target_xfer_partial. */ -static int -monitor_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write, - struct mem_attrib *attrib, struct target_ops *target) +static LONGEST +monitor_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf, + ULONGEST memaddr, LONGEST len) { int res; - if (write) + if (writebuf != NULL) { if (current_monitor->flags & MO_HAS_BLOCKWRITES) - res = monitor_write_memory_block(memaddr, myaddr, len); + res = monitor_write_memory_block (memaddr, writebuf, len); else - res = monitor_write_memory(memaddr, myaddr, len); + res = monitor_write_memory (memaddr, writebuf, len); } else { - res = monitor_read_memory(memaddr, myaddr, len); + res = monitor_read_memory (memaddr, readbuf, len); } + if (res == 0) + return TARGET_XFER_E_IO; return res; } +/* Target to_xfer_partial implementation. */ + +static LONGEST +monitor_xfer_partial (struct target_ops *ops, enum target_object object, + const char *annex, gdb_byte *readbuf, + const gdb_byte *writebuf, ULONGEST offset, LONGEST len) +{ + switch (object) + { + case TARGET_OBJECT_MEMORY: + return monitor_xfer_memory (readbuf, writebuf, offset, len); + + default: + return TARGET_XFER_E_IO; + } +} + static void monitor_kill (struct target_ops *ops) { @@ -2344,7 +2362,7 @@ init_base_monitor_ops (void) monitor_ops.to_fetch_registers = monitor_fetch_registers; monitor_ops.to_store_registers = monitor_store_registers; monitor_ops.to_prepare_to_store = monitor_prepare_to_store; - monitor_ops.deprecated_xfer_memory = monitor_xfer_memory; + monitor_ops.to_xfer_partial = monitor_xfer_partial; monitor_ops.to_files_info = monitor_files_info; monitor_ops.to_insert_breakpoint = monitor_insert_breakpoint; monitor_ops.to_remove_breakpoint = monitor_remove_breakpoint; -- 2.7.4