diff options
author | tschwinge <tschwinge> | 2013-09-19 13:40:38 +0000 |
---|---|---|
committer | tschwinge <tschwinge> | 2013-09-19 13:40:38 +0000 |
commit | 4ba2b67ec67221fc9e61a89fe2ab6c2624253d22 (patch) | |
tree | f1c07d9e5bcba3881a86cca3e8033d21929b1356 /gdb/gnu-nat.c | |
parent | bf70f69596aebfe8c461c3b95e4e38adbf834860 (diff) | |
download | gdb-4ba2b67ec67221fc9e61a89fe2ab6c2624253d22.tar.gz |
gnu-nat.c: Don't install a deprecated_xfer_memory method.
This removes another instance of a deprecated_xfer_memory user.
gdb/
2013-09-19 Pedro Alves <palves@redhat.com>
Thomas Schwinge <thomas@codesourcery.com>
Yue Lu <hacklu.newborn@gmail.com>
* gnu-nat.c (gnu_read_inferior, gnu_write_inferior): Make static.
Take a gdb_byte pointer instead of a char pointer.
* gnu-nat.c (gnu_xfer_memory): Adjust interface as
gnu_xfer_partial helper.
(gnu_xfer_partial): New function.
(gnu_target): Don't install a deprecated_xfer_memory hook.
Install a to_xfer_partial hook.
Diffstat (limited to 'gdb/gnu-nat.c')
-rw-r--r-- | gdb/gnu-nat.c | 66 |
1 files changed, 46 insertions, 20 deletions
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index b4f99f81ce8..b99f5570ec1 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2268,8 +2268,8 @@ gnu_thread_alive (struct target_ops *ops, ptid_t ptid) /* Read inferior task's LEN bytes from ADDR and copy it to MYADDR in gdb's address space. Return 0 on failure; number of bytes read otherwise. */ -int -gnu_read_inferior (task_t task, CORE_ADDR addr, char *myaddr, int length) +static int +gnu_read_inferior (task_t task, CORE_ADDR addr, gdb_byte *myaddr, int length) { error_t err; vm_address_t low_address = (vm_address_t) trunc_page (addr); @@ -2314,8 +2314,9 @@ struct obstack region_obstack; /* Write gdb's LEN bytes from MYADDR and copy it to ADDR in inferior task's address space. */ -int -gnu_write_inferior (task_t task, CORE_ADDR addr, char *myaddr, int length) +static int +gnu_write_inferior (task_t task, CORE_ADDR addr, + const gdb_byte *myaddr, int length) { error_t err = 0; vm_address_t low_address = (vm_address_t) trunc_page (addr); @@ -2471,30 +2472,55 @@ out: } -/* Return 0 on failure, number of bytes handled otherwise. TARGET - is ignored. */ -static int -gnu_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write, - struct mem_attrib *attrib, - struct target_ops *target) + +/* Helper for gnu_xfer_partial that handles memory transfers. */ + +static LONGEST +gnu_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf, + CORE_ADDR memaddr, LONGEST len) { task_t task = (gnu_current_inf ? (gnu_current_inf->task ? gnu_current_inf->task->port : 0) : 0); + int res; if (task == MACH_PORT_NULL) - return 0; + return TARGET_XFER_E_IO; + + if (writebuf != NULL) + { + inf_debug (gnu_current_inf, "writing %s[%s] <-- %s", + paddress (target_gdbarch (), memaddr), plongest (len), + host_address_to_string (writebuf)); + res = gnu_write_inferior (task, memaddr, writebuf, len); + } else { - inf_debug (gnu_current_inf, "%s %s[%d] %s %s", - write ? "writing" : "reading", - paddress (target_gdbarch (), memaddr), len, - write ? "<--" : "-->", host_address_to_string (myaddr)); - if (write) - return gnu_write_inferior (task, memaddr, myaddr, len); - else - return gnu_read_inferior (task, memaddr, myaddr, len); + inf_debug (gnu_current_inf, "reading %s[%s] --> %s", + paddress (target_gdbarch (), memaddr), plongest (len), + host_address_to_string (readbuf)); + res = gnu_read_inferior (task, memaddr, readbuf, len); + } + if (res == 0) + return TARGET_XFER_E_IO; + return res; +} + +/* Target to_xfer_partial implementation. */ + +static LONGEST +gnu_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 gnu_xfer_memory (readbuf, writebuf, offset, len); + + default: + return -1; } } @@ -2628,7 +2654,7 @@ gnu_target (void) t->to_detach = gnu_detach; t->to_resume = gnu_resume; t->to_wait = gnu_wait; - t->deprecated_xfer_memory = gnu_xfer_memory; + t->to_xfer_partial = gnu_xfer_partial; t->to_find_memory_regions = gnu_find_memory_regions; t->to_terminal_init = gnu_terminal_init_inferior; t->to_kill = gnu_kill_inferior; |