From: Julian Seward Date: Tue, 22 Oct 2002 05:05:49 +0000 (+0000) Subject: Merge patch from Jeremy Fitzhardinge: X-Git-Tag: svn/VALGRIND_1_9_4~190 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=277bf259c6793fae44b319d8ec0bc9d3d5f37247;p=thirdparty%2Fvalgrind.git Merge patch from Jeremy Fitzhardinge: 20-hg-secmap HELGRIND: fix bugs causing a torrent of "access to distingished map" messages. There were two: one is some absurdly broken rounding/padding code in set_address_range_state() (how did anything work!?). The other was some odd looking code in the tracking of attaching shared memory segments. Since they're semantically very similar to mmap, track them as such. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1257 --- diff --git a/coregrind/vg_syscalls.c b/coregrind/vg_syscalls.c index 7d1a48fe05..4fb58c4689 100644 --- a/coregrind/vg_syscalls.c +++ b/coregrind/vg_syscalls.c @@ -86,10 +86,10 @@ void mmap_segment ( Addr a, UInt len, UInt prot, Int fd ) Bool nn, rr, ww, xx; /* Records segment, reads debug symbols if necessary */ - if (prot & PROT_EXEC && fd != -1) + if ((prot & PROT_EXEC) && fd != -1) VG_(new_exe_segment) ( a, len ); - nn = prot & PROT_NONE; + nn = False; /* PROT_NONE == 0; was = prot & PROT_NONE. */ rr = prot & PROT_READ; ww = prot & PROT_WRITE; xx = prot & PROT_EXEC; @@ -1778,7 +1778,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( post_mem_write, addr, segmentSize ); + VG_TRACK( new_mem_mmap, addr, segmentSize, False, True, True, False ); } } break; diff --git a/helgrind/hg_main.c b/helgrind/hg_main.c index f625396fa9..75b1b64797 100644 --- a/helgrind/hg_main.c +++ b/helgrind/hg_main.c @@ -760,7 +760,7 @@ static void set_address_range_state ( Addr a, UInt len /* in bytes */, VgeInitStatus status ) { - Addr aligned_a, end, aligned_end; + Addr end; # if DEBUG_MAKE_ACCESSES VG_(printf)("make_access: 0x%x, %u, status=%u\n", a, len, status); @@ -782,12 +782,8 @@ void set_address_range_state ( Addr a, UInt len /* in bytes */, * len/4+1 words. This works out which it is by aligning the block and * seeing if the end byte is in the same word as it is for the unaligned * block; if not, it's the awkward case. */ - aligned_a = a & 0xc; /* zero bottom two bits */ - end = a + len; - aligned_end = aligned_a + len; - if ((end & 0xc) != (aligned_end & 0xc)) { - end += 4; /* len/4 + 1 case */ - } + end = (a + len + 3) & ~3; /* round up */ + a &= ~3; /* round down */ /* Do it ... */ switch (status) { @@ -1256,6 +1252,7 @@ static void record_eraser_error ( ThreadState *tst, Addr a, Bool is_write, shadow_word prevstate ) { HelgrindError err_extra; + static const shadow_word err_sw = { TID_INDICATING_ALL, Vge_Excl }; clear_HelgrindError(&err_extra); err_extra.isWrite = is_write; @@ -1266,12 +1263,7 @@ static void record_eraser_error ( ThreadState *tst, Addr a, Bool is_write, (is_write ? "writing" : "reading"), &err_extra); - /* Put location into error state to suppress future warnings */ - { - shadow_word *sword = get_sword_addr(a); - sword->state = Vge_Excl; - sword->other = TID_INDICATING_ALL; - } + set_sword(a, err_sw); } static void record_mutex_error(ThreadId tid, hg_mutex_t *mutex,