summaryrefslogtreecommitdiff
path: root/memcheck/mc_main.c
diff options
context:
space:
mode:
authorsewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9>2006-03-10 13:41:58 +0000
committersewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9>2006-03-10 13:41:58 +0000
commitfb1e9ada13f0c46f84f3562d48213e8288cc135f (patch)
treecf92df22d4da7d3d9afe4916493cb70e802774fc /memcheck/mc_main.c
parent63daa8afee0bf09c5527975d14f884d98ee77f9e (diff)
Add a new kind of memory-painting primitive, which is: 'make_defined'.
For each byte in the range, if the byte is addressible, make it be initialised, but if it isn't addressible, leave it alone. So it's like a version of make_readable which doesn't alter addressibility. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5736 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'memcheck/mc_main.c')
-rw-r--r--memcheck/mc_main.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c
index f63986b5..20192ef8 100644
--- a/memcheck/mc_main.c
+++ b/memcheck/mc_main.c
@@ -741,6 +741,22 @@ static void mc_make_readable ( Addr a, SizeT len )
set_address_range_perms ( a, len, VGM_BIT_VALID, VGM_BIT_VALID );
}
+/* For each byte in [a,a+len), if the byte is addressable, make it be
+ defined, but if it isn't addressible, leave it alone. In other
+ words a version of mc_make_readable that doesn't mess with
+ addressibility. Low-performance implementation. */
+static void mc_make_defined ( Addr a, SizeT len )
+{
+ SizeT i;
+ UWord abit, vbyte;
+ DEBUG("mc_make_defined(%p, %llu)\n", a, (ULong)len);
+ for (i = 0; i < len; i++) {
+ get_abit_and_vbyte( &abit, &vbyte, a+i );
+ if (EXPECTED_TAKEN(abit == VGM_BIT_VALID))
+ set_vbyte(a+i, VGM_BYTE_VALID);
+ }
+}
+
/* --- Block-copy permissions (needed for implementing realloc() and
sys_mremap). --- */
@@ -2519,6 +2535,11 @@ static Bool mc_handle_client_request ( ThreadId tid, UWord* arg, UWord* ret )
*ret = -1;
break;
+ case VG_USERREQ__MAKE_DEFINED: /* make defined */
+ mc_make_defined ( arg[1], arg[2] );
+ *ret = -1;
+ break;
+
case VG_USERREQ__CREATE_BLOCK: /* describe a block */
if (arg[1] != 0 && arg[2] != 0) {
i = alloc_client_block();