From: Julian Seward Date: Wed, 23 Oct 2002 21:46:13 +0000 (+0000) Subject: Merge patch from Jeremy Fitzhardinge: X-Git-Tag: svn/VALGRIND_1_9_4~184 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7240057bc8c5ddf0d8dc619c367e376cbd9d91d5;p=thirdparty%2Fvalgrind.git Merge patch from Jeremy Fitzhardinge: 14-hg-mmap-magic-virgin This does two things: 1. change the signatures of the new_mem_mmap and change_mem_mprotect functions to remove the pointless 'nn' argument. This makes them match the signature of new_mem_startup... 2. change helgrind to mark memory created by mmap as if it were the same as other magically pre-inited memory. Implement this by pointing helgrind's new_mem_mmap function at new_mem_startup. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1263 --- diff --git a/addrcheck/ac_main.c b/addrcheck/ac_main.c index 23d1d08556..bf0da4f067 100644 --- a/addrcheck/ac_main.c +++ b/addrcheck/ac_main.c @@ -1317,10 +1317,10 @@ void addrcheck_new_mem_heap ( Addr a, UInt len, Bool is_inited ) static void addrcheck_set_perms (Addr a, UInt len, - Bool nn, Bool rr, Bool ww, Bool xx) + Bool rr, Bool ww, Bool xx) { - DEBUG("addrcheck_set_perms(%p, %u, nn=%u, rr=%u ww=%u, xx=%u)\n", - a, len, nn, rr, ww, xx); + DEBUG("addrcheck_set_perms(%p, %u, rr=%u ww=%u, xx=%u)\n", + a, len, rr, ww, xx); if (rr || ww || xx) { SK_(make_accessible)(a, len); } else { diff --git a/coregrind/vg_syscalls.c b/coregrind/vg_syscalls.c index 4fb58c4689..9da32761a5 100644 --- a/coregrind/vg_syscalls.c +++ b/coregrind/vg_syscalls.c @@ -83,18 +83,17 @@ void mash_addr_and_len( Addr* a, UInt* len) static void mmap_segment ( Addr a, UInt len, UInt prot, Int fd ) { - Bool nn, rr, ww, xx; + Bool rr, ww, xx; /* Records segment, reads debug symbols if necessary */ if ((prot & PROT_EXEC) && fd != -1) VG_(new_exe_segment) ( a, len ); - nn = False; /* PROT_NONE == 0; was = prot & PROT_NONE. */ rr = prot & PROT_READ; ww = prot & PROT_WRITE; xx = prot & PROT_EXEC; - VG_TRACK( new_mem_mmap, a, len, nn, rr, ww, xx ); + VG_TRACK( new_mem_mmap, a, len, rr, ww, xx ); } static @@ -123,8 +122,8 @@ void munmap_segment ( Addr a, UInt len ) static void mprotect_segment ( Addr a, UInt len, Int prot ) { - Bool nn, rr, ww, xx; - nn = prot & PROT_NONE; + Bool rr, ww, xx; + rr = prot & PROT_READ; ww = prot & PROT_WRITE; xx = prot & PROT_EXEC; @@ -133,7 +132,7 @@ void mprotect_segment ( Addr a, UInt len, Int prot ) // if adding, should check and add to exe_seg list // easier to ignore both cases -- both v. unlikely? mash_addr_and_len(&a, &len); - VG_TRACK( change_mem_mprotect, a, len, nn, rr, ww, xx ); + VG_TRACK( change_mem_mprotect, a, len, rr, ww, xx ); } static @@ -162,7 +161,7 @@ void mremap_segment ( old_addr, old_size, new_addr, new_size ) // what should the permissions on the new extended part be?? // using 'rwx' VG_TRACK( new_mem_mmap, new_addr+old_size, new_size-old_size, - False, True, True, True ); + True, True, True ); } } @@ -1778,7 +1777,7 @@ void VG_(perform_assumed_nonblocking_syscall) ( ThreadId tid ) if ( segmentSize > 0 ) { /* we don't distinguish whether it's read-only or * read-write -- it doesn't matter really. */ - VG_TRACK( new_mem_mmap, addr, segmentSize, False, True, True, False ); + VG_TRACK( new_mem_mmap, addr, segmentSize, True, True, False ); } } break; diff --git a/helgrind/hg_main.c b/helgrind/hg_main.c index 8d0b0e7770..206152ce6e 100644 --- a/helgrind/hg_main.c +++ b/helgrind/hg_main.c @@ -915,7 +915,7 @@ void eraser_new_mem_heap ( Addr a, UInt len, Bool is_inited ) static void eraser_set_perms (Addr a, UInt len, - Bool nn, Bool rr, Bool ww, Bool xx) + Bool rr, Bool ww, Bool xx) { if (rr) make_readable(a, len); else if (ww) make_writable(a, len); @@ -1916,7 +1916,7 @@ void SK_(pre_clo_init)(VgDetails* details, VgNeeds* needs, VgTrackEvents* track) track->new_mem_stack_aligned = & make_writable_aligned; track->new_mem_stack_signal = & make_writable; track->new_mem_brk = & make_writable; - track->new_mem_mmap = & eraser_set_perms; + track->new_mem_mmap = & eraser_new_mem_startup; track->copy_mem_heap = & copy_address_range_state; track->change_mem_mprotect = & eraser_set_perms; diff --git a/include/vg_skin.h b/include/vg_skin.h index 4a06beeb19..819d1539ff 100644 --- a/include/vg_skin.h +++ b/include/vg_skin.h @@ -1277,13 +1277,11 @@ typedef void (*new_mem_stack_aligned) ( Addr a, UInt len ); void (*new_mem_stack_signal) ( Addr a, UInt len ); void (*new_mem_brk) ( Addr a, UInt len ); - void (*new_mem_mmap) ( Addr a, UInt len, - Bool nn, Bool rr, Bool ww, Bool xx ); + void (*new_mem_mmap) ( Addr a, UInt len, Bool rr, Bool ww, Bool xx ); void (*copy_mem_heap) ( Addr from, Addr to, UInt len ); void (*copy_mem_remap) ( Addr from, Addr to, UInt len ); - void (*change_mem_mprotect) ( Addr a, UInt len, - Bool nn, Bool rr, Bool ww, Bool xx ); + void (*change_mem_mprotect) ( Addr a, UInt len, Bool rr, Bool ww, Bool xx ); /* Used on redzones around malloc'd blocks and at end of stack */ void (*ban_mem_heap) ( Addr a, UInt len ); diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c index 42710b04ee..2484c1337e 100644 --- a/memcheck/mc_main.c +++ b/memcheck/mc_main.c @@ -889,10 +889,10 @@ void memcheck_new_mem_heap ( Addr a, UInt len, Bool is_inited ) static void memcheck_set_perms (Addr a, UInt len, - Bool nn, Bool rr, Bool ww, Bool xx) + Bool rr, Bool ww, Bool xx) { - DEBUG("memcheck_set_perms(%p, %u, nn=%u, rr=%u ww=%u, xx=%u)\n", - a, len, nn, rr, ww, xx); + DEBUG("memcheck_set_perms(%p, %u, rr=%u ww=%u, xx=%u)\n", + a, len, rr, ww, xx); if (rr) SK_(make_readable)(a, len); else if (ww) SK_(make_writable)(a, len); else SK_(make_noaccess)(a, len);