Today’s episode is all about Valgrind – from the pro’s to the con’s, from the why to the how! This episode will be of interest to anyone who is or wants to work with Valgrind on a regular or semi-regular basis.

  1. Pro’s/Why
  2. Con’s
  3. How
    1. Using the latest version
      sudo [yum/apt-get] install valgrind
      #OR#
      sudo [yum/apt-get] remove valgrind
      sudo [yum/apt-get] install bzip2 glibc*
      wget http://valgrind.org/downloads/valgrind-3.10.1.tar.bz2
      tar -xf valgrind-3.10.1.tar.bz2; cd valgrind-3.10.1
      ./configure; make; sudo make install
      valgrind –version # This should now read 3.10.1
    2. VGDB (cd ./mysql-test)
      ./lib/v1/mysql-test-run.pl –start-and-exit –valgrind –valgrind-option=”–leak-check=yes”
      –valgrind-option=”–vgdb=yes” –valgrind-option=”–vgdb-error=0″ 1st
      #OR# valgrind –leak-check=yes –vgdb=yes –vgdb-error=0 ./mysqld –options…
      #ALSO CONSIDER# –num-callers=40 –show-reachable=yes –track-origins=yes
      gdb /Percona-server/bin/mysqld
      (gdb) target remote | vgdb
      (gdb) bt
    3. pquery Valgrind
    4. Valgrind stacks overview & analysis

Full-screen viewing @ 720p resolution recommended.

Checkout the full MySQL QA Series today!

5 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Jörg Brühe

I sure would like to follow your explanations – but I won’t install insecure stuff like Flash.
Please: Isn’t there a safe way to publish your material?

Regards,
Jörg

Shahriyar Rzayev

If you try to install valgrind debuginfo package and got something like:
“debuginfo-install: command not found”
Just install yum-utils package:
[root@centos-base ~]# yum install yum-utils

Shahriyar Rzayev

Just for a note if somebody wondering how to have a “Debug” or “Valgrind” MySQL on they own. Simply it means that you have compiled MySQL from source code with:
-DWITH_DEBUG=1 for “Debug” build, -DWITH_VALGRIND=1 for “Valgrind” build.

The full command will be like above for eg with MySQL 5.6.19:

cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql-5.6.19 -DMYSQL_DATADIR=/var/lib/mysql -DSYSCONFDIR=/opt/mysql-5.6.19 -DWITH_SSL=system -DMYSQL_TCP_PORT=3307 -DMYSQL_UNIX_ADDR=/opt/mysql-5.6.19/mysqld.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_DEBUG=1 -DCOMPILATION_COMMENT=”Shahriyar Rzayev’s Ubuntu MySQL-5.6.19″ -DOPTIMIZER_TRACE=1 -DWITH_ZLIB=system -DWITH_VALGRIND=1 -DCMAKE_C_FLAGS=-DHAVE_purify -DCMAKE_CXX_FLAGS=-DHAVE_purify

Then:
make
make install

You may have some problems with installing MySQL from source code. So i have noted them in our local community page:

http://mysql.az/installing-mysql-from-source-cmake-issues/