### Test Valgrind Installation with OpenOffice.org Source: https://valgrind.org/docs/manual/dist.readme-packagers.html Use this command to test if Valgrind can start and exit successfully with OpenOffice.org (soffice), thoroughly exercising Valgrind's capabilities. Ensure the final installation works by running it on something huge. ```bash valgrind -v --trace-children=yes soffice ``` -------------------------------- ### Start Valgrind and vgdb for remote debugging Source: https://valgrind.org/docs/manual/manual-core-adv.html This example demonstrates starting a Valgrind process with debugging enabled and then running vgdb to listen on a specific TCP port for GDB connections. It's useful for debugging Valgrind processes on a remote machine. ```bash # On the target computer, start your program under valgrind using valgrind --vgdb-error=0 prog # and then in another shell, run: vgdb --port=1234 ``` -------------------------------- ### Install Valgrind from ports Source: https://valgrind.org/docs/manual/dist.readme-freebsd.html Navigate to the Valgrind port directory and run 'make install clean' to install from source. ```bash cd /usr/ports/devel/valgrind && make install clean ``` -------------------------------- ### Test Valgrind Installation with Firefox Source: https://valgrind.org/docs/manual/dist.readme-packagers.html Use this command to test if Valgrind can start and exit successfully with Firefox, thoroughly exercising Valgrind's capabilities. Ensure the final installation works by running it on something huge. ```bash valgrind -v --trace-children=yes firefox ``` -------------------------------- ### Start Valgrind Listener Source: https://valgrind.org/docs/manual/faq.html Command to start the valgrind-listener program to receive logging output over the network. This should be started before the Valgrind process. ```bash valgrind-listener 12345 ``` -------------------------------- ### Example Command with --free-is-write Source: https://valgrind.org/docs/manual/drd-manual.html This example demonstrates the usage of the `--free-is-write=yes` option with DRD on a specific test case. ```bash valgrind --tool=drd --free-is-write=yes         drd/tests/annotate_smart_pointer ``` -------------------------------- ### Valgrind Tool Startup Output Example Source: https://valgrind.org/docs/manual/manual-writing-tools.html Example of the expected output when running a newly created Valgrind tool. This shows the tool's name, version, copyright information, and the executed command. ```text ==738== foobar-0.0.1, a foobarring tool. ==738== Copyright (C) 2002-2017, and GNU GPL'd, by J. Programmer. ==738== Using Valgrind-3.14.0.GIT and LibVEX; rerun with -h for copyright info ==738== Command: date ==738== Tue Nov 27 12:40:49 EST 2017 ==738== ``` -------------------------------- ### Configure Valgrind for Self-Hosting Regression Tests Source: https://valgrind.org/docs/manual/dist.readme-developers.html Example command for running Valgrind regression tests in a self-hosting mode. This setup helps verify Valgrind's internal integrity, such as detecting memory leaks. ```bash outer/.../bin/valgrind --sim-hints=enable-outer --trace-children=yes \ --smc-check=all-non-file \ --run-libc-freeres=no --tool=cachegrind -v \ ``` -------------------------------- ### Install Valgrind using pkg Source: https://valgrind.org/docs/manual/dist.readme-freebsd.html Use this command to install Valgrind via the pkg package manager on FreeBSD. ```bash pkg install devel/valgrind ``` -------------------------------- ### Start Android Emulator Source: https://valgrind.org/docs/manual/dist.readme-android_emulator.html Initiate the Android emulator. This command is typically run from the Android SDK tools directory. ```bash android ``` -------------------------------- ### Debug Valgrind Tool with GDB Source: https://valgrind.org/docs/manual/dist.readme-developers.html Launch GDB with the specific tool executable. This is step (2) for debugging the main body of Valgrind code. Examples show both installed and uninstalled versions. ```bash gdb /usr/local/libexec/valgrind/lackey-ppc32-linux ``` ```bash gdb $DIR/.in_place/memcheck-x86-linux ``` -------------------------------- ### Start Valgrind and vgdb on Android Source: https://valgrind.org/docs/manual/manual-core-adv.html Execute these commands on the Android system to start Valgrind with debugging enabled and launch the vgdb server. ```bash valgrind --vgdb-error=0 --vgdb=yes prog ``` ```bash vgdb --port=1234 ``` -------------------------------- ### Start GDB on the target program Source: https://valgrind.org/docs/manual/manual-core-adv.html Before connecting to the Valgrind gdbserver, start GDB attached to the program you intend to debug. ```bash gdb ./prog ``` -------------------------------- ### Extended Callgrind Example Source: https://valgrind.org/docs/manual/cl-format.html An example demonstrating function calls and their associated costs in the Callgrind format. It illustrates how to specify calls between functions in the same or different files. ```callgrind # callgrind format events: Instructions fl=file1.c fn=main 16 20 cfn=func1 calls=1 50 16 400 cfi=file2.c cfn=func2 calls=3 20 16 400 fn=func1 51 100 cfi=file2.c cfn=func2 calls=2 20 51 300 fl=file2.c fn=func2 20 700 ``` -------------------------------- ### Copy Profiling Example Source: https://valgrind.org/docs/manual/dh-manual.html An example PP node from DHAT's copy profiling mode, showing memory copy operations like memcpy and memmove. ```text PP 1.1.2/5 (4 children) { Total: 1,210,925 bytes (10.03%, 4,358.66/Minstr) in 112,717 blocks (35.2%, 405.72/Minstr), avg size 10.74 bytes Copied at { ^1: 0x4842524: memmove (vg_replace_strmem.c:1289) #2: 0x1F0A0D: copy_nonoverlapping (intrinsics.rs:1858) #3: 0x1F0A0D: copy_from_slice (mod.rs:2524) #4: 0x1F0A0D: spec_extend (vec.rs:2227) #5: 0x1F0A0D: extend_from_slice (vec.rs:1619) #6: 0x1F0A0D: push_str (string.rs:821) #7: 0x1F0A0D: write_str (string.rs:2418) #8: 0x1F0A0D: <&mut W as core::fmt::Write>::write_str (mod.rs:195) } } ``` -------------------------------- ### Start Valgrind with GDB Debugging Enabled Source: https://valgrind.org/docs/manual/manual-core-adv.html Use this command to start Valgrind with the gdbserver enabled and set to report errors immediately. This is useful for quick debugging sessions. ```bash valgrind --vgdb=yes --vgdb-error=0 prog ``` -------------------------------- ### Start Callgrind Profiling Source: https://valgrind.org/docs/manual/cl-manual.html Execute this command to start a profiling run for your program with Callgrind. Ensure your program is compiled with debugging information and optimization. ```bash valgrind --tool=callgrind [callgrind options] your-program [program options] ``` -------------------------------- ### Valgrind DH Interior Node Output Example Source: https://valgrind.org/docs/manual/dh-manual.html This snippet shows an example of the detailed output for an interior node (PP node) in Valgrind's DH tool. It includes aggregated allocation data, stack traces, and performance metrics. ```text PP 1.1/25 (2 children) { Total: 54,533,440 bytes (4.02%, 2,714.28/Minstr) in 458,839 blocks (7.72%, 22.84/Minstr), avg size 118.85 bytes, avg lifetime 1,127,259,403.64 instrs (5.61% of program duration) At t-gmax: 0 bytes (0%) in 0 blocks (0%), avg size 0 bytes At t-end: 0 bytes (0%) in 0 blocks (0%), avg size 0 bytes Reads: 15,993,012 bytes (0.29%, 796.02/Minstr), 0.29/byte Writes: 20,974,752 bytes (1.03%, 1,043.97/Minstr), 0.38/byte Allocated at { #1: 0x95CACC9: alloc (alloc.rs:72) #2: 0x95CACC9: alloc (alloc.rs:148) #3: 0x95CACC9: reserve_internal (raw_vec.rs:669) #4: 0x95CACC9: reserve (raw_vec.rs:492) #5: 0x95CACC9: reserve (vec.rs:460) #6: 0x95CACC9: push (vec.rs:989) #7: 0x95CACC9: parse_token_trees_until_close_delim (tokentrees.rs:27) #8: 0x95CACC9: syntax::parse::lexer::tokentrees::>::parse_token_tree (tokentrees.rs:81) } } ``` -------------------------------- ### Example C Program for Heap Allocation Source: https://valgrind.org/docs/manual/ms-manual.html This C program demonstrates various heap allocations and deallocations, suitable for profiling with Massif. ```c #include void g(void) { malloc(4000); } void f(void) { malloc(2000); g(); } int main(void) { int i; int* a[10]; for (i = 0; i < 10; i++) { a[i] = malloc(1000); } f(); g(); for (i = 0; i < 10; i++) { free(a[i]); } return 0; } ``` -------------------------------- ### Massif Output Preamble Example Source: https://valgrind.org/docs/manual/ms-manual.html The initial section of ms_print's output shows how the program, Massif, and ms_print were invoked. ```text -------------------------------------------------------------------------------- Command: example Massif arguments: (none) ms_print arguments: massif.out.12797 -------------------------------------------------------------------------------- ``` -------------------------------- ### Callgrind Format Basic Structure Example Source: https://valgrind.org/docs/manual/cl-format.html This example demonstrates the basic structure of a Callgrind format file, including the header and cost lines. The 'events' line defines the profile metrics, and cost lines provide counts for these events associated with source code positions. ```text # callgrind format events: Cycles Instructions Flops fl=file.f fn=main 15 90 14 2 16 20 12 ``` -------------------------------- ### Cachegrind Summary Statistics Example Source: https://valgrind.org/docs/manual/cg-manual.html This is an example of the summary statistics printed after running Cachegrind. 'I refs' stands for 'Instruction cache references', equivalent to instructions executed. ```text ==17942== I refs: 8,195,070 ``` -------------------------------- ### Configure GDB connection on Development System Source: https://valgrind.org/docs/manual/manual-core-adv.html On the development system, forward the port and start GDB to connect to the remote target. ```bash adb forward tcp:1234 tcp:1234 ``` ```bash gdb prog ``` ```gdb (gdb) target remote :1234 ``` -------------------------------- ### Build GDB on Solaris Source: https://valgrind.org/docs/manual/dist.readme-solaris.html Steps to download, patch, configure, and install GDB on Solaris, which is a prerequisite for Valgrind development on this platform. ```bash pkg install developer/gnu-binutils wget http://ftp.gnu.org/gnu/gdb/gdb-7.6.2.tar.gz gzip -dc gdb-7.6.2.tar.gz | tar xf - cd gdb-7.6.2 patch -p1 -i /path/to/valgrind-solaris/solaris/gdb-sol-thread.patch export LIBS="-lncurses" export CC="gcc -m64" ./configure --with-x=no --with-curses --with-libexpat-prefix=/usr/lib gmake && gmake install ``` -------------------------------- ### Valgrind Leak Summary with Heuristics Source: https://valgrind.org/docs/manual/mc-manual.html Example of a Valgrind leak summary that includes details on heuristically reachable memory subsets. ```text LEAK SUMMARY: definitely lost: 4 bytes in 1 blocks indirectly lost: 0 bytes in 0 blocks possibly lost: 0 bytes in 0 blocks still reachable: 95 bytes in 6 blocks of which reachable via heuristic: stdstring : 56 bytes in 2 blocks length64 : 16 bytes in 1 blocks newarray : 7 bytes in 1 blocks multipleinheritance: 8 bytes in 1 blocks suppressed: 0 bytes in 0 blocks ``` -------------------------------- ### Cachegrind Annotation Summary Example Source: https://valgrind.org/docs/manual/cg-manual.html Shows the summary output from cg_annotate, detailing the number of annotated and unannotated counts and the reasons for unannotation. ```text -------------------------------------------------------------------------------- -- Annotation summary -------------------------------------------------------------------------------- Ir______________ ``` ```text ``` -------------------------------- ### Basic Block Vector File Format Example Source: https://valgrind.org/docs/manual/bbv-manual.html This is an example of the Basic Block Vector file format. Each line starting with 'T' represents an interval, followed by basic block identifiers and their frequencies. ```text T:45:1024 :189:99343 T:11:78573 :15:1353 :56:1 T:18:45 :12:135353 :56:78 314:4324263 ``` -------------------------------- ### Build and Test a New Valgrind Tool Source: https://valgrind.org/docs/manual/manual-writing-tools.html Steps to configure, build, and install a new Valgrind tool using automake and autoconf. Includes commands for running the tool on a sample program. ```bash autogen.sh ./configure --prefix=`pwd`/inst make make install ``` ```bash inst/bin/valgrind --tool=foobar date ``` -------------------------------- ### Valgrind vgdb Extended-Remote Protocol Source: https://valgrind.org/docs/manual/dist.news.html Example of starting a program under Valgrind using GDB with the extended-remote protocol. This allows running GDB and Valgrind from the same terminal. ```bash $ gdb prog ``` ```gdb (gdb) set remote exec-file prog ``` ```gdb (gdb) set sysroot / ``` ```gdb (gdb) target extended-remote | vgdb --multi ``` ```gdb (gdb) start ``` -------------------------------- ### GDB Example: Enabling Host Visibility and Adding Symbol File Source: https://valgrind.org/docs/manual/manual-core-adv.html This GDB session demonstrates enabling host visibility and adding a symbol file for a Valgrind tool. This allows GDB to inspect Valgrind's internal variables and memory. ```gdb (gdb) monitor v.set hostvisibility yes Enabled access to Valgrind memory/status by GDB If not yet done, tell GDB which valgrind file(s) to use, typically: add-symbol-file /home/philippe/valgrind/git/improve/Inst/libexec/valgrind/memcheck-amd64-linux 0x58001000 (gdb) add-symbol-file /home/philippe/valgrind/git/improve/Inst/libexec/valgrind/memcheck-amd64-linux 0x58001000 add symbol table from file "/home/philippe/valgrind/git/improve/Inst/libexec/valgrind/memcheck-amd64-linux" at .text_addr = 0x58001000 (y or n) y Reading symbols from /home/philippe/valgrind/git/improve/Inst/libexec/valgrind/memcheck-amd64-linux... (gdb) ``` -------------------------------- ### Build Valgrind from source Source: https://valgrind.org/docs/manual/dist.readme-freebsd.html Follow these steps to build Valgrind from source, including autogen, configure, and make commands. ```bash $ sh autogen.sh $ ./configure --prefix=/where/ever $ gmake $ gmake install ``` -------------------------------- ### Implement a Valgrind wrapper function Source: https://valgrind.org/docs/manual/manual-core-adv.html A wrapper function intercepts calls to the original function. It requires including 'valgrind.h' and uses specific macros to get the original function's address, call it, and handle results. This example prints arguments and the return value. ```c #include #include "valgrind.h" int I_WRAP_SONAME_FNNAME_ZU(NONE,foo)( int x, int y ) { int result; OrigFn fn; VALGRIND_GET_ORIG_FN(fn); printf("foo's wrapper: args %d %d\n", x, y); CALL_FN_W_WW(result, fn, x,y); printf("foo's wrapper: result %d\n", result); return result; } ``` -------------------------------- ### Example Output Files from Performance Tests Source: https://valgrind.org/docs/manual/dist.readme-developers.html Illustrates the naming convention for output files generated when using Callgrind or Cachegrind as the outer tool. ```bash callgrind.out.inner_tchain.no.many-loss-records.18465 callgrind.outer.log.inner_tchain.no.many-loss-records.18465 callgrind.out.inner_tchain.me.many-loss-records.21899 callgrind.outer.log.inner_tchain.me.many-loss-records.21899 callgrind.out.inner_trunk.no.many-loss-records.21224 callgrind.outer.log.inner_trunk.no.many-loss-records.21224 callgrind.out.inner_trunk.me.many-loss-records.22916 callgrind.outer.log.inner_trunk.me.many-loss-records.22916 ``` -------------------------------- ### Valgrind --multi mode connection and start output Source: https://valgrind.org/docs/manual/manual-core-adv.html When using `--multi` mode, `vgdb` starts Valgrind automatically. This output shows the connection relay and the program starting with a temporary breakpoint. ```text Temporary breakpoint 1 at 0x24e0 Starting program: prog relaying data between gdb and process 2999348 Temporary breakpoint 1, 0x000000000010a4a0 in main () ``` -------------------------------- ### Start Valgrind with gdbserver enabled Source: https://valgrind.org/docs/manual/manual-core-adv.html Activate Valgrind's gdbserver by specifying `--vgdb=yes` or `--vgdb=full`. Use `--vgdb-error=number` to control when the gdbserver becomes active. A value of 0 activates it at startup. ```bash valgrind --tool=memcheck --vgdb=yes --vgdb-error=0 ./prog ``` -------------------------------- ### Program Example with Message Passing Source: https://valgrind.org/docs/manual/hg-manual.html Demonstrates a more abstract solution to race conditions using message passing to synchronize access to a shared variable, ensuring predictable program behavior. ```c Parent thread: Child thread: int var; // create child thread pthread_create(...) var = 20; // send message to child // wait for message to arrive var = 10; exit // wait for child pthread_join(...) printf("%d\n", var); ``` -------------------------------- ### Basic Scheme for Running MPI Apps with Valgrind Wrappers Source: https://valgrind.org/docs/manual/mc-manual.html This command shows the general method for running an MPI application with Valgrind and the MPI wrappers. It involves setting environment variables for debugging and preloading the wrapper library. ```bash MPIWRAP_DEBUG=[wrapper-args] \ LD_PRELOAD=$prefix/lib/valgrind/libmpiwrap-.so \ mpirun [mpirun-args] \ $prefix/bin/valgrind [valgrind-args] \ [application] [app-args] ``` -------------------------------- ### Run All Performance Tests with Outer Callgrind Source: https://valgrind.org/docs/manual/dist.readme-developers.html Execute all performance tests using an outer Callgrind instance. Ensure Valgrind is installed via 'make install'. ```bash perf/vg_perf --outer-valgrind=../outer/.../bin/valgrind \ --outer-tool=callgrind perf ``` -------------------------------- ### Enable Cache Simulation Source: https://valgrind.org/docs/manual/cg-manual.html Enable cache simulation with --cache-sim=yes to gather statistics on I1, D1, and LL cache accesses and misses. ```bash valgrind --tool=cachegrind --cache-sim=yes ./your_program ``` -------------------------------- ### Run All Performance Tests with Outer Cachegrind Source: https://valgrind.org/docs/manual/dist.readme-developers.html Execute all performance tests using an outer Cachegrind instance. Ensure Valgrind is installed via 'make install'. ```bash perf/vg_perf --outer-valgrind=../outer/.../bin/valgrind perf ``` -------------------------------- ### Valgrind Reachable Memory Leak Example Source: https://valgrind.org/docs/manual/mc-manual.html This snippet shows an example of memory that is still reachable but not freed. It is reported when using `--show-leak-kinds=all` or `--show-leak-kinds=reachable`. ```text 64 bytes in 4 blocks are still reachable in loss record 2 of 4 at 0x........: malloc (vg_replace_malloc.c:177) by 0x........: mk (leak-cases.c:52) by 0x........: main (leak-cases.c:74) ``` -------------------------------- ### Build distribution tarball Source: https://valgrind.org/docs/manual/dist.readme-developers.html Create a distribution tarball from the Valgrind sources. Use BUILD_DOCS=none to skip documentation building if only testing the tarball's integrity. ```bash make dist ``` ```bash make dist BUILD_DOCS=none ``` -------------------------------- ### List Dynamically Changeable Valgrind Options Source: https://valgrind.org/docs/manual/manual-core.html Use the `--help-dyn-options` flag with the Valgrind core and a specific tool to see which options can be changed during runtime. This helps identify available dynamic controls. ```bash $ valgrind --tool=memcheck --help-dyn-options dynamically changeable options: -v -q -d --stats --vgdb=no --vgdb=yes --vgdb=full --vgdb-poll --vgdb-error --vgdb-stop-at --error-markers --show-error-list -s --show-below-main --time-stamp --trace-children --child-silent-after-fork --trace-sched --trace-signals --trace-symtab --trace-cfi --debug-dump=syms --debug-dump=line --debug-dump=frames --trace-redir --trace-syscalls --sym-offsets --progress-interval --merge-recursive-frames --vex-iropt-verbosity --suppressions --trace-flags --trace-notbelow --trace-notabove --profile-flags --gen-suppressions=no --gen-suppressions=yes --gen-suppressions=all --errors-for-leak-kinds --show-leak-kinds --leak-check-heuristics --show-reachable --show-possibly-lost --freelist-vol --freelist-big-blocks --leak-check=no --leak-check=summary --leak-check=yes --leak-check=full --ignore-ranges --ignore-range-below-sp --show-mismatched-frees valgrind: Use --help for more information. $ ``` -------------------------------- ### Run Valgrind without installation Source: https://valgrind.org/docs/manual/dist.readme-developers.html Set the VALGRIND_LIB environment variable to the root of the source tree to run Valgrind without installing it. This is useful for quick testing during development. ```bash VALGRIND_LIB=~/grind/head4/.in_place ~/grind/head4/coregrind/valgrind ``` -------------------------------- ### Valgrind Used Suppressions Output Example Source: https://valgrind.org/docs/manual/mc-manual.html An example of Valgrind's output when the -v option is used, showing the list of used suppressions, their counts, and suppressed bytes/blocks. ```text --21041-- used_suppression: 10 some_other_leak_suppression s.supp:14 suppressed: 12,400 bytes in 1 blocks --21041-- used_suppression: 39 some_leak_suppression s.supp:2 suppressed: 96 bytes in 7 blocks ``` -------------------------------- ### Ad Hoc Profiling Example Source: https://valgrind.org/docs/manual/dh-manual.html An example PP node from DHAT's ad hoc profiling mode, illustrating custom event tracking using DHAT_AD_HOC_EVENT. ```text PP 1.1.1.1/2 { Total: 30 units (17.65%, 115.97/Minstr) in 1 events (14.29%, 3.87/Minstr), avg size 30 units Occurred at { ^1: 0x109407: g (ad-hoc.c:4) ^2: 0x109425: f (ad-hoc.c:8) #3: 0x109497: main (ad-hoc.c:14) } } ``` -------------------------------- ### DHAT Aggregate Nodes Output Example Source: https://valgrind.org/docs/manual/dh-manual.html Example of aggregated nodes in the PP tree. This output simplifies the view by grouping insignificant nodes, indicating the number of nodes aggregated. ```text PP 1.14.2/2 { Total: 5,175 blocks (0.09%, 0.26/Minstr) Allocated at { [5 insignificant] } } ``` -------------------------------- ### Basic Valgrind Invocation Source: https://valgrind.org/docs/manual/manual-core.html This is the general syntax for running Valgrind with any tool. Replace `valgrind-options` with specific Valgrind flags and `your-prog` with the executable to be analyzed. ```bash valgrind [valgrind-options] your-prog [your-prog-options] ``` -------------------------------- ### Run Specific Performance Test with Outer Cachegrind Source: https://valgrind.org/docs/manual/dist.readme-developers.html Execute a specific performance test (e.g., 'bz2') with an outer Cachegrind instance. Ensure Valgrind is installed via 'make install'. ```bash perf/vg_perf --outer-valgrind=../outer/.../bin/valgrind perf/bz2 ``` -------------------------------- ### Valgrind MPI Wrapper Startup Banner Source: https://valgrind.org/docs/manual/mc-manual.html This output is shown when the Valgrind MPI wrappers are active for a process. It confirms the wrappers are loaded and suggests checking MPIWRAP_DEBUG for more options. ```text valgrind MPI wrappers 31901: Active for pid 31901 valgrind MPI wrappers 31901: Try MPIWRAP_DEBUG=help for possible options ``` -------------------------------- ### Example DRD Data Race Detection Report Source: https://valgrind.org/docs/manual/drd-manual.html This is an example of a message printed by DRD when it detects a data race. It shows conflicting memory accesses, thread information, and call stacks. ```text $ valgrind --tool=drd --read-var-info=yes drd/tests/rwlock_race ... ==9466== Thread 3: ==9466== Conflicting load by thread 3 at 0x006020b8 size 4 ==9466== at 0x400B6C: thread_func (rwlock_race.c:29) ==9466== by 0x4C291DF: vg_thread_wrapper (drd_pthread_intercepts.c:186) ==9466== by 0x4E3403F: start_thread (in /lib64/libpthread-2.8.so) ==9466== by 0x53250CC: clone (in /lib64/libc-2.8.so) ==9466== Location 0x6020b8 is 0 bytes inside local var "s_racy" ==9466== declared at rwlock_race.c:18, in frame #0 of thread 3 ==9466== Other segment start (thread 2) ==9466== at 0x4C2847D: pthread_rwlock_rdlock* (drd_pthread_intercepts.c:813) ==9466== by 0x400B6B: thread_func (rwlock_race.c:28) ==9466== by 0x4C291DF: vg_thread_wrapper (drd_pthread_intercepts.c:186) ==9466== by 0x4E3403F: start_thread (in /lib64/libpthread-2.8.so) ==9466== by 0x53250CC: clone (in /lib64/libc-2.8.so) ==9466== Other segment end (thread 2) ==9466== at 0x4C28B54: pthread_rwlock_unlock* (drd_pthread_intercepts.c:912) ==9466== by 0x400B84: thread_func (rwlock_race.c:30) ==9466== by 0x4C291DF: vg_thread_wrapper (drd_pthread_intercepts.c:186) ==9466== by 0x4E3403F: start_thread (in /lib64/libpthread-2.8.so) ==9466== by 0x53250CC: clone (in /lib64/libc-2.8.so) ... ``` -------------------------------- ### Valgrind Conditional Jump Error Example Source: https://valgrind.org/docs/manual/faq.html This example shows a typical Valgrind error message for a conditional jump that depends on uninitialized values. The error indicates the memory address and the call stack where the issue occurred. ```text Conditional jump or move depends on uninitialised value(s) at 0x1051C39B: ??? by 0x12657AA7: ??? ``` -------------------------------- ### Run Valgrind with MPI Wrappers Source: https://valgrind.org/docs/manual/mc-manual.html This command demonstrates how to run an MPI application under Valgrind with the MPI wrapper library preloaded. Ensure you replace $prefix with your Valgrind installation path and with your system's platform identifier. ```bash LD_PRELOAD=$prefix/lib/valgrind/libmpiwrap-.so \ mpirun [args] $prefix/bin/valgrind ./hello ``` -------------------------------- ### Get location information for an address Source: https://valgrind.org/docs/manual/manual-core-adv.html Use 'v.info location ' to get details about a specific memory address. Enable '--read-var-info=yes' for more variable information. The GDB front-end allows using expressions directly. ```gdb (gdb) monitor v.info location 0x1130a0 Location 0x1130a0 is 0 bytes inside global var "mx" declared at tc19_shadowmem.c:19 (gdb) mo v.in loc 0x1ffefffe10 Location 0x1ffefffe10 is 0 bytes inside info.child, declared at tc19_shadowmem.c:139, in frame #1 of thread 1 (gdb) valgrind v.info location &mx Location 0x1130a0 is 0 bytes inside global var "mx" declared at tc19_shadowmem.c:19 (gdb) v v.i lo info Location 0x1ffefffe10 is 0 bytes inside info.child, declared at tc19_shadowmem.c:139, in frame #1 of thread 1 ``` -------------------------------- ### Initialize Tool Details Source: https://valgrind.org/docs/manual/manual-writing-tools.html Set compulsory and optional details for a Valgrind tool during initialization. `detail_bug_reports_to` is used for error reporting and assertion failures. ```c VG_(details_bug_reports_to) = "your_email@example.com"; ```