From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10734 invoked by alias); 20 Feb 2013 15:24:29 -0000 Received: (qmail 10710 invoked by uid 22791); 20 Feb 2013 15:24:27 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_BM X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 20 Feb 2013 15:24:21 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1KFNdg5023136 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 20 Feb 2013 10:23:39 -0500 Received: from host2.jankratochvil.net (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r1KFNVWv030089 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 20 Feb 2013 10:23:34 -0500 Date: Wed, 20 Feb 2013 15:24:00 -0000 From: Jan Kratochvil To: Pedro Alves Cc: Philippe Waroquiers , gdb-patches@sourceware.org Subject: [patch+NEWS] Avoid false valgrind warnings on linux_ptrace_test_ret_to_nx Message-ID: <20130220152331.GA16617@host2.jankratochvil.net> References: <20130220140520.GA10822@host2.jankratochvil.net> <5124E66D.3060606@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5124E66D.3060606@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-02/txt/msg00534.txt.bz2 On Wed, 20 Feb 2013 16:06:21 +0100, Pedro Alves wrote: > That reminds us that ideally new configury options are all > advertised in NEWS. Yes; forgot it. > I assumed there'd be a reason for the more complete test, > instead of a simpler and unconditional > AC_CHECK_HEADERS(valgrind/valgrind.h) and then just > > #ifdef RUNNING_ON_VALGRIND > if (RUNNING_ON_VALGRIND) > return; > #endif > > As in, you had found that older valgrind/valgrind.h's didn't > have that RUNNING_ON_VALGRIND macro. I haven't found such valgrind. The reason is there could be a broken valgrind.h include file installed. As GDB built before not depending on such file in the past and now it would break it would be a regression. Or is somewhere a rule what should and what should not be tested by configure? Thanks, Jan gdb/ 2013-02-20 Jan Kratochvil * NEWS (--with-valgrind/--without-valgrind): New. * acinclude.m4: Include common/acinclude.m4. * common/acinclude.m4: New file. * common/linux-ptrace.c : Include valgrind/valgrind.h. (linux_ptrace_test_ret_to_nx) : Return. * config.in: Regenerate. * configure: Regenerate. * configure.ac: Call GDB_AC_CHECK_VALGRIND. gdb/gdbserver/ 2013-02-20 Jan Kratochvil * acinclude.m4: Include ../common/acinclude.m4. * config.in: Regenerate. * configure: Regenerate. * configure.ac: Call GDB_AC_CHECK_VALGRIND. diff --git a/gdb/NEWS b/gdb/NEWS index 0877aa2..3e11229 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -79,6 +79,15 @@ Lynx 178 PowerPC powerpc-*-lynx*178 by default. The --enable-libmcheck/--disable-libmcheck configure options allow the user to override that default. +--with-valgrind/--without-valgrind + Include special support when GDB itself runs under valgrind. Without this + support valgrind will report a warning on linux_ptrace_test_ret_to_nx which + is not a bug in GDB. Include file needs to be + installed for this support. Include file is autodetected by default. Using + --with-valgrind aborts the configure script if the valgrind include file is + not installed. --without-valgrind omits the support in GDB even if the + include file is installed. + * New commands (for set/show, see "New options" below) catch signal diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4 index 25caddd..12da851 100644 --- a/gdb/acinclude.m4 +++ b/gdb/acinclude.m4 @@ -49,6 +49,8 @@ sinclude([../config/codeset.m4]) sinclude([../config/zlib.m4]) +sinclude([common/acinclude.m4]) + ## ----------------------------------------- ## ## ANSIfy the C compiler whenever possible. ## ## From Franc,ois Pinard ## diff --git a/gdb/common/acinclude.m4 b/gdb/common/acinclude.m4 new file mode 100644 index 0000000..fcb1c71 --- /dev/null +++ b/gdb/common/acinclude.m4 @@ -0,0 +1,44 @@ +# Copyright 2013 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +dnl GDB_AC_CHECK_VALGRIND +dnl Check for HAVE_RUNNING_ON_VALGRIND. +dnl If such symbol is defined is also available. +AC_DEFUN([GDB_AC_CHECK_VALGRIND], [ + AC_ARG_WITH([valgrind], + [AS_HELP_STRING([--without-valgrind], + [do not include support for running-on-valgrind detection])],, + [with_valgrind=check]) + if test "$with_valgrind" != no; then + AC_MSG_CHECKING([for RUNNING_ON_VALGRIND macro]) + AC_CACHE_VAL(gdb_cv_check_running_on_valgrind, [ + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[return RUNNING_ON_VALGRIND;]])], + [gdb_cv_check_running_on_valgrind=yes], + [gdb_cv_check_running_on_valgrind=no])]) + AC_MSG_RESULT($gdb_cv_check_running_on_valgrind) + if test "$gdb_cv_check_running_on_valgrind" = yes; then + with_valgrind=yes + elif test "$with_valgrind" = yes; then + AC_ERROR( + [--with-valgrind was requested but was not found]) + fi + fi + if test "$with_valgrind" = yes; then + AC_DEFINE(HAVE_RUNNING_ON_VALGRIND, 1, + [Define if you have and RUNNING_ON_VALGRIND.]) + fi +]) diff --git a/gdb/common/linux-ptrace.c b/gdb/common/linux-ptrace.c index 886be80..97a314b 100644 --- a/gdb/common/linux-ptrace.c +++ b/gdb/common/linux-ptrace.c @@ -29,6 +29,10 @@ #include "gdb_assert.h" #include "gdb_wait.h" +#ifdef HAVE_RUNNING_ON_VALGRIND +# include +#endif + /* Find all possible reasons we could fail to attach PID and append these newline terminated reason strings to initialized BUFFER. '\0' termination of BUFFER must be done by the caller. */ @@ -76,6 +80,15 @@ linux_ptrace_test_ret_to_nx (void) long l; int status; + /* Below we'll mmap a non-executable page, which under Valgrind + results in annoying warnings such as + "Bad permissions for mapped region at address 0xfoobar". + Just skip the whole test if running under Valgrind. */ +#ifdef HAVE_RUNNING_ON_VALGRIND + if (RUNNING_ON_VALGRIND) + return; +#endif + return_address = mmap (NULL, 2, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (return_address == MAP_FAILED) diff --git a/gdb/configure.ac b/gdb/configure.ac index e501766..a7bac76 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -1166,6 +1166,7 @@ AC_CHECK_FUNCS([canonicalize_file_name realpath getrusage getuid getgid \ ttrace wborder wresize setlocale iconvlist libiconvlist btowc \ setrlimit getrlimit posix_madvise waitpid lstat]) AM_LANGINFO_CODESET +GDB_AC_CHECK_VALGRIND # Check the return and argument types of ptrace. No canned test for # this, so roll our own. diff --git a/gdb/gdbserver/acinclude.m4 b/gdb/gdbserver/acinclude.m4 index 0e0bdc8..c5a93b7 100644 --- a/gdb/gdbserver/acinclude.m4 +++ b/gdb/gdbserver/acinclude.m4 @@ -12,6 +12,8 @@ sinclude(../../config/acx.m4) m4_include(../../config/depstand.m4) m4_include(../../config/lead-dot.m4) +sinclude([../common/acinclude.m4]) + dnl Check for existence of a type $1 in libthread_db.h dnl Based on BFD_HAVE_SYS_PROCFS_TYPE in bfd/bfd.m4. diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac index 55fb461..d492e8b 100644 --- a/gdb/gdbserver/configure.ac +++ b/gdb/gdbserver/configure.ac @@ -71,6 +71,7 @@ AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl linux/perf_event.h) AC_CHECK_FUNCS(pread pwrite pread64 readlink) AC_REPLACE_FUNCS(vasprintf vsnprintf) +GDB_AC_CHECK_VALGRIND # Check for UST ustlibs=""