Using and understanding the Valgrind core
--require-text-symbol=:sonamepatt:fnnamepatt
When a shared object whose soname matches
sonamepatt
is loaded into the process, examine all the text symbols
it exports. If none of those match
fnnamepatt
, print an error message and abandon the run. This makes it possible
to ensure that the run does not continue unless a given shared object contains a particular function name.
Both
sonamepatt
and
fnnamepatt
can be written using the usual
?
and
*
wildcards.
For example:
":*libc.so*:foo?bar"
.
You may use characters other than a colon to separate the two patterns.
It is
only important that the first character and the separator character are the same. For example, the above example could
also be written
"Q*libc.so*Qfoo?bar"
. Multiple
--require-text-symbol
flags are allowed, in which
case shared objects that are loaded into the process will be checked against all of them.
The purpose of this is to support reliable usage of marked-up libraries.
For example, suppose we have a
version of GCC’s
libgomp.so
which has been marked up with annotations to support Helgrind.
It is only
too easy and confusing to load the wrong, un-annotated
libgomp.so
into the application.
So the idea is:
add a text symbol in the marked-up library, for example
annotated_for_helgrind_3_6
, and then give
the flag
--require-text-symbol=:*libgomp*so*:annotated_for_helgrind_3_6
so that when
libgomp.so
is loaded, Valgrind scans its symbol table, and if the symbol isn’t present the run is aborted, rather
than continuing silently with the un-marked-up library.
Note that you should put the entire flag in quotes to stop
shells expanding up the
*
and
?
wildcards.
--soname-synonyms=syn1=pattern1,syn2=pattern2,...
When a shared library is loaded, Valgrind checks for functions in the library that must be replaced or wrapped. For
example, Memcheck replaces all malloc related functions (malloc, free, calloc, ...) with its own versions. Such
replacements are done by default only in shared libraries whose soname matches a predefined soname pattern (e.g.
libc.so*
on linux). By default, no replacement is done for a statically linked library or for alternative libraries
such as tcmalloc. In some cases, the replacements allow
--soname-synonyms
to specify one additional synonym
pattern, giving flexibility in the replacement.
Currently, this flexibility is only allowed for the malloc related functions, using the synonym
somalloc
.
This
synonym is usable for all tools doing standard replacement of malloc related functions (e.g. memcheck, massif, drd,
helgrind, exp-dhat, exp-sgcheck).
• Alternate malloc library:
to replace the malloc related functions in an alternate library with soname
mymalloclib.so
, give the option
--soname-synonyms=somalloc=mymalloclib.so
. A pattern can
be used to match multiple libraries sonames. For example,
--soname-synonyms=somalloc=*tcmalloc*
will match the soname of all variants of the tcmalloc library (native, debug, profiled, ... tcmalloc variants).
Note: the soname of a elf shared library can be retrieved using the readelf utility.
• Replacements in a statically linked library are done by using the
NONE
pattern.
For exam-
ple, if you link with
libtcmalloc.a
, memcheck will properly work when you give the option
--soname-synonyms=somalloc=NONE
.
Note that a NONE pattern will match the main executable
and any shared library having no soname.
• To run a "default" Firefox build for Linux, in which JEMalloc is linked in to the main executable, use
--soname-synonyms=somalloc=NONE
.
20
Содержание Software
Страница 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 ...