Using and understanding the Valgrind core: Advanced Topics
VALGRIND_DISCARD_TRANSLATIONS
:
Discards translations of code in the specified address range.
Useful if you are debugging a JIT compiler or some
other dynamic code generation system. After this call, attempts to execute code in the invalidated address range will
cause Valgrind to make new translations of that code, which is probably the semantics you want.
Note that code
invalidations are expensive because finding all the relevant translations quickly is very difficult, so try not to call it
often. Note that you can be clever about this: you only need to call it when an area which previously contained code is
overwritten with new code. You can choose to write code into fresh memory, and just call this occasionally to discard
large chunks of old code all at once.
Alternatively, for transparent self-modifying-code support, use
--smc-check=all
, or run on ppc32/Linux,
ppc64/Linux or ARM/Linux.
VALGRIND_COUNT_ERRORS
:
Returns the number of errors found so far by Valgrind.
Can be useful in test harness code when combined with
the
--log-fd=-1
option; this runs Valgrind silently, but the client program can detect when errors occur.
Only
useful for tools that report errors, e.g. it’s useful for Memcheck, but for Cachegrind it will always return zero because
Cachegrind doesn’t report errors.
VALGRIND_MALLOCLIKE_BLOCK
:
If your program manages its own memory instead of using the standard
malloc
/
new
/
new[]
, tools that track
information about heap blocks will not do nearly as good a job.
For example, Memcheck won’t detect nearly as
many errors, and the error messages won’t be as informative. To improve this situation, use this macro just after your
custom allocator allocates some new memory. See the comments in
valgrind.h
for information on how to use it.
VALGRIND_FREELIKE_BLOCK
:
This should be used in conjunction with
VALGRIND_MALLOCLIKE_BLOCK
. Again, see
valgrind.h
for infor-
mation on how to use it.
VALGRIND_RESIZEINPLACE_BLOCK
:
Informs a Valgrind tool that the size of an allocated block has been modified but not its address. See
valgrind.h
for more information on how to use it.
VALGRIND_CREATE_MEMPOOL
,
VALGRIND_DESTROY_MEMPOOL
,
VALGRIND_MEMPOOL_ALLOC
,
VALGRIND_MEMPOOL_FREE
,
VALGRIND_MOVE_MEMPOOL
,
VALGRIND_MEMPOOL_CHANGE
,
VALGRIND_MEMPOOL_EXISTS
:
These are similar to
VALGRIND_MALLOCLIKE_BLOCK
and
VALGRIND_FREELIKE_BLOCK
but are tailored
towards code that uses memory pools. See
Memory Pools
for a detailed description.
VALGRIND_NON_SIMD_CALL[0123]
:
Executes a function in the client program on the
real
CPU, not the virtual CPU that Valgrind normally runs code on.
The function must take an integer (holding a thread ID) as the first argument and then 0, 1, 2 or 3 more arguments
(depending on which client request is used). These are used in various ways internally to Valgrind. They might be
useful to client programs.
Warning:
Only use these if you
really
know what you are doing. They aren’t entirely reliable, and can cause Valgrind
to crash. See
valgrind.h
for more details.
VALGRIND_PRINTF(format, ...)
:
Print a printf-style message to the Valgrind log file.
The message is prefixed with the PID between a pair of
**
markers. (Like all client requests, nothing is output if the client program is not running under Valgrind.) Output is not
produced until a newline is encountered, or subsequent Valgrind output is printed; this allows you to build up a single
line of output over multiple calls. Returns the number of characters output, excluding the PID prefix.
VALGRIND_PRINTF_BACKTRACE(format, ...)
:
Like
VALGRIND_PRINTF
(in particular, the return value is identical), but prints a stack backtrace immediately
afterwards.
30
Содержание 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 ...