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 ./programTo 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
Trace the origin of variables causing memory leaks?
valgrind --track-origins ./program
Resources
- YouTube: C++ Weekly - Ep 86 - Valgrind
Fully check for memory leak of a program?
valgrind --leak-check full ./program
Resources
- YouTube: Detecting Memory Leaks With Valgrind
Count the number of instructions used in a program?
Description
valgrind --tool callgrind ./program
Resources
- YouTube: C++ Weekly - Ep 86 - Valgrind
Use interactive control to use callgrind dump file?
Description
Resources
- YouTube: C++ Weekly - Ep 86 - Valgrind
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
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