This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFA:] Take 2 (was: Re: RFC: --enable-checking=valgrind.)
Hans-Peter Nilsson wrote:-
> +
> + #ifdef ENABLE_VALGRIND_CHECKING
> + /* We must tell Valgrind that the byte at buf[size] is actually
> + readable. Discard the handle to avoid handle leak. */
> + VALGRIND_DISCARD (VALGRIND_MAKE_READABLE (buf + size, 1));
> + #endif
> +
> inc->mapped = 1;
> }
> else
> *************** purge_cache (inc)
> *** 498,504 ****
> {
> #if MMAP_THRESHOLD
> if (inc->mapped)
> ! munmap ((PTR) inc->buffer, inc->st.st_size);
> else
> #endif
> free ((PTR) inc->buffer);
> --- 508,523 ----
> {
> #if MMAP_THRESHOLD
> if (inc->mapped)
> ! {
> ! #ifdef ENABLE_VALGRIND_CHECKING
> ! /* Undo the previous annotation for the
> ! known-zero-byte-after-mmap. Discard the handle to avoid
> ! handle leak. */
> ! VALGRIND_DISCARD (VALGRIND_MAKE_NOACCESS (inc->buffer
> ! + inc->st.st_size, 1));
> ! #endif
> ! munmap ((PTR) inc->buffer, inc->st.st_size);
> ! }
To avoid ballooning #ifdef-nastiness, could you (maybe in the #ifdef you
added at the top of the file) add something like
#else
#define VALGRIND_DISCARD(x) /* Ignore. */
and get rid of the conditional compilation in these two places?
Neil.