Use and install Valgrind in Centos

Source: Internet
Author: User
Tags valgrind

Use and install Valgrind in Centos

Step 1:

To obtain the Valgrind package, you can first access http://valgrind.org/downloads/latest version

Wget http://valgrind.org/downloads/valgrind-3.10.1.tar.bz2

Step 2:

Decompress the downloaded file

Tar-jxvf valgrind-3.10.1.tar.bz2

Step 3:

Installation and configuration
./Autogen. sh
./Configure
Make; make install

Step 4:

View the parameters used (valgrind -- help)

Usage: valgrind [options] prog-and-args

Tool-selection option, with default in []:
-- Tool = <name> use the Valgrind tool named <name> [memcheck]


Basic user options for all Valgrind tools, with defaults in []:
-H -- help show this message
-- Help-debug show this message, plus debugging options
-- Version show version
-Q -- quiet run silently; only print error msgs
-V -- verbose be more verbose -- show misc extra info
-- Trace-children = no | yes Valgrind-ise child processes (follow execve )? [No]
-- Trace-children-skip = patt1, patt2,... specifies a list of executables
That -- trace-children = yes shocould not trace
-- Trace-children-skip-by-arg = patt1, patt2,... same as -- trace-children-skip =
But check the argv [] entries for children, rather
Than the exe name, to make a follow/no-follow demo-
-- Child-silent-after-fork = no | yes omit child output between fork & exec? [No]
-- Vgdb = no | yes | full activate gdbserver? [Yes]
Full is slower but provides precise watchpoint/step
-- Vgdb-error = <number> invoke gdbserver after <number> errors [1, 999999999]
To get started quickly, use -- vgdb-error = 0
And follow the on-screen directions ctions
-- Vgdb-stop-at = event1, event2,... invoke gdbserver for given events [none]
Where event is one:
Startup exit valgrindabexit all none
-- Track-fds = no | yes track open file descriptors? [No]
-- Time-stamp = no | yes add timestamps to log messages? [No]
-- Log-fd = <number> log messages to file descriptor [2 = stderr]
-- Log-file = <file> log messages to <file>
-- Log-socket = ipaddr: port log messages to socket ipaddr: port


User options for Valgrind tools that report errors:
-- Xml = yes emit error output in XML (some tools only)
-- Xml-fd = <number> XML output to file descriptor
-- Xml-file = <file> XML output to <file>
-- Xml-socket = ipaddr: port XML output to socket ipaddr: port
-- Xml-user-comment = STR copy STR verbatim into XML output
-- Demangle = no | yes automatically demangle C ++ names? [Yes]
-- Num-callers = <number> show <number> callers in stack traces [12]
-- Error-limit = no | yes stop showing new errors if too operation? [Yes]
-- Error-exitcode = <number> exit code to return if errors found [0 = disable]
-- Show-below-main = no | yes continue stack traces below main () [no]
-- Default-suppressions = yes | no
Load default suppressions [yes]
-- Suppressions = <filename> suppress errors described in <filename>
-- Gen-suppressions = no | yes | all print suppressions for errors? [No]
-- Db-attach = no | yes start debugger when errors detected? [No]
Note: deprecated feature
-- Db-command = <command> command to start debugger [/no/gdb/was/found/at/configure/time-nw % f % p]
-- Input-fd = <number> file descriptor for input [0 = stdin]
-- Dsymutil = no | yes run dsymutil on Mac OS X when helpful? [No]
-- Max-stackframe = <number> assume stack switch for SP changes larger
Than <number> bytes [1, 2000000]
-- Main-stacksize = <number> set size of main thread's stack (in bytes)
[Min (max (current 'ulimit 'value, 1 MB), 16 MB)]


User options for Valgrind tools that replace malloc:
-- Alignment = <number> set minimum alignment of heap allocations [16]
-- Redzone-size = <number> set minimum size of redzones added before/after
Heap blocks (in bytes). [16]


Uncommon user options for all Valgrind tools:
-- Fullpath-after = (with nothing after the '= ')
Show full source paths in call stacks
-- Fullpath-after = string like -- fullpath-after =, but only show
Part of the path after 'string'. Allows removal
Of path prefixes. Use this flag multiple times
To specify a set of prefixes to remove.
-- Extra-debuginfo-path = path absolute path to search for additional
Debug symbols, in addition to existing default
Well known search paths.
-- Debuginfo-server = ipaddr: port also query this server
(Valgrind-di-server) for debug symbols
-- Allow-mismatched-debuginfo = no | yes [no]
For the above two flags only, accept debuginfo
Objects that don't "match" the main object
-- Smc-check = none | stack | all-non-file [stack]
Checks for self-modifying code: none, only
Code found in stacks, for all code, or for all
Code found t that from file-backed mappings
-- Read-inline-info = yes | no read debug info about inlined function CILS
And use it to do better stack traces. [yes]
On Linux/Android for Memcheck/Helgrind/DRD
Only. [no] for all other tools and platforms.
-- Read-var-info = yes | no read debug info on stack and global variables
And use it to print better error messages in
Tools that make use of it (Memcheck, Helgrind,
DRD) [no]
-- Vgdb-poll = <number> gdbserver poll max every <number> basic blocks [0, 5000]
-- Vgdb-shadow-registers = no | yes let gdb see the shadow registers [no]
-- Vgdb-prefix = <prefix> prefix for vgdb Guest OS [/tmp/vgdb-pipe]
-- Run-libc-freeres = no | yes free up glibc memory at exit on Linux? [Yes]
-- Sim-hints = hint1, hint2,... activate unusual sim behaviours [none]
Where hint is one:
Lax-ioctls fuse-compatible enable-outer
No-inner-prefix no-nptl-pthread-stackcache none
-- Fair-sched = no | yes | try schedule threads fairly on multicore systems [no]
-- Kernel-variant = variant1, variant2 ,...
Handle non-standard kernel variants [none]
Where variant is one:
Bproc android-no-hw-tls
Android-gpu-sgx5xx android-gpu-adreno3xx none
-- Merge-recursive-frames = <number> merge frames between identical
Program counters in max <number> frames) [0]
-- Num-transtab-sectors = <number> size of translated code cache [16]
More sectors may increase performance, but use more memory.
-- Aspace-minaddr = 0xPP avoid mapping memory below 0xPP [guessed]
-- Show-emwarns = no | yes show warnings about emulation limits? [No]
-- Require-text-symbol =: sonamepattern: symbolpattern abort run if
Stated shared object doesn' t have the stated
Text symbol. Patterns can contain? And *.
-- Soname-synonyms = syn1 = pattern1, syn2 = pattern2,... synonym soname
Specify patterns for function wrapping or replacement.
To use a non-libc malloc library that is
In the main exe: -- soname-synonyms = somalloc = NONE
In libxyruntime. so: -- soname-synonyms = somalloc = libxyruntime. so
-- Sigill-diagnostics = yes | no warn about illegal instructions? [Yes]
-- Unw-stack-scan-thresh = <number> Enable stack-scan unwind if fewer
Than <number> good frames found [0, meaning "disabled"]
NOTE: stack scanning is only available on arm-linux.
-- Unw-stack-scan-frames = <number> Max number of frames that can be
Recovered by stack scanning [5]


User options for Memcheck:
-- Leak-check = no | summary | full search for memory leaks at exit? [Summary]
-- Leak-resolution = low | med | high differentiation of leak stack traces [high]
-- Show-leak-kinds = kind1, kind2,... which leak kinds to show?
[Definite, possible]
-- Errors-for-leak-kinds = kind1, kind2,... which leak kinds are errors?
[Definite, possible]
Where kind is one:
Definite indirect possible reachable all none
-- Leak-check-heuristics = heur1, heur2,... which heuristics to use
Improving leak search false positive [none]
Where heur is one:
Stdstring length64 newarray multipleinheritance all none
-- Show-reachable = yes same as -- show-leak-kinds = all
-- Show-reachable = no -- show-possibly-lost = yes
Same as -- show-leak-kinds = definite, possible
-- Show-reachable = no -- show-possibly-lost = no
Same as -- show-leak-kinds = definite
-- Undef-value-errors = no | yes check for undefined value errors [yes]
-- Track-origins = no | yes show origins of undefined values? [No]
-- Partial-loads-OK = no | yes too hard to explain here; see manual [no]
-- Freelist-vol = <number> volume of freed blocks queue [1, 20000000]
-- Freelist-big-blocks = <number> releases first blocks with size> = [1000000]
-- Workaround-gcc296-bugs = no | yes self explanatory [no]
-- Ignore-ranges = 0xPP-0xQQ [, 0xRR-0xSS] assume given addresses are OK
-- Malloc-fill = -- Free-fill = -- Keep-stacktraces = alloc | free | alloc-and-free | alloc-then-free | none
Stack trace (s) to keep for malloc 'd/free 'd areas [alloc-then-free]
-- Show-mismatched-frees = no | yes show frees that don't match the allocator? [Yes]

Step 5 test the program: Note: whether the current user has the execution permission is required

Valgrind -- tool = memcheck -- leak-check = full -- log-file = log./main tests the compiled C program using the corresponding parameters.

Step 6:

The above configuration will generate a log file in the current directory to view the log file.

==24809 = Memcheck, a memory error detector
= 24809 = Copyright (C) 2002-2013, and gnu gpl 'd, by Julian Seward et al.
= 24809 = Using Valgrind-3.10.1 and LibVEX; rerun with-h for copyright info
==24809 = Command:./main
= 24809 = Parent PID: 7060
= 24809 =
= 24809 =
==24809 === heap summary:
= 24809 = in use at exit: 0 bytes in 0 blocks
= 24809 = total heap usage: 29 allocs, 29 frees, 1,193 bytes allocated
= 24809 =
= 24809 = All heap blocks were freed -- no leaks are possible
= 24809 =
= 24809 = For counts of detected and suppressed errors, rerun with:-v
= 24809 = error summary: 0 errors from 0 contexts (suppressed: 4 from 4)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.