For Developers‎ > ‎How-Tos‎ > ‎Using Valgrind‎ > ‎

Get Valgrind

Using pre-built binaries from Chromium SVN

In most cases, you don't need to build Valgrind yourself.
We already have pre-built Valgrind binaries for Linux and Mac OS 10.5 and 10.6 in SVN.
These binaries are not checked out automatically, you need to specify the following rule in your .glient custom_deps section of your src client:
  { "name"        : "src",
    "url"         : <...>,
    "custom_deps" : {
      <your old custom_deps here>
      "src/third_party/valgrind":
        "http://src.chromium.org/chrome/trunk/deps/third_party/valgrind/binaries",
  },
and then do gclient sync (this will download around 40Mb of binaries).

Using pre-built binaries in the git-submodules flow

From your src directory, run
git clone https://chromium.googlesource.com/chromium/deps/valgrind/binaries.git third_party/valgrind
These binaries won't get updated automatically by the sync process, so you'll want to manually `git pull` them occasionally.

Building binaries for local use

If for some reason the binaries from SVN don't work for you, you can build the binaries for your architecture in some local directory.

OS X users: note that Valgrind isn't supported on 10.8, and nobody is working on the support right now.
If you need to debug addressability issues, consider using AddressSanitizer (http://dev.chromium.org/developers/testing/addresssanitizer).
If you strongly need to run Valgrind on OS X, try using a 10.6 or 10.7 machine (e.g. connect to one of the buildbots).

First of all, make sure you have automake installed:
sudo apt-get install automake

Then, make sure you aren't linking with gold, otherwise the build may fail.
If you've set CC/CXX to point to gold, unset them before doing the steps listed below.

Then,
mkdir valgrind-build-for-chromium # please don't delete this directory 
cd valgrind-build-for-chromium
mkdir binaries
svn co http://src.chromium.org/chrome/trunk/deps/third_party/valgrind/scripts
cd scripts
sh build-valgrind-for-chromium.sh
# You should probably read this script to get better understanding of what's happening.

These steps may help you to try your local patches to Valgrind if you want to.

You'll need to define CHROME_VALGRIND environmental variable pointing to your local build directory before running src/tools/valgrind/chrome_tests.sh
OR you can do
cd ../binaries
sudo ln -s local /usr/local/valgrind-10880

Updating binaries in the SVN

If you need to update the Valgrind binaries in the SVN (e.g. add a new patch, get a newer version of Valgrind, etc),
please do the following on two machines (Linux 64-bit and Mac 10.5):

First, make sure you have automake installed (e.g. sudo apt-get automake)

Then,
mkdir valgrind-for-chromium-client
cd valgrind-for-chromium-client
gclient config svn://.../trunk/deps/third_party/valgrind # use the SVN path provided with your commiter access details.
gclient sync
cd valgrind/scripts
sh build-valgrind-for-chromium.sh # this will overwrite some files in valgrind/binaries/<your platform>/
cd ../binaries
svn status # check that the binaries have changed
<commit>

You may put valgrind-for-chromium-client directory into a shared network location if you need update the binaries for Linux and Mac at the same time.
Please note that the absolute path to valgrind-for-chromium-client will be put into Valgrind binaries!

Configuring Valgrind buildbot slave

If you need to add a new Valgrind slave to the buildbot, please add
factory_properties={
  'needs_valgrind' : True,
  'gclient_env': { 'GYP_DEFINES' : valgrind_gyp_defines}})
to the slave factory definition in the corresponding master.cfg

This will pull Valgrind binaries from SVN (see http://sites.google.com/a/chromium.org/dev/developers/how-tos/using-valgrind/building-valgrind for the details) and some definitions to build Valgrind-friendly Chrome. 

Please see Memory Waterfall master.cfg for the examples.
Comments