summaryrefslogtreecommitdiffstats
path: root/sys/mips
diff options
context:
space:
mode:
authormarkj <markj@FreeBSD.org>2015-12-07 21:33:15 +0000
committermarkj <markj@FreeBSD.org>2015-12-07 21:33:15 +0000
commitf734f97f4eae5074772d9168c3337517648369ad (patch)
tree395bb015ca7c3a283ed4a6f10d9206628be6e3f3 /sys/mips
parent7f1d362dac9d67803ca7ba38b1e2fd8ff43ae14f (diff)
downloadFreeBSD-src-f734f97f4eae5074772d9168c3337517648369ad.zip
FreeBSD-src-f734f97f4eae5074772d9168c3337517648369ad.tar.gz
Add helper functions proc_readmem() and proc_writemem().
These helper functions can be used to read in or write a buffer from or to an arbitrary process' address space. Without them, this can only be done using proc_rwmem(), which requires the caller to fill out a uio. This is onerous and results in code duplication; the new functions provide a simpler interface which is sufficient for most existing callers of proc_rwmem(). This change also adds a manual page for proc_rwmem() and the new functions. Reviewed by: jhb, kib Differential Revision: https://reviews.freebsd.org/D4245
Diffstat (limited to 'sys/mips')
-rw-r--r--sys/mips/mips/pm_machdep.c36
1 files changed, 8 insertions, 28 deletions
diff --git a/sys/mips/mips/pm_machdep.c b/sys/mips/mips/pm_machdep.c
index d5f6df0..9bccaec 100644
--- a/sys/mips/mips/pm_machdep.c
+++ b/sys/mips/mips/pm_machdep.c
@@ -214,39 +214,19 @@ ptrace_set_pc(struct thread *td, unsigned long addr)
static int
ptrace_read_int(struct thread *td, off_t addr, int *v)
{
- struct iovec iov;
- struct uio uio;
-
- PROC_LOCK_ASSERT(td->td_proc, MA_NOTOWNED);
- iov.iov_base = (caddr_t) v;
- iov.iov_len = sizeof(int);
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
- uio.uio_offset = (off_t)addr;
- uio.uio_resid = sizeof(int);
- uio.uio_segflg = UIO_SYSSPACE;
- uio.uio_rw = UIO_READ;
- uio.uio_td = td;
- return proc_rwmem(td->td_proc, &uio);
+
+ if (proc_readmem(td, td->td_proc, addr, v, sizeof(*v)) != sizeof(*v))
+ return (ENOMEM);
+ return (0);
}
static int
ptrace_write_int(struct thread *td, off_t addr, int v)
{
- struct iovec iov;
- struct uio uio;
-
- PROC_LOCK_ASSERT(td->td_proc, MA_NOTOWNED);
- iov.iov_base = (caddr_t) &v;
- iov.iov_len = sizeof(int);
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
- uio.uio_offset = (off_t)addr;
- uio.uio_resid = sizeof(int);
- uio.uio_segflg = UIO_SYSSPACE;
- uio.uio_rw = UIO_WRITE;
- uio.uio_td = td;
- return proc_rwmem(td->td_proc, &uio);
+
+ if (proc_writemem(td, td->td_proc, addr, &v, sizeof(v)) != sizeof(v))
+ return (ENOMEM);
+ return (0);
}
int
OpenPOWER on IntegriCloud