static int procfs_can_run (struct target_ops *self);
-static int procfs_xfer_memory (CORE_ADDR, gdb_byte *, int, int,
- struct mem_attrib *attrib,
- struct target_ops *);
-
static void init_procfs_ops (void);
static ptid_t do_attach (ptid_t ptid);
nto_supply_altregset (regcache, (char *) ®.altreg);
}
-/* Copy LEN bytes to/from inferior's memory starting at MEMADDR
- from/to debugger memory starting at MYADDR. Copy from inferior
- if DOWRITE is zero or to inferior if DOWRITE is nonzero.
+/* Helper for procfs_xfer_partial that handles memory transfers.
+ Arguments are like target_xfer_partial. */
- Returns the length copied, which is either the LEN argument or
- zero. This xfer function does not do partial moves, since procfs_ops
- doesn't allow memory operations to cross below us in the target stack
- anyway. */
-static int
-procfs_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int dowrite,
- struct mem_attrib *attrib, struct target_ops *target)
+static enum target_xfer_status
+procfs_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf,
+ ULONGEST memaddr, ULONGEST len, ULONGEST *xfered_len)
{
- int nbytes = 0;
+ int nbytes;
+
+ if (lseek (ctl_fd, (off_t) memaddr, SEEK_SET) != (off_t) memaddr)
+ return TARGET_XFER_E_IO;
+
+ if (writebuf != NULL)
+ nbytes = write (ctl_fd, writebuf, len);
+ else
+ nbytes = read (ctl_fd, readbuf, len);
+ if (nbytes <= 0)
+ return TARGET_XFER_E_IO;
+ *xfered_len = nbytes;
+ return TARGET_XFER_OK;
+}
+
+/* Target to_xfer_partial implementation. */
- if (lseek (ctl_fd, (off_t) memaddr, SEEK_SET) == (off_t) memaddr)
+static enum target_xfer_status
+procfs_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)
{
- if (dowrite)
- nbytes = write (ctl_fd, myaddr, len);
- else
- nbytes = read (ctl_fd, myaddr, len);
- if (nbytes < 0)
- nbytes = 0;
+ case TARGET_OBJECT_MEMORY:
+ return procfs_xfer_memory (readbuf, writebuf, offset, len, xfered_len);
+ default:
+ return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
+ readbuf, writebuf, offset, len);
}
- return (nbytes);
}
/* Take a program previously attached to and detaches it.
procfs_ops.to_fetch_registers = procfs_fetch_registers;
procfs_ops.to_store_registers = procfs_store_registers;
procfs_ops.to_prepare_to_store = procfs_prepare_to_store;
- procfs_ops.deprecated_xfer_memory = procfs_xfer_memory;
+ procfs_ops.to_xfer_partial = procfs_xfer_partial;
procfs_ops.to_files_info = procfs_files_info;
procfs_ops.to_insert_breakpoint = procfs_insert_breakpoint;
procfs_ops.to_remove_breakpoint = procfs_remove_breakpoint;