diff options
author | Mike Frysinger <vapier@gentoo.org> | 2012-08-12 21:56:05 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2012-08-12 21:56:43 -0400 |
commit | 53179a50a1a3e7a21e71cea6de46468deee87c69 (patch) | |
tree | ea636b0cf902e883740f058931426e7b87cb579e /libsandbox/trace.c | |
parent | libsandbox: fix hppa trace code (diff) | |
download | sandbox-53179a50a1a3e7a21e71cea6de46468deee87c69.tar.gz sandbox-53179a50a1a3e7a21e71cea6de46468deee87c69.tar.bz2 sandbox-53179a50a1a3e7a21e71cea6de46468deee87c69.zip |
libsandbox: use process_vm_readv if available
Should speed up loading of strings from remote processes as we only have
to do (usually) one syscall to extract the whole string in one shot.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsandbox/trace.c')
-rw-r--r-- | libsandbox/trace.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libsandbox/trace.c b/libsandbox/trace.c index ea769fd..c38ea12 100644 --- a/libsandbox/trace.c +++ b/libsandbox/trace.c @@ -90,6 +90,32 @@ static char *do_peekstr(unsigned long lptr) if (lptr < sizeof(long)) return NULL; +#ifdef HAVE_PROCESS_VM_READV + struct iovec liov, riov; + + /* We can't cross remote page boundaries when using this :( */ + l = 0x1000; + riov.iov_base = (void *)lptr; + len = lptr % l; + if (!len) + len = l; + liov.iov_base = ret = xmalloc(len); + riov.iov_len = liov.iov_len = len; + + while (1) { + process_vm_readv(trace_pid, &liov, 1, &riov, 1, 0); + + for (i = 0; i < liov.iov_len; ++i) + if (!((char *)liov.iov_base)[i]) + return ret; + riov.iov_base += l; + riov.iov_len = liov.iov_len = l; + len += l; + ret = xrealloc(ret, len); + liov.iov_base = ret + len - l; + } +#endif + l = 0; len = 1024; ret = xmalloc(len); |