Using and understanding the Valgrind core
--main-stacksize=<number> [default:
use current ’ulimit’ value]
Specifies the size of the main thread’s stack.
To simplify its memory management, Valgrind reserves all required space for the main thread’s stack at startup. That
means it needs to know the required stack size at startup.
By default, Valgrind uses the current "ulimit" value for the stack size, or 16 MB, whichever is lower. In many cases
this gives a stack size in the range 8 to 16 MB, which almost never overflows for most applications.
If you need a larger total stack size, use
--main-stacksize
to specify it. Only set it as high as you need, since
reserving far more space than you need (that is, hundreds of megabytes more than you need) constrains Valgrind’s
memory allocators and may reduce the total amount of memory that Valgrind can use.
This is only really of
significance on 32-bit machines.
On Linux, you may request a stack of size up to 2GB. Valgrind will stop with a diagnostic message if the stack cannot
be allocated.
--main-stacksize
only affects the stack size for the program’s initial thread.
It has no bearing on the size of
thread stacks, as Valgrind does not allocate those.
You may need to use both
--main-stacksize
and
--max-stackframe
together. It is important to understand
that
--main-stacksize
sets the maximum total stack size, whilst
--max-stackframe
specifies the largest size
of any one stack frame.
You will have to work out the
--main-stacksize
value for yourself (usually, if your
applications segfaults). But Valgrind will tell you the needed
--max-stackframe
size, if necessary.
As discussed further in the description of
--max-stackframe
, a requirement for a large stack is a sign of potential
portability problems. You are best advised to place all large data in heap-allocated memory.
2.6.4. malloc-related Options
For tools that use their own version of
malloc
(e.g. Memcheck, Massif, Helgrind, DRD), the following options
apply.
--alignment=<number> [default:
8 or 16, depending on the platform]
By default Valgrind’s
malloc
,
realloc
, etc, return a block whose starting address is 8-byte aligned or 16-byte
aligned (the value depends on the platform and matches the platform default).
This option allows you to specify a
different alignment. The supplied value must be greater than or equal to the default, less than or equal to 4096, and
must be a power of two.
--redzone-size=<number> [default:
depends on the tool]
Valgrind’s
malloc, realloc,
etc, add padding blocks before and after each heap block allocated by the program
being run. Such padding blocks are called redzones. The default value for the redzone size depends on the tool. For
example, Memcheck adds and protects a minimum of 16 bytes before and after each block allocated by the client.
This allows it to detect block underruns or overruns of up to 16 bytes.
Increasing the redzone size makes it possible to detect overruns of larger distances, but increases the amount of
memory used by Valgrind. Decreasing the redzone size will reduce the memory needed by Valgrind but also reduces
the chances of detecting over/underruns, so is not recommended.
2.6.5. Uncommon Options
These options apply to all tools, as they affect certain obscure workings of the Valgrind core. Most people won’t need
to use them.
16
Содержание 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 ...