summaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog13
-rw-r--r--gdb/gnu-nat.c66
2 files changed, 59 insertions, 20 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0fadddf2e95..738d757b1f1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,16 @@
+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.
+
2013-09-19 Jan Kratochvil <jan.kratochvil@redhat.com>
Constification.
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;