DRD: a thread error detector
Note: if you compiled Valgrind yourself, the header file
<valgrind/drd.h>
will have been installed in the
directory
/usr/include
by the command
make install
. If you obtained Valgrind by installing it as a package
however, you will probably have to install another package with a name like
valgrind-devel
before Valgrind’s
header files are available.
8.2.6. Debugging GNOME Programs
GNOME applications use the threading primitives provided by the
glib
and
gthread
libraries. These libraries are
built on top of POSIX threads, and hence are directly supported by DRD. Please keep in mind that you have to call
g_thread_init
before creating any threads, or DRD will report several data races on glib functions. See also the
GLib Reference Manual for more information about
g_thread_init
.
One of the many facilities provided by the
glib
library is a block allocator, called
g_slice
.
You have
to disable this block allocator when using DRD by adding the following to the shell environment variables:
G_SLICE=always-malloc
. See also the GLib Reference Manual for more information.
8.2.7. Debugging Boost.Thread Programs
The Boost.Thread library is the threading library included with the cross-platform Boost Libraries. This threading
library is an early implementation of the upcoming C++0x threading library.
Applications that use the Boost.Thread library should run fine under DRD.
More information about Boost.Thread can be found here:
• Anthony Williams, Boost.Thread Library Documentation, Boost website, 2007.
• Anthony Williams, What’s New in Boost Threads?, Recent changes to the Boost Thread library, Dr. Dobbs
Magazine, October 2008.
8.2.8. Debugging OpenMP Programs
OpenMP stands for
Open Multi-Processing
. The OpenMP standard consists of a set of compiler directives for C, C++
and Fortran programs that allows a compiler to transform a sequential program into a parallel program. OpenMP is
well suited for HPC applications and allows to work at a higher level compared to direct use of the POSIX threads
API. While OpenMP ensures that the POSIX API is used correctly, OpenMP programs can still contain data races. So
it definitely makes sense to verify OpenMP programs with a thread checking tool.
DRD supports OpenMP shared-memory programs generated by GCC. GCC supports OpenMP since version 4.2.0.
GCC’s runtime support for OpenMP programs is provided by a library called
libgomp
. The synchronization
primitives implemented in this library use Linux’ futex system call directly, unless the library has been configured
with the
--disable-linux-futex
option. DRD only supports libgomp libraries that have been configured with
this option and in which symbol information is present. For most Linux distributions this means that you will have to
recompile GCC. See also the script
drd/scripts/download-and-build-gcc
in the Valgrind source tree for
an example of how to compile GCC. You will also have to make sure that the newly compiled
libgomp.so
library
is loaded when OpenMP programs are started. This is possible by adding a line similar to the following to your shell
startup script:
export LD_LIBRARY_PATH=~/gcc-4.4.0/lib64:~/gcc-4.4.0/lib:
131
Содержание BBV
Страница 176: ...Valgrind FAQ Release 3 8 0 10 August 2012 Copyright 2000 2012 Valgrind Developers Email valgrind valgrind org ...
Страница 177: ...Valgrind FAQ Table of Contents Valgrind Frequently Asked Questions 1 ii ...
Страница 302: ...README mips based on newer GCC versions if possible 95 ...
Страница 303: ...GNU Licenses ...
Страница 304: ...GNU Licenses Table of Contents 1 The GNU General Public License 1 2 The GNU Free Documentation License 8 ii ...