From: Hans-Peter Nilsson <hp@bitrange.com>
To: gcc-patches@gcc.gnu.org
Subject: Re: [RFA:] Take 2 (was: Re: RFC: --enable-checking=valgrind.)
Date: Wed, 20 Nov 2002 11:57:00 -0000 [thread overview]
Message-ID: <Pine.BSF.4.44.0211201408320.48834-100000@dair.pair.com> (raw)
In-Reply-To: <20021118203717.A3046@redhat.com>
On Mon, 18 Nov 2002, Richard Henderson wrote:
> Updated patch is ok.
Thanks for the review.
On request from Neil, I instead committed this for cppfiles.c,
as an obvious change to the patch. Tested by inspecting
preprocessed output with and without --enable-checking=valgrind
and "manually" checking the expected whitespace change, plus the
expected extra ";" without --enable-checking, compared to the
previous, bootstrapped&checked patch. Also bootstrapped&checked
without --enable-checking=valgrind. New ChangeLog entry for
that file:
* cppfiles.c [!ENABLE_VALGRIND_CHECKING] (VALGRIND_DISCARD):
Define as empty.
(read_include_file): When doing the mmap+1 trick,
valgrind-annotate the byte after the mmap:ed area as readable.
(purge_cache): Remove above annotation.
Index: cppfiles.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppfiles.c,v
retrieving revision 1.156
diff -p -c -r1.156 cppfiles.c
*** cppfiles.c 22 Sep 2002 02:03:16 -0000 1.156
--- cppfiles.c 20 Nov 2002 00:02:38 -0000
*************** Foundation, 59 Temple Place - Suite 330,
*** 27,32 ****
--- 27,38 ----
#include "intl.h"
#include "mkdeps.h"
#include "splay-tree.h"
+ #ifdef ENABLE_VALGRIND_CHECKING
+ #include <valgrind.h>
+ #else
+ /* Avoid #ifdef:s when we can help it. */
+ #define VALGRIND_DISCARD(x)
+ #endif
#ifdef HAVE_MMAP_FILE
# include <sys/mman.h>
*************** read_include_file (pfile, inc)
*** 418,423 ****
--- 424,434 ----
buf = (uchar *) mmap (0, size, PROT_READ, MAP_PRIVATE, inc->fd, 0);
if (buf == (uchar *)-1)
goto perror_fail;
+
+ /* 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));
+
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);
--- 509,522 ----
{
#if MMAP_THRESHOLD
if (inc->mapped)
! {
! /* 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));
! munmap ((PTR) inc->buffer, inc->st.st_size);
! }
else
#endif
free ((PTR) inc->buffer);
brgds, H-P
next prev parent reply other threads:[~2002-11-20 19:57 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-10 17:35 RFC: --enable-checking=valgrind Hans-Peter Nilsson
2002-11-10 19:34 ` Zack Weinberg
2002-11-11 1:55 ` Hans-Peter Nilsson
2002-11-11 16:53 ` Zack Weinberg
2002-11-11 17:48 ` Hans-Peter Nilsson
2002-11-12 6:02 ` Jan Hubicka
2002-11-12 17:11 ` Hans-Peter Nilsson
2002-11-12 17:21 ` Zack Weinberg
2002-11-13 5:32 ` Jan Hubicka
2002-11-13 13:38 ` Hans-Peter Nilsson
2002-11-18 17:20 ` Richard Henderson
2002-11-18 18:24 ` [RFA:] Take 2 (was: Re: RFC: --enable-checking=valgrind.) Hans-Peter Nilsson
2002-11-18 20:37 ` Richard Henderson
2002-11-20 11:57 ` Hans-Peter Nilsson [this message]
2002-11-18 22:12 ` Neil Booth
2002-11-19 4:37 ` Hans-Peter Nilsson
2002-11-18 22:33 ` Andreas Jaeger
2002-11-19 4:33 ` Hans-Peter Nilsson
2002-11-19 7:31 ` Andreas Jaeger
2002-11-19 9:07 ` Hans-Peter Nilsson
2002-11-19 9:15 ` [RFA:] Take 2 Andreas Jaeger
2002-11-26 5:42 ` [PATCH] Fix configure (was Re: [RFA:] Take 2 (was: Re: RFC: --enable-checking=valgrind.)) Jakub Jelinek
2002-11-26 9:59 ` Richard Henderson
2002-11-28 7:34 ` Hans-Peter Nilsson
2002-11-28 8:08 ` Hans-Peter Nilsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.BSF.4.44.0211201408320.48834-100000@dair.pair.com \
--to=hp@bitrange.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).