summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortimurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-26 20:45:49 +0000
committertimurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-26 20:45:49 +0000
commit102d398c226ad6e741569900b8a77c8b7083e652 (patch)
treee9acc6cdc56d925ced1549df8cbdda1e9b3927de
parent425c270648ba5c7ed37fc8db8d659a54f5406f71 (diff)
downloadchromium_src-102d398c226ad6e741569900b8a77c8b7083e652.zip
chromium_src-102d398c226ad6e741569900b8a77c8b7083e652.tar.gz
chromium_src-102d398c226ad6e741569900b8a77c8b7083e652.tar.bz2
Remove old Valgrind build scripts and patches.
Review URL: http://codereview.chromium.org/543213 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37151 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-xtools/valgrind/build-valgrind-for-chromium.sh215
-rw-r--r--tools/valgrind/fork.patch386
-rw-r--r--tools/valgrind/intercept_tcmalloc.patch235
-rw-r--r--tools/valgrind/possible.patch56
-rw-r--r--tools/valgrind/redzone.patch13
-rw-r--r--tools/valgrind/vbug205541.patch21
-rw-r--r--tools/valgrind/vbug210481.patch14
-rw-r--r--tools/valgrind/xml-loadadr.patch13
8 files changed, 6 insertions, 947 deletions
diff --git a/tools/valgrind/build-valgrind-for-chromium.sh b/tools/valgrind/build-valgrind-for-chromium.sh
index ec1fa77..d0b2e28 100755
--- a/tools/valgrind/build-valgrind-for-chromium.sh
+++ b/tools/valgrind/build-valgrind-for-chromium.sh
@@ -1,211 +1,8 @@
#!/bin/sh
-# Copyright (c) 2009 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Script to build valgrind for use with chromium
-#
-# Can also be used to just prepare patched source tarball with MAKE_TARBALL=yes
-# or to just build from a patched source tarball with USE_TARBALL=yes.
-# These are useful when configuring jailed buildbots which are not allowed to
-# fetch valgrind source via svn. Most users won't need those options.
-
-# Checkout by date doesn't work unless you specify the friggin' timezone
-VALGRIND_SVN_REV=10880
-# And svn isn't smart enough to figure out what rev of the linked tree to get
-VEX_SVN_REV=1914
-# and TSAN may be out of sync, so you have to check that out by rev anyway
-TSAN_SVN_REV=1274
-
-# suffix for build and install dir to denote our set of patches (may be empty)
-PATCHLEVEL=-redzone
-
-DIRNAME=valgrind-${VALGRIND_SVN_REV}${PATCHLEVEL}
-
-THISDIR=$(dirname "${0}")
-THISDIR=$(cd "${THISDIR}" && /bin/pwd)
-
-case "x${1}" in
-x|x/*) ;;
-*)
- echo "Usage: sh build-valgrind-for-chromium.sh [prefix]"
- echo "Prefix is optional, but if present, must be the absolute path to where"
- echo "you want to install valgrind's bin, include, and lib directories."
- echo "Prefix defaults to /usr/local/$DIRNAME."
- echo "Will use sudo to do the install if you don't own the parent of prefix."
- exit 1
- ;;
-esac
-
-set -x
-set -e
-
-if test "x${USE_TARBALL}" = "xyes" && test "x${MAKE_TARBALL}" = "xyes"
-then
- echo Set only one of MAKE_TARBALL or USE_TARBALL to yes
- exit 1
-fi
-
-# Clean checkout our untar
-test -d "$DIRNAME" && rm -rf ./"$DIRNAME"
-mkdir -p "$DIRNAME"
-
-if test "x${USE_TARBALL}" != "xyes"
-then
- # Check out latest version that following patches known to apply against
- svn co -r "${VALGRIND_SVN_REV}" "svn://svn.valgrind.org/valgrind/trunk" "$DIRNAME"
-
- cd "$DIRNAME"
-
- # Make sure svn gets the right version of the external VEX repo, too
- svn update -r "${VEX_SVN_REV}" VEX/
-
- # Work around bug https://bugs.kde.org/show_bug.cgi?id=162848
- # "fork() not handled properly"
- patch -p0 < "${THISDIR}/fork.patch"
-
- # Add feature bug https://bugs.kde.org/show_bug.cgi?id=201170
- # "Want --show-possible option so I can ignore the bazillion possible leaks..."
- patch -p0 < "${THISDIR}/possible.patch"
-
- # Add feature bug https://bugs.kde.org/show_bug.cgi?id=205000
- # "Need library load address in log files"
- patch -p0 < "${THISDIR}/xml-loadadr.patch"
-
- # Make red zone 64 bytes bigger to catch more buffer overruns
- patch -p0 < "${THISDIR}/redzone.patch"
-
- # Fix/work around https://bugs.kde.org/show_bug.cgi?id=210481
- # which prevented valgrind from handling v8 on 64 bits
- patch -p0 < "${THISDIR}/vbug210481.patch"
-
- # Fix/work around https://bugs.kde.org/show_bug.cgi?id=205541
- # which prevented valgrind from handling wine
- patch -p0 < "${THISDIR}/vbug205541.patch"
-
- # Add intercepts for tcmalloc memory functions.
- # The corresponding feature request for Valgrind is at
- # https://bugs.kde.org/show_bug.cgi?id=219156.
- patch -p0 < "${THISDIR}/intercept_tcmalloc.patch"
-
-
- if [ "${INSTALL_TSAN}" = "yes" ]
- then
- # Add ThreadSanitier to the installation.
- # ThreadSanitizer is an experimental dynamic data race detector.
- # See http://code.google.com/p/data-race-test/wiki/ThreadSanitizer
- svn checkout -r "${TSAN_SVN_REV}" http://data-race-test.googlecode.com/svn/trunk/tsan tsan
- mkdir tsan/tests
- touch tsan/tests/Makefile.am
- patch -p 0 < tsan/valgrind.patch
- fi
-
- sh autogen.sh
- if test -L install-sh
- then
- # replace symlink with actual contents!
- cp install-sh install-sh.new
- mv -f install-sh.new install-sh
- chmod +x install-sh
- fi
-
- # MacOSX before Snow Leopoard needs newer gdb to be able to handle -O1 chrome
- # Kludgily download and unpack the sources in a subdirectory.
- if test `uname` = Darwin || test "x${MAKE_TARBALL}" = "xyes"
- then
- curl http://www.opensource.apple.com/tarballs/gdb/gdb-1344.tar.gz | tar -xzf -
- fi
- cd ..
-
-fi
-
-if test "x${MAKE_TARBALL}" = "xyes"
-then
- tar -czvf "$DIRNAME".tgz "$DIRNAME"
-fi
-
-if test "x${USE_TARBALL}" = "xyes"
-then
- tar -xzvf "$DIRNAME".tgz
-fi
-
-if test "x${MAKE_TARBALL}" != "xyes"
-then
- cd "$DIRNAME"
-
- OVERRIDE_LD_DIR="${THISDIR}/override_ld"
- if ld --version | grep gold
- then
- # build/install-build-deps leaves original ld around, try using that
- if test -x /usr/bin/ld.orig
- then
- echo "Using /usr/bin/ld.orig instead of gold to link valgrind"
- test -d "${OVERRIDE_LD_DIR}" && rm -rf "${OVERRIDE_LD_DIR}"
- mkdir "${OVERRIDE_LD_DIR}"
- ln -s /usr/bin/ld.orig "${OVERRIDE_LD_DIR}/ld"
- PATH="${OVERRIDE_LD_DIR}:${PATH}"
- # Ubuntu diverts original ld to ld.single when it installs binutils-gold
- elif test -x /usr/bin/ld.single
- then
- echo "Using /usr/bin/ld.single instead of gold to link valgrind"
- test -d "${OVERRIDE_LD_DIR}" && rm -rf "${OVERRIDE_LD_DIR}"
- mkdir "${OVERRIDE_LD_DIR}"
- ln -s /usr/bin/ld.single "${OVERRIDE_LD_DIR}/ld"
- PATH="${OVERRIDE_LD_DIR}:${PATH}"
- else
- echo "Cannot build valgrind with gold. Please switch to normal /usr/bin/ld, rerun this script, then switch back to gold."
- exit 1
- fi
- fi
-
- # Desired parent directory for valgrind's bin, include, etc.
- PREFIX="${1:-/usr/local/$DIRNAME}"
- parent_of_prefix=$(dirname "${PREFIX}")
- if test ! -d "${parent_of_prefix}"
- then
- echo "Directory ${parent_of_prefix} does not exist"
- exit 1
- fi
-
- ./configure --prefix="${PREFIX}"
- make -j4
-
- if ./vg-in-place true
- then
- echo built valgrind passes smoke test, good
- else
- echo built valgrind fails smoke test
- exit 1
- fi
-
- test -d "${OVERRIDE_LD_DIR}" && rm -rf "${OVERRIDE_LD_DIR}"
-
- # Build and install gdb if needed
- case `uname` in
- Darwin)
- cd gdb-1344/src
- ./configure --prefix="${PREFIX}"
- # gdb makefile is not yet parallel-safe
- make
- if test -w "${parent_of_prefix}"
- then
- make install
- else
- sudo make install
- fi
- cd ../..
- ;;
- esac
-
- # Finally install valgrind.
- # Don't use sudo if we own the destination
- if test -w "${parent_of_prefix}"
- then
- make install
- else
- sudo make install
- fi
-
- cd ..
-fi
+# If you see this code during a merge conflict, you should probably re-apply
+# your local changes to deps/third_party/valgrind/scripts
+echo "This script has been deprecated! Please see"
+echo "http://sites.google.com/a/chromium.org/dev/developers/how-tos/using-valgrind/building-valgrind"
+echo "for the new instructions on building Valgrind"
+exit 1
diff --git a/tools/valgrind/fork.patch b/tools/valgrind/fork.patch
deleted file mode 100644
index 9802318..0000000
--- a/tools/valgrind/fork.patch
+++ /dev/null
@@ -1,386 +0,0 @@
-Index: coregrind/m_syswrap/syswrap-generic.c
-===================================================================
---- coregrind/m_syswrap/syswrap-generic.c (revision 10880)
-+++ coregrind/m_syswrap/syswrap-generic.c (working copy)
-@@ -2563,6 +2563,11 @@
-
- } else {
- path = (Char*)ARG1;
-+ if (VG_(clo_xml)) {
-+ VG_(printf_xml)("\n<execv/>\n\n</valgrindoutput>\n\n");
-+ } else {
-+ VG_(umsg)("execv called - the tool will now quit\n");
-+ }
- }
-
- // Set up the child's environment.
-@@ -4103,4 +4108,3 @@
- /*--------------------------------------------------------------------*/
- /*--- end ---*/
- /*--------------------------------------------------------------------*/
--
-Index: coregrind/pub_core_libcfile.h
-===================================================================
---- coregrind/pub_core_libcfile.h (revision 10880)
-+++ coregrind/pub_core_libcfile.h (working copy)
-@@ -41,6 +41,7 @@
-
- /* Move an fd into the Valgrind-safe range */
- extern Int VG_(safe_fd) ( Int oldfd );
-+extern Int reopen_output_fd(Bool xml);
- extern Int VG_(fcntl) ( Int fd, Int cmd, Addr arg );
-
- /* Convert an fd into a filename */
-Index: coregrind/m_main.c
-===================================================================
---- coregrind/m_main.c (revision 10880)
-+++ coregrind/m_main.c (working copy)
-@@ -313,6 +313,64 @@
- }
- }
-
-+Int reopen_output_fd(Bool xml) {
-+ // Returns FD
-+ Char *filename = NULL;
-+ Char *fsname_unexpanded = xml ? VG_(clo_xml_fname_unexpanded) :
-+ VG_(clo_log_fname_unexpanded);
-+ const Char *output_type = xml ? "xml" : "log";
-+ Int ret = -1;
-+ SysRes sres;
-+
-+ vg_assert(fsname_unexpanded != NULL);
-+ vg_assert(VG_(strlen)(fsname_unexpanded) <= 900); /* paranoia */
-+
-+ // Nb: we overwrite an existing file of this name without asking
-+ // any questions.
-+ filename = VG_(expand_file_name)(xml ? "--xml-file" : "--log-file",
-+ fsname_unexpanded);
-+ sres = VG_(open)(filename,
-+ VKI_O_CREAT|VKI_O_WRONLY|VKI_O_TRUNC,
-+ VKI_S_IRUSR|VKI_S_IWUSR);
-+ if (!sr_isError(sres)) {
-+ ret = sr_Res(sres);
-+ if (xml)
-+ VG_(clo_xml_fname_expanded) = filename;
-+ else
-+ VG_(clo_log_fname_expanded) = filename;
-+
-+ /* strdup here is probably paranoid overkill, but ... */
-+ // TODO: do we need to do anything with it?
-+ /* *fsname_unexpanded = VG_(strdup)( "main.mpclo.2",
-+ xml_fsname_unexpanded ); */
-+ } else {
-+ VG_(message)(Vg_UserMsg,
-+ "Can't create %s file '%s' (%s); giving up!\n",
-+ output_type, filename, VG_(strerror)(sr_Err(sres)));
-+ VG_(err_bad_option)(
-+ "--[xml|log]-file=<file> (didn't work out for some reason.)");
-+ /*NOTREACHED*/
-+ }
-+
-+ return ret;
-+}
-+
-+static Int move_fd_into_safe_range(Int fd, Bool xml) {
-+ OutputSink *sink = xml ? &(VG_(xml_output_sink)) : &(VG_(log_output_sink));
-+ // Move fd into the safe range, so it doesn't conflict with any app fds.
-+ fd = VG_(fcntl)(fd, VKI_F_DUPFD, VG_(fd_hard_limit));
-+ if (fd < 0) {
-+ VG_(printf)("valgrind: failed to move %s file fd "
-+ "into safe range, using stderr\n", xml ? "XML" : "log");
-+ sink->fd = 2; // stderr
-+ sink->is_socket = False;
-+ } else {
-+ sink->fd = fd;
-+ VG_(fcntl)(fd, VKI_F_SETFD, VKI_FD_CLOEXEC);
-+ }
-+ return fd;
-+}
-+
- /* The main processing for command line options. See comments above
- on early_process_cmd_line_options.
-
-@@ -339,13 +397,11 @@
- */
- static
- void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd,
-- /*OUT*/Char** xml_fname_unexpanded,
- const HChar* toolname )
- {
- // VG_(clo_log_fd) is used by all the messaging. It starts as 2 (stderr)
- // and we cannot change it until we know what we are changing it to is
- // ok. So we have tmp_log_fd to hold the tmp fd prior to that point.
-- SysRes sres;
- Int i, tmp_log_fd, tmp_xml_fd;
- Int toolname_len = VG_(strlen)(toolname);
- Char* tmp_str; // Used in a couple of places.
-@@ -514,9 +570,13 @@
-
- else if VG_STR_CLO(arg, "--log-file", log_fsname_unexpanded) {
- log_to = VgLogTo_File;
-+ VG_(clo_log_fname_unexpanded) =
-+ VG_(strdup)("", log_fsname_unexpanded);
- }
- else if VG_STR_CLO(arg, "--xml-file", xml_fsname_unexpanded) {
- xml_to = VgLogTo_File;
-+ VG_(clo_xml_fname_unexpanded) =
-+ VG_(strdup)("", xml_fsname_unexpanded);
- }
-
- else if VG_STR_CLO(arg, "--log-socket", log_fsname_unexpanded) {
-@@ -716,29 +776,7 @@
- break;
-
- case VgLogTo_File: {
-- Char* logfilename;
--
-- vg_assert(log_fsname_unexpanded != NULL);
-- vg_assert(VG_(strlen)(log_fsname_unexpanded) <= 900); /* paranoia */
--
-- // Nb: we overwrite an existing file of this name without asking
-- // any questions.
-- logfilename = VG_(expand_file_name)("--log-file",
-- log_fsname_unexpanded);
-- sres = VG_(open)(logfilename,
-- VKI_O_CREAT|VKI_O_WRONLY|VKI_O_TRUNC,
-- VKI_S_IRUSR|VKI_S_IWUSR);
-- if (!sr_isError(sres)) {
-- tmp_log_fd = sr_Res(sres);
-- VG_(clo_log_fname_expanded) = logfilename;
-- } else {
-- VG_(message)(Vg_UserMsg,
-- "Can't create log file '%s' (%s); giving up!\n",
-- logfilename, VG_(strerror)(sr_Err(sres)));
-- VG_(err_bad_option)(
-- "--log-file=<file> (didn't work out for some reason.)");
-- /*NOTREACHED*/
-- }
-+ tmp_log_fd = reopen_output_fd(False);
- break;
- }
-
-@@ -784,32 +822,7 @@
- break;
-
- case VgLogTo_File: {
-- Char* xmlfilename;
--
-- vg_assert(xml_fsname_unexpanded != NULL);
-- vg_assert(VG_(strlen)(xml_fsname_unexpanded) <= 900); /* paranoia */
--
-- // Nb: we overwrite an existing file of this name without asking
-- // any questions.
-- xmlfilename = VG_(expand_file_name)("--xml-file",
-- xml_fsname_unexpanded);
-- sres = VG_(open)(xmlfilename,
-- VKI_O_CREAT|VKI_O_WRONLY|VKI_O_TRUNC,
-- VKI_S_IRUSR|VKI_S_IWUSR);
-- if (!sr_isError(sres)) {
-- tmp_xml_fd = sr_Res(sres);
-- VG_(clo_xml_fname_expanded) = xmlfilename;
-- /* strdup here is probably paranoid overkill, but ... */
-- *xml_fname_unexpanded = VG_(strdup)( "main.mpclo.2",
-- xml_fsname_unexpanded );
-- } else {
-- VG_(message)(Vg_UserMsg,
-- "Can't create XML file '%s' (%s); giving up!\n",
-- xmlfilename, VG_(strerror)(sr_Err(sres)));
-- VG_(err_bad_option)(
-- "--xml-file=<file> (didn't work out for some reason.)");
-- /*NOTREACHED*/
-- }
-+ tmp_xml_fd = reopen_output_fd(True);
- break;
- }
-
-@@ -864,18 +877,7 @@
- // Finalise the output fds: the log fd ..
-
- if (tmp_log_fd >= 0) {
-- // Move log_fd into the safe range, so it doesn't conflict with
-- // any app fds.
-- tmp_log_fd = VG_(fcntl)(tmp_log_fd, VKI_F_DUPFD, VG_(fd_hard_limit));
-- if (tmp_log_fd < 0) {
-- VG_(message)(Vg_UserMsg, "valgrind: failed to move logfile fd "
-- "into safe range, using stderr\n");
-- VG_(log_output_sink).fd = 2; // stderr
-- VG_(log_output_sink).is_socket = False;
-- } else {
-- VG_(log_output_sink).fd = tmp_log_fd;
-- VG_(fcntl)(VG_(log_output_sink).fd, VKI_F_SETFD, VKI_FD_CLOEXEC);
-- }
-+ tmp_log_fd = move_fd_into_safe_range(tmp_log_fd, False);
- } else {
- // If they said --log-fd=-1, don't print anything. Plausible for use in
- // regression testing suites that use client requests to count errors.
-@@ -886,18 +888,7 @@
- // Finalise the output fds: and the XML fd ..
-
- if (tmp_xml_fd >= 0) {
-- // Move xml_fd into the safe range, so it doesn't conflict with
-- // any app fds.
-- tmp_xml_fd = VG_(fcntl)(tmp_xml_fd, VKI_F_DUPFD, VG_(fd_hard_limit));
-- if (tmp_xml_fd < 0) {
-- VG_(message)(Vg_UserMsg, "valgrind: failed to move XML file fd "
-- "into safe range, using stderr\n");
-- VG_(xml_output_sink).fd = 2; // stderr
-- VG_(xml_output_sink).is_socket = False;
-- } else {
-- VG_(xml_output_sink).fd = tmp_xml_fd;
-- VG_(fcntl)(VG_(xml_output_sink).fd, VKI_F_SETFD, VKI_FD_CLOEXEC);
-- }
-+ tmp_xml_fd = move_fd_into_safe_range(tmp_xml_fd, True);
- } else {
- // If they said --xml-fd=-1, don't print anything. Plausible for use in
- // regression testing suites that use client requests to count errors.
-@@ -989,9 +980,12 @@
- If logging to file or a socket, write details of parent PID and
- command line args, to help people trying to interpret the
- results of a run which encompasses multiple processes. */
--static void print_preamble ( Bool logging_to_fd,
-- Char* xml_fname_unexpanded,
-- const HChar* toolname )
-+// TODO(timurrrr): we add a non-static declaration of this function since
-+// we need it in coregrind/m_libcproc.c
-+// Should we move it to some header file?
-+void print_preamble ( Bool logging_to_fd, const HChar* toolname );
-+
-+void print_preamble ( Bool logging_to_fd, const HChar* toolname )
- {
- Int i;
- HChar* xpre = VG_(clo_xml) ? " <line>" : "";
-@@ -999,9 +993,15 @@
- UInt (*umsg_or_xml)( const HChar*, ... )
- = VG_(clo_xml) ? VG_(printf_xml) : VG_(umsg);
-
-+ static const char* last_toolname = NULL;
- vg_assert( VG_(args_for_client) );
- vg_assert( VG_(args_for_valgrind) );
-+
-+ // This way you may pass toolname == NULL provided the first invocation
-+ // with toolname != NULL takes place in valgrind_main().
-+ toolname = (toolname == NULL ? last_toolname : toolname);
- vg_assert( toolname );
-+ last_toolname = toolname;
-
- if (VG_(clo_xml)) {
- VG_(printf_xml)("<?xml version=\"1.0\"?>\n");
-@@ -1013,7 +1013,7 @@
- VG_(printf_xml)("\n");
- }
-
-- if (VG_(clo_xml) || VG_(clo_verbosity > 0)) {
-+ if (VG_(clo_xml) || VG_(clo_verbosity) > 0) {
-
- if (VG_(clo_xml))
- VG_(printf_xml)("<preamble>\n");
-@@ -1067,6 +1067,7 @@
- }
- else
- if (VG_(clo_xml)) {
-+ Char *xml_fname_unexpanded = VG_(clo_xml_fname_unexpanded);
- VG_(printf_xml)("\n");
- VG_(printf_xml)("<pid>%d</pid>\n", VG_(getpid)());
- VG_(printf_xml)("<ppid>%d</ppid>\n", VG_(getppid)());
-@@ -1374,7 +1375,6 @@
- Int need_help = 0; // 0 = no, 1 = --help, 2 = --help-debug
- ThreadId tid_main = VG_INVALID_THREADID;
- Bool logging_to_fd = False;
-- Char* xml_fname_unexpanded = NULL;
- Int loglevel, i;
- struct vki_rlimit zero = { 0, 0 };
- XArray* addr2dihandle = NULL;
-@@ -1872,8 +1872,7 @@
- VG_(debugLog)(1, "main",
- "(main_) Process Valgrind's command line options, "
- "setup logging\n");
-- main_process_cmd_line_options ( &logging_to_fd, &xml_fname_unexpanded,
-- toolname );
-+ main_process_cmd_line_options ( &logging_to_fd, toolname );
-
- //--------------------------------------------------------------
- // Zeroise the millisecond counter by doing a first read of it.
-@@ -1886,10 +1885,10 @@
- // p: tl_pre_clo_init [for 'VG_(details).name' and friends]
- // p: main_process_cmd_line_options()
- // [for VG_(clo_verbosity), VG_(clo_xml),
-- // logging_to_fd, xml_fname_unexpanded]
-+ // logging_to_fd]
- //--------------------------------------------------------------
- VG_(debugLog)(1, "main", "Print the preamble...\n");
-- print_preamble(logging_to_fd, xml_fname_unexpanded, toolname);
-+ print_preamble(logging_to_fd, toolname);
- VG_(debugLog)(1, "main", "...finished the preamble\n");
-
- //--------------------------------------------------------------
-Index: coregrind/m_libcproc.c
-===================================================================
---- coregrind/m_libcproc.c (revision 10880)
-+++ coregrind/m_libcproc.c (working copy)
-@@ -33,9 +33,12 @@
- #include "pub_core_vkiscnums.h"
- #include "pub_core_libcbase.h"
- #include "pub_core_libcassert.h"
-+#include "pub_core_libcfile.h"
- #include "pub_core_libcprint.h"
- #include "pub_core_libcproc.h"
- #include "pub_core_libcsignal.h"
-+#include "pub_core_tooliface.h"
-+#include "pub_core_options.h"
- #include "pub_core_seqmatch.h"
- #include "pub_core_mallocfree.h"
- #include "pub_core_syscall.h"
-@@ -708,10 +711,39 @@
- (*atforks[i].parent)(tid);
- }
-
-+// Defined in m_main.c
-+void print_preamble(Bool logging_to_fd, const char* toolname);
-+
-+Char* VG_(clo_log_fname_unexpanded) = NULL;
-+Char* VG_(clo_xml_fname_unexpanded) = NULL;
-+
-+// If --log-file=ABC%pXYZ is specified, we'd like to have separate log files
-+// for each forked child.
-+// If %p is present in the --log-file option, this function creates
-+// a new log file and redirects the child's output to it.
-+static void open_new_logfile_for_forked_child(void)
-+{
-+ Int tmp_fd = -1;
-+
-+ if (VG_(log_output_sink).is_socket == False && VG_(clo_log_fname_unexpanded) != NULL) {
-+ tmp_fd = reopen_output_fd(False);
-+ VG_(log_output_sink).fd = VG_(safe_fd)(tmp_fd);
-+ }
-+
-+ if (VG_(xml_output_sink).is_socket == False && VG_(clo_xml_fname_unexpanded) != NULL) {
-+ tmp_fd = reopen_output_fd(True);
-+ VG_(xml_output_sink).fd = VG_(safe_fd)(tmp_fd);
-+ }
-+
-+ print_preamble(False, NULL);
-+}
-+
- void VG_(do_atfork_child)(ThreadId tid)
- {
- Int i;
-
-+ open_new_logfile_for_forked_child();
-+
- for (i = 0; i < n_atfork; i++)
- if (atforks[i].child != NULL)
- (*atforks[i].child)(tid);
-Index: coregrind/pub_core_options.h
-===================================================================
---- coregrind/pub_core_options.h (revision 10880)
-+++ coregrind/pub_core_options.h (working copy)
-@@ -74,6 +74,9 @@
- extern Char* VG_(clo_log_fname_expanded);
- extern Char* VG_(clo_xml_fname_expanded);
-
-+extern Char* VG_(clo_log_fname_unexpanded);
-+extern Char* VG_(clo_xml_fname_unexpanded);
-+
- /* Add timestamps to log messages? default: NO */
- extern Bool VG_(clo_time_stamp);
-
diff --git a/tools/valgrind/intercept_tcmalloc.patch b/tools/valgrind/intercept_tcmalloc.patch
deleted file mode 100644
index 3f47556..0000000
--- a/tools/valgrind/intercept_tcmalloc.patch
+++ /dev/null
@@ -1,235 +0,0 @@
-Index: coregrind/m_replacemalloc/vg_replace_malloc.c
-===================================================================
---- coregrind/m_replacemalloc/vg_replace_malloc.c (revision 10880)
-+++ coregrind/m_replacemalloc/vg_replace_malloc.c (working copy)
-@@ -193,6 +193,18 @@
- // malloc
- ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, malloc, malloc);
- ALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc, malloc);
-+// Handle libtcmalloc's malloc() function.
-+// Similar interceptors are added below to handle other libtcmalloc
-+// allocation/deallocation functions.
-+// soname=NONE means that a user's allocation function is intercepted.
-+ALLOC_or_NULL(NONE, malloc, malloc);
-+// Bash has sh_malloc() and sh_free() along with standard malloc() and free().
-+// Sometimes these functions are called inconsistently (e.g. free() after
-+// sh_malloc()). To deal with this we have to intercept the sh_*() functions
-+// as well.
-+ALLOC_or_NULL(NONE, sh_malloc, malloc);
-+// Handle Python's malloc.
-+ALLOC_or_NULL(NONE, PyObject_Malloc, malloc);
- #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
- ALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc_common, malloc);
- #elif defined(VGO_darwin)
-@@ -205,20 +217,24 @@
- // operator new(unsigned int), not mangled (for gcc 2.96)
- ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, builtin_new, __builtin_new);
- ALLOC_or_BOMB(VG_Z_LIBC_SONAME, builtin_new, __builtin_new);
-+ALLOC_or_BOMB(NONE, builtin_new, __builtin_new);
-
- ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, __builtin_new, __builtin_new);
- ALLOC_or_BOMB(VG_Z_LIBC_SONAME, __builtin_new, __builtin_new);
-+ALLOC_or_BOMB(NONE, __builtin_new, __builtin_new);
-
- // operator new(unsigned int), GNU mangling
- #if VG_WORDSIZE == 4
- ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znwj, __builtin_new);
- ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znwj, __builtin_new);
-+ ALLOC_or_BOMB(NONE, _Znwj, __builtin_new);
- #endif
-
- // operator new(unsigned long), GNU mangling
- #if VG_WORDSIZE == 8 || defined(VGP_ppc32_aix5) || defined(VGO_darwin)
- ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znwm, __builtin_new);
- ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znwm, __builtin_new);
-+ ALLOC_or_BOMB(NONE, _Znwm, __builtin_new);
- #endif
-
- // operator new(unsigned long), ARM/cfront mangling
-@@ -233,12 +249,14 @@
- #if VG_WORDSIZE == 4
- ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnwjRKSt9nothrow_t, __builtin_new);
- ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnwjRKSt9nothrow_t, __builtin_new);
-+ ALLOC_or_NULL(NONE, _ZnwjRKSt9nothrow_t, __builtin_new);
- #endif
-
- // operator new(unsigned long, std::nothrow_t const&), GNU mangling
- #if VG_WORDSIZE == 8 || defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) || defined(VGO_darwin)
- ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnwmRKSt9nothrow_t, __builtin_new);
- ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnwmRKSt9nothrow_t, __builtin_new);
-+ ALLOC_or_NULL(NONE, _ZnwmRKSt9nothrow_t, __builtin_new);
- #endif
-
- // operator new(unsigned long, std::nothrow_t const&), ARM/cfront mangling
-@@ -252,17 +270,20 @@
- // operator new[](unsigned int), not mangled (for gcc 2.96)
- ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, __builtin_vec_new, __builtin_vec_new );
- ALLOC_or_BOMB(VG_Z_LIBC_SONAME, __builtin_vec_new, __builtin_vec_new );
-+ALLOC_or_BOMB(NONE, __builtin_vec_new, __builtin_vec_new );
-
- // operator new[](unsigned int), GNU mangling
- #if VG_WORDSIZE == 4
- ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znaj, __builtin_vec_new );
- ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znaj, __builtin_vec_new );
-+ ALLOC_or_BOMB(NONE, _Znaj, __builtin_vec_new );
- #endif
-
- // operator new[](unsigned long), GNU mangling
- #if VG_WORDSIZE == 8 || defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) || defined(VGO_darwin)
- ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znam, __builtin_vec_new );
- ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znam, __builtin_vec_new );
-+ ALLOC_or_BOMB(NONE, _Znam, __builtin_vec_new );
- #endif
-
- // operator new[](unsigned long), ARM/cfront mangling
-@@ -277,12 +298,14 @@
- #if VG_WORDSIZE == 4
- ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnajRKSt9nothrow_t, __builtin_vec_new );
- ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnajRKSt9nothrow_t, __builtin_vec_new );
-+ ALLOC_or_NULL(NONE, _ZnajRKSt9nothrow_t, __builtin_vec_new );
- #endif
-
- // operator new[](unsigned long, std::nothrow_t const&), GNU mangling
- #if VG_WORDSIZE == 8 || defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5) || defined(VGO_darwin)
- ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnamRKSt9nothrow_t, __builtin_vec_new );
- ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnamRKSt9nothrow_t, __builtin_vec_new );
-+ ALLOC_or_NULL(NONE, _ZnamRKSt9nothrow_t, __builtin_vec_new );
- #endif
-
- // operator new [](unsigned long, std::nothrow_t const&), ARM/cfront mangling
-@@ -323,6 +346,9 @@
- // free
- FREE(VG_Z_LIBSTDCXX_SONAME, free, free );
- FREE(VG_Z_LIBC_SONAME, free, free );
-+FREE(NONE, free, free );
-+FREE(NONE, sh_free, free );
-+FREE(NONE, PyObject_Free, free );
- #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
- FREE(VG_Z_LIBC_SONAME, free_common, free );
- #elif defined(VGO_darwin)
-@@ -335,16 +361,20 @@
- // cfree
- FREE(VG_Z_LIBSTDCXX_SONAME, cfree, free );
- FREE(VG_Z_LIBC_SONAME, cfree, free );
-+FREE(NONE, cfree, free );
-+FREE(NONE, sh_cfree, free );
-
-
- /*---------------------- delete ----------------------*/
- // operator delete(void*), not mangled (for gcc 2.96)
- FREE(VG_Z_LIBSTDCXX_SONAME, __builtin_delete, __builtin_delete );
- FREE(VG_Z_LIBC_SONAME, __builtin_delete, __builtin_delete );
-+FREE(NONE, __builtin_delete, __builtin_delete );
-
- // operator delete(void*), GNU mangling
- FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPv, __builtin_delete );
- FREE(VG_Z_LIBC_SONAME, _ZdlPv, __builtin_delete );
-+FREE(NONE, _ZdlPv, __builtin_delete );
-
- // operator delete(void*), ARM/cfront mangling
- #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
-@@ -357,16 +387,19 @@
- // operator delete(void*, std::nothrow_t const&), GNU mangling
- FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvRKSt9nothrow_t, __builtin_delete );
- FREE(VG_Z_LIBC_SONAME, _ZdlPvRKSt9nothrow_t, __builtin_delete );
-+FREE(NONE, _ZdlPvRKSt9nothrow_t, __builtin_delete );
-
-
- /*---------------------- delete [] ----------------------*/
- // operator delete[](void*), not mangled (for gcc 2.96)
- FREE(VG_Z_LIBSTDCXX_SONAME, __builtin_vec_delete, __builtin_vec_delete );
- FREE(VG_Z_LIBC_SONAME, __builtin_vec_delete, __builtin_vec_delete );
-+FREE(NONE, __builtin_vec_delete, __builtin_vec_delete );
-
- // operator delete[](void*), GNU mangling
- FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPv, __builtin_vec_delete );
- FREE(VG_Z_LIBC_SONAME, _ZdaPv, __builtin_vec_delete );
-+FREE(NONE, _ZdaPv, __builtin_vec_delete );
-
- // operator delete[](void*), ARM/cfront mangling
- #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
-@@ -379,6 +412,7 @@
- // operator delete[](void*, std::nothrow_t const&), GNU mangling
- FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete );
- FREE(VG_Z_LIBC_SONAME, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete );
-+FREE(NONE, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete );
-
-
- /*---------------------- calloc ----------------------*/
-@@ -416,6 +450,8 @@
- }
-
- CALLOC(VG_Z_LIBC_SONAME, calloc);
-+CALLOC(NONE, calloc);
-+CALLOC(NONE, sh_calloc);
- #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
- CALLOC(VG_Z_LIBC_SONAME, calloc_common);
- #elif defined(VGO_darwin)
-@@ -474,6 +510,9 @@
- }
-
- REALLOC(VG_Z_LIBC_SONAME, realloc);
-+REALLOC(NONE, realloc);
-+REALLOC(NONE, sh_realloc);
-+REALLOC(NONE, PyObject_Realloc);
- #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
- REALLOC(VG_Z_LIBC_SONAME, realloc_common);
- #elif defined(VGO_darwin)
-@@ -530,6 +569,8 @@
- }
-
- MEMALIGN(VG_Z_LIBC_SONAME, memalign);
-+MEMALIGN(NONE, memalign);
-+MEMALIGN(NONE, sh_memalign);
- #if defined(VGO_darwin)
- ZONEMEMALIGN(VG_Z_LIBC_SONAME, malloc_zone_memalign);
- #endif
-@@ -572,6 +613,8 @@
- }
-
- VALLOC(VG_Z_LIBC_SONAME, valloc);
-+VALLOC(NONE, valloc);
-+VALLOC(NONE, sh_valloc);
- #if defined(VGO_darwin)
- ZONEVALLOC(VG_Z_LIBC_SONAME, malloc_zone_valloc);
- #endif
-@@ -592,6 +635,7 @@
- }
-
- MALLOPT(VG_Z_LIBC_SONAME, mallopt);
-+MALLOPT(NONE, mallopt);
-
-
- /*---------------------- malloc_trim ----------------------*/
-@@ -628,6 +672,7 @@
- }
-
- MALLOC_TRIM(VG_Z_LIBC_SONAME, malloc_trim);
-+MALLOC_TRIM(NONE, malloc_trim);
-
-
- /*---------------------- posix_memalign ----------------------*/
-@@ -658,6 +703,7 @@
- }
-
- POSIX_MEMALIGN(VG_Z_LIBC_SONAME, posix_memalign);
-+POSIX_MEMALIGN(NONE, posix_memalign);
- #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
- /* 27 Nov 07: it appears that xlc links into executables, a
- posix_memalign, which calls onwards to memalign_common, with the
-@@ -688,6 +734,7 @@
-
- MALLOC_USABLE_SIZE(VG_Z_LIBC_SONAME, malloc_usable_size);
- MALLOC_USABLE_SIZE(VG_Z_LIBC_SONAME, malloc_size);
-+MALLOC_USABLE_SIZE(NONE, malloc_size);
-
-
- /*---------------------- (unimplemented) ----------------------*/
-@@ -742,6 +789,7 @@
- }
-
- MALLINFO(VG_Z_LIBC_SONAME, mallinfo);
-+MALLINFO(NONE, mallinfo);
-
-
- #if defined(VGO_darwin)
diff --git a/tools/valgrind/possible.patch b/tools/valgrind/possible.patch
deleted file mode 100644
index b5e4841..0000000
--- a/tools/valgrind/possible.patch
+++ /dev/null
@@ -1,56 +0,0 @@
-Index: memcheck/mc_main.c
-===================================================================
---- memcheck/mc_main.c (revision 10880)
-+++ memcheck/mc_main.c (working copy)
-@@ -4658,6 +4658,7 @@
- LeakCheckMode MC_(clo_leak_check) = LC_Summary;
- VgRes MC_(clo_leak_resolution) = Vg_HighRes;
- Bool MC_(clo_show_reachable) = False;
-+Bool MC_(clo_show_possible) = True;
- Bool MC_(clo_workaround_gcc296_bugs) = False;
- Int MC_(clo_malloc_fill) = -1;
- Int MC_(clo_free_fill) = -1;
-@@ -4711,6 +4712,7 @@
-
- if VG_BOOL_CLO(arg, "--partial-loads-ok", MC_(clo_partial_loads_ok)) {}
- else if VG_BOOL_CLO(arg, "--show-reachable", MC_(clo_show_reachable)) {}
-+ else if VG_BOOL_CLO(arg, "--show-possible", MC_(clo_show_possible)) {}
- else if VG_BOOL_CLO(arg, "--workaround-gcc296-bugs",
- MC_(clo_workaround_gcc296_bugs)) {}
-
-@@ -4776,6 +4778,7 @@
- " --leak-check=no|summary|full search for memory leaks at exit? [summary]\n"
- " --leak-resolution=low|med|high differentiation of leak stack traces [high]\n"
- " --show-reachable=no|yes show reachable blocks in leak check? [no]\n"
-+" --show-possible=no|yes show possibly lost blocks in leak check? [yes]\n"
- " --undef-value-errors=no|yes check for undefined value errors [yes]\n"
- " --track-origins=no|yes show origins of undefined values? [no]\n"
- " --partial-loads-ok=no|yes too hard to explain here; see manual [no]\n"
-Index: memcheck/mc_include.h
-===================================================================
---- memcheck/mc_include.h (revision 10880)
-+++ memcheck/mc_include.h (working copy)
-@@ -395,6 +395,9 @@
- /* In leak check, show reachable-but-not-freed blocks? default: NO */
- extern Bool MC_(clo_show_reachable);
-
-+/* In leak check, show possibly-lost blocks? default: YES */
-+extern Bool MC_(clo_show_possible);
-+
- /* Assume accesses immediately below %esp are due to gcc-2.96 bugs.
- * default: NO */
- extern Bool MC_(clo_workaround_gcc296_bugs);
-Index: memcheck/mc_leakcheck.c
-===================================================================
---- memcheck/mc_leakcheck.c (revision 10880)
-+++ memcheck/mc_leakcheck.c (working copy)
-@@ -845,7 +845,8 @@
- print_record = is_full_check &&
- ( MC_(clo_show_reachable) ||
- Unreached == lr->key.state ||
-- Possible == lr->key.state );
-+ ( MC_(clo_show_possible) &&
-+ Possible == lr->key.state ) );
- // We don't count a leaks as errors with --leak-check=summary.
- // Otherwise you can get high error counts with few or no error
- // messages, which can be confusing. Also, you could argue that
diff --git a/tools/valgrind/redzone.patch b/tools/valgrind/redzone.patch
deleted file mode 100644
index 22f0bf7..0000000
--- a/tools/valgrind/redzone.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Index: memcheck/mc_include.h
-===================================================================
---- memcheck/mc_include.h (revision 10888)
-+++ memcheck/mc_include.h (working copy)
-@@ -43,7 +43,7 @@
- /*------------------------------------------------------------*/
-
- /* We want at least a 16B redzone on client heap blocks for Memcheck */
--#define MC_MALLOC_REDZONE_SZB 16
-+#define MC_MALLOC_REDZONE_SZB 64
-
- /* For malloc()/new/new[] vs. free()/delete/delete[] mismatch checking. */
- typedef
diff --git a/tools/valgrind/vbug205541.patch b/tools/valgrind/vbug205541.patch
deleted file mode 100644
index 3ab721a..0000000
--- a/tools/valgrind/vbug205541.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-# See https://bugs.kde.org/show_bug.cgi?id=205541#c1
-Index: memcheck/mc_main.c
-===================================================================
---- memcheck/mc_main.c (revision 10877)
-+++ memcheck/mc_main.c (working copy)
-@@ -3708,7 +3708,14 @@
- if (rr || ww || xx)
- MC_(make_mem_defined)(a, len);
- else
-- MC_(make_mem_noaccess)(a, len);
-+ MC_(make_mem_defined)(a, len);
-+ /* State after mmap(,,PROT_NONE,,,) should match
-+ * state after mprotect(,,PROT_NONE): the operating system
-+ * will trap any access, but any subsequent mprotect(,,PROT_R|W|X)
-+ * will re-instate the previous V bits [in this case, all valid].
-+ * See comment in mc_pre_clo_init() re:
-+ * VG_(track_change_mem_mprotect) ( NULL );
-+ */
- }
-
- static
diff --git a/tools/valgrind/vbug210481.patch b/tools/valgrind/vbug210481.patch
deleted file mode 100644
index 2907f6d..0000000
--- a/tools/valgrind/vbug210481.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-# See https://bugs.kde.org/show_bug.cgi?id=210481
-Index: guest_amd64_toIR.c
-===================================================================
---- VEX/priv/guest_amd64_toIR.c (Revision 1924)
-+++ VEX/priv/guest_amd64_toIR.c (Arbeitskopie)
-@@ -14597,7 +14597,7 @@
- /* There is no encoding for 32-bit pop in 64-bit mode.
- So sz==4 actually means sz==8. */
- if (haveF2orF3(pfx)) goto decode_failure;
-- vassert(sz == 2 || sz == 4);
-+ vassert(sz == 2 || sz == 4 || sz == 8);
- if (sz == 4) sz = 8;
- if (sz != 8) goto decode_failure; // until we know a sz==2 test case exists
-
diff --git a/tools/valgrind/xml-loadadr.patch b/tools/valgrind/xml-loadadr.patch
deleted file mode 100644
index a398543..0000000
--- a/tools/valgrind/xml-loadadr.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Index: coregrind/m_debuginfo/readmacho.c
-===================================================================
---- coregrind/m_debuginfo/readmacho.c (revision 10771)
-+++ coregrind/m_debuginfo/readmacho.c (working copy)
-@@ -680,6 +682,8 @@
- if (VG_(clo_verbosity) > 1)
- VG_(message)(Vg_DebugMsg,
- "%s (%#lx)\n", di->filename, di->rx_map_avma );
-+ if (VG_(clo_xml))
-+ VG_(printf_xml)("<load_obj><obj>%s</obj><ip>%#lx</ip></load_obj>\n", di->filename, di->rx_map_avma);
-
- /* This should be ensured by our caller. */
- vg_assert(di->have_rx_map);