Skip to content

Latest commit

 

History

History
138 lines (117 loc) · 2.2 KB

valgrind.md

File metadata and controls

138 lines (117 loc) · 2.2 KB

Valgrind

Resources

Memcheck

Detect common memory faults in a program?

Valgrind is capable of checking for memory leaks on a binary file.

gcc -o program main.c
valgrind ./program

To have a better output from Valgrind, compile with debug info:

gcc -o program main.c -g3
valgrind ./program

Resources

  • YouTube: C++ Weekly - Ep 86 - Valgrind

References

Trace the origin of variables causing memory leaks?
valgrind --track-origins ./program

Resources

  • YouTube: C++ Weekly - Ep 86 - Valgrind

References

Fully check for memory leak of a program?
valgrind --leak-check full ./program

Resources

  • YouTube: Detecting Memory Leaks With Valgrind

References

Helgrind

Callgrind

Count the number of instructions used in a program?

Description

valgrind --tool callgrind ./program

Resources

  • YouTube: C++ Weekly - Ep 86 - Valgrind

References

Use interactive control to use callgrind dump file?

Description


Resources

  • YouTube: C++ Weekly - Ep 86 - Valgrind

References

Use a user interface to interactively control the use of callgrind dump file?
kcachegrind callgrind-dump.out.123

Resources

  • YouTube: C++ Weekly - Ep 86 - Valgrind

References

Cachegrind

Running with GDB

Attach gdb remote session to valgrind?

Description

gdb ./program
(gdb) set remote exec-file ./program
(gdb) set sysroot /
(gdb) target extended-remote | vgdb --multi --vargs -q
(gdb) start
(gdb) help valgrind
(gdb) help memcheck
(gdb) help helgrind

Resources

  • YouTube: Debugging memory issues with Valgrind and GDB - DevConf.CZ 2023

References