Valgrind Tool Introduction
So what is Valgrind ? It may be possible that at the time of reading this post, you may have basic familiarity with Valgrind or vice-versa. So lets understand the basic purpose of Valgrind before diving deeper into the topic. In the very naive language, it can be described as a tool used for memory debugging and code profiling . The different purposes for which this tool can be used for memory debugging are listed below :
- Indicates wherever uninitialized memory is used in the code.
- depicts where read/write operation is being performed after freeing the memory block
- depicts whenever code tries to write outside the memory block allocated by malloc
- highlights the memory leaks in the code
- highlights when code tries to access the inappropriate areas on the stack
Give example of how to use it in code…
valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./try
=> where try is an executable file for which you need to perform memory debugging.
But now Valgrind is much more than a simple profiler tools as it has evolved as an infrastructure for code profiling and memory debugging offering different techniques to catch serious issues which can break your code in real time execution. Different tools which are being offered to Valgrind users are listed below :
- Memcheck – This provides the facility for debugging memory management related errors in the code. So its kinda memory profiler
- CacheCheck – This is a cache profiler
- Callgrind – It provides all the information that cachecheck provides plus the extra information of Call Graph.
- Massif – This is a heap profiler.
- Helgrind – This tool is used to detect data race conditions for multi threaded programs
- DRD – DRD is a tool for identifying errors in multi-threaded C /C++ programs
So how does this tool detects all this stuff prematurely. Basically , tools like valgrind executes your executable in the simulated environment in which memory allocations are much more controlled and guarded as compared to our real time run environment. So these tools provides this extra disciplined simulated run environment against which they test our executable and at the same time, catch different error in our executable which results in breakage during execution based upon the different parameters for which user wants his executable to be tested.
I know this is a very brief description about an interesting tool like valgrind and its related tools. So, we will talk about Valgrind and its related tools in detail in next part.. Till then See you guys.. Keep debugging !!!
You can download Valgrind tool from this Link
Author’s Note : Hey Guys!!! Currently I am not sure what and how much data is to provided in the posts to keep it brief and at the same make it useful for your use. So please help me improvising to make this and other posts (basically the whole stuff) more useful and interesting for you guys… Thanks in Advance !!!