Date created: Saturday, October 10, 2015 3:03:32 PM. Last modified: Friday, January 3, 2020 3:34:08 PM

Valgrind Notes

References:
http://c.learncodethehardway.org/book/ex41.html
http://valgrind.org/docs/manual/sg-manual.html

Compile with debug flags:

g++ -o etherate etherate.cpp -lrt -O0 -g

Valgrind

valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --track-fds=yes ./etherate -r

Callgrind - Annotate each line with the number of instructions it ran (Ir)

valgrind --tool=callgrind ./etherate -r
callgrind_annotate ./callgrind.out.2974 /path/to/tests.cpp

or

callgrind_annotate --auto=yes ./callgrind.out.2974

Cachegrind - Annotate each line with memory reads/writes/misses and instructions

valgrind --tool=cachegrind ./etherate -r
cg_annotate ./cachegrind-out /path/to/tests.cpp

KCachegrind

sudo kcachegrind cachegrind.out

Branch predictor simulator

gcc -o etherate_mt etherate_mt.c -lpthread -Wall -Werror -pedantic -ftrapv -fstack-protector-all -Og -g
sudo taskset -c 2 valgrind --tool=cachegrind --branch-sim=yes ./etherate_mt -I 1
sudo cg_annotate cachegrind.out.3331 /home/bensley/C/etherate_mt/etherate_mt.c

Previous page: Stack, Heap and Stack Frame
Next page: Bass-Kick-Hi-Hat