Tuesday, February 25, 2014

Valgrind's Memcheck + Valkyrie: Detect user space run time memory errors


In my last post 
Valgrind's Memcheck: Detect user space run time memory errors, I covered Valgrind's memcheck tool. I am not that impressed with memcheck's text based reporting of dyanamic analysis errors. In this post, I will cover Valkyrie - an intuitive GUI based tool to analyze memcheck's dyanmic analysis errors.

memcheck usage for Valkyrie



  • Step1: Recompile the program:
gcc -g prog.c -o <prog_name>

  • Step2: Run the program in valgrind emulator:
valgrind --leak-check=full --track-origins=yes --xml-file=<log_file.xml> --xml=yes <prog_name> <prog_args>

Usage Example:
  


root@babu-VirtualBox:~/valgrind_tests# valgrind --leak-check=full --track-origins=yes --xml-file=vk_log.xml --xml=yes ./vg_test.o 1 2 3 4 5 7 8 9
10
*num = 0 
i[-1] = 0 
Please type a bunch of characters and hit enter.
34
root@babu-VirtualBox:~/valgrind_tests#



Reporting and Analysis of memcheck results using Valkyrie


apt-get install valkyrie
apt-get install vim-gtk

root@babu-VirtualBox:~/valgrind_tests# valkyrie --view-log ./vk_log.xml &
[1] 12307
root@babu-VirtualBox:~/valgrind_tests# MainWindow::runTool( tool: 0, proc: 1 )
Valkyrie::runTool( 0, 1)
.
.

Below are some screenshots of Valkyrie for my log file:
  • Top level screen displaying headlines of all the dynamic analysis errors:



  • Screen displaying Memory Leak along with stack trace:



  • Screen displaying Double free along with stack trace:




Hope this helps.


1 comment:

Unknown said...

How to run valkyrie on Ubuntu in VM from Mac

UA-48797665-1